Skip to content

Commit

Permalink
chore: [#1258] Fixes unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
capricorn86 committed Mar 12, 2024
1 parent 1711be4 commit 1f21076
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/happy-dom/src/custom-element/CustomElementRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,23 @@ export default class CustomElementRegistry {

Object.defineProperty(elementClass.prototype, 'localName', {
configurable: true,
get: () => name
get: function () {
return this[PropertySymbol.localName] || name;
}
});

Object.defineProperty(elementClass.prototype, 'tagName', {
configurable: true,
get: () => tagName
get: function () {
return this[PropertySymbol.tagName] || tagName;
}
});

Object.defineProperty(elementClass.prototype, 'namespaceURI', {
configurable: true,
get: () => NamespaceURI.html
get: function () {
return this[PropertySymbol.namespaceURI] || NamespaceURI.html;
}
});

this[PropertySymbol.registry][name] = {
Expand Down
3 changes: 3 additions & 0 deletions packages/happy-dom/src/nodes/document/Document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,9 @@ export default class Document extends Node implements IDocument {

if (customElement) {
const element = new customElement.elementClass();
element[PropertySymbol.tagName] = qualifiedName.toUpperCase();
element[PropertySymbol.localName] = qualifiedName;
element[PropertySymbol.namespaceURI] = namespaceURI;
element[PropertySymbol.isValue] = options && options.is ? String(options.is) : null;
return element;
}
Expand Down

0 comments on commit 1f21076

Please sign in to comment.