Skip to content

Commit

Permalink
Merge pull request #641 from IGx89/task/204-support-html-anchor-element
Browse files Browse the repository at this point in the history
#204@minor: Add support for HTMLAnchorElement.
  • Loading branch information
capricorn86 committed Nov 11, 2022
2 parents 1a21ed7 + 2debb1b commit e91b864
Show file tree
Hide file tree
Showing 9 changed files with 925 additions and 29 deletions.
3 changes: 2 additions & 1 deletion packages/happy-dom/src/config/ElementTag.ts
Expand Up @@ -20,9 +20,10 @@ import HTMLDialogElement from '../nodes/html-dialog-element/HTMLDialogElement';
import HTMLButtonElement from '../nodes/html-button-element/HTMLButtonElement';
import HTMLAudioElement from '../nodes/html-audio-element/HTMLAudioElement';
import HTMLVideoElement from '../nodes/html-video-element/HTMLVideoElement';
import HTMLAnchorElement from '../nodes/html-anchor-element/HTMLAnchorElement';

export default {
A: HTMLElement,
A: HTMLAnchorElement,
ABBR: HTMLElement,
ADDRESS: HTMLElement,
AREA: HTMLElement,
Expand Down
2 changes: 1 addition & 1 deletion packages/happy-dom/src/dom-token-list/DOMTokenList.ts
Expand Up @@ -199,7 +199,7 @@ export default class DOMTokenList implements IDOMTokenList {
* Updates indices.
*/
public _updateIndices(): void {
const attr = this._ownerElement.getAttribute('class');
const attr = this._ownerElement.getAttribute(this._attributeName);
const list = attr ? Array.from(new Set(attr.split(' '))) : [];

for (let i = list.length - 1, max = this.length; i < max; i++) {
Expand Down
17 changes: 6 additions & 11 deletions packages/happy-dom/src/nodes/element/Element.ts
Expand Up @@ -840,7 +840,9 @@ export default class Element extends Node implements IElement {

this._attributes[name] = attribute;

this._updateDomListIndices();
if (attribute.name === 'class' && this._classList) {
this._classList._updateIndices();
}

if (
this.attributeChangedCallback &&
Expand Down Expand Up @@ -936,7 +938,9 @@ export default class Element extends Node implements IElement {
this.ownerDocument['_cacheID']++;
}

this._updateDomListIndices();
if (attribute.name === 'class' && this._classList) {
this._classList._updateIndices();
}

if (
this.attributeChangedCallback &&
Expand Down Expand Up @@ -1033,13 +1037,4 @@ export default class Element extends Node implements IElement {
}
return name.toLowerCase();
}

/**
* Updates DOM list indices.
*/
protected _updateDomListIndices(): void {
if (this._classList) {
this._classList._updateIndices();
}
}
}

0 comments on commit e91b864

Please sign in to comment.