diff --git a/lib/jsdom/browser/Window.js b/lib/jsdom/browser/Window.js index 92989c2bf9..68704d11ac 100644 --- a/lib/jsdom/browser/Window.js +++ b/lib/jsdom/browser/Window.js @@ -543,14 +543,10 @@ function Window(options) { return declaration; }; - const customElementRegistryImpl = CustomElementRegistry.createImpl([], { + this.customElements = CustomElementRegistry.create([], { _ownerDocument: idlUtils.implForWrapper(this._document) }); - // TODO: move this to the document instead of the window object if possible. - this._customElements = customElementRegistryImpl; - this.customElements = idlUtils.wrapperForImpl(customElementRegistryImpl); - // The captureEvents() and releaseEvents() methods must do nothing this.captureEvents = function () {}; diff --git a/lib/jsdom/browser/parser/html.js b/lib/jsdom/browser/parser/html.js index 62352dbb04..4a3676289f 100644 --- a/lib/jsdom/browser/parser/html.js +++ b/lib/jsdom/browser/parser/html.js @@ -83,7 +83,6 @@ class JSDOMParse5Adapter { willExecuteScript = true; } - // TODO: need to better understand the implications of the changes here. const element = createElement(this._documentImpl, localName, namespace, null, isValue, willExecuteScript); this.adoptAttributes(element, attrs); @@ -173,8 +172,6 @@ class JSDOMParse5Adapter { Object.assign(JSDOMParse5Adapter.prototype, serializationAdapter); function parseFragment(markup, contextElement) { - // TODO: Readjust the content document. - // Explain better const ownerDocument = contextElement.localName === "template" ? contextElement.content._ownerDocument : contextElement._ownerDocument; diff --git a/lib/jsdom/living/custom-elements/CustomElementRegistry-impl.js b/lib/jsdom/living/custom-elements/CustomElementRegistry-impl.js index 32cb4e9d0c..5523a9b5b5 100644 --- a/lib/jsdom/living/custom-elements/CustomElementRegistry-impl.js +++ b/lib/jsdom/living/custom-elements/CustomElementRegistry-impl.js @@ -68,7 +68,6 @@ class CustomElementRegistryImpl { // https://html.spec.whatwg.org/#dom-customelementregistry-define define(name, ctor, options) { - // TODO: Add better check if the ctor is a constructor if (typeof ctor !== "function" || !isConstructor(ctor)) { throw new TypeError("Constructor argument is not a constructor."); } @@ -111,9 +110,8 @@ class CustomElementRegistryImpl { } if (this._elementDefinitionIsRunning) { - // TODO: Improve wording throw new DOMException( - "Can't define a new custom element in the middle of the definition of another one.", + "Invalid nested custom element definition.", "NotSupportedError" ); } diff --git a/lib/jsdom/living/helpers/custom-elements.js b/lib/jsdom/living/helpers/custom-elements.js index dd75c73fcb..c825369584 100644 --- a/lib/jsdom/living/helpers/custom-elements.js +++ b/lib/jsdom/living/helpers/custom-elements.js @@ -154,7 +154,7 @@ function lookupCEDefinition(document, namespace, localName, isValue) { return definition; } - const registry = document._defaultView._customElements; + const registry = implForWrapper(document._defaultView.customElements); const definitionByName = registry._customElementDefinitions.find(def => { return def.name === def.localName && def.localName === localName; diff --git a/lib/jsdom/living/helpers/html-constructor.js b/lib/jsdom/living/helpers/html-constructor.js index 9fedf86330..3b66edb52c 100644 --- a/lib/jsdom/living/helpers/html-constructor.js +++ b/lib/jsdom/living/helpers/html-constructor.js @@ -85,7 +85,7 @@ const ALREADY_CONSTRUCTED_MARKER = Symbol("already-constructed-marker"); // https://html.spec.whatwg.org/multipage/dom.html#htmlconstructor function HTMLConstructor({ globalObject, newTarget, constructorName }) { - const registry = globalObject._customElements; + const registry = implForWrapper(globalObject.customElements); if (newTarget === HTMLConstructor) { throw new TypeError("Invalid constructor");