Skip to content

Commit

Permalink
first PR cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
pmdartus committed Sep 20, 2019
1 parent bbc5318 commit 4cca088
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 13 deletions.
6 changes: 1 addition & 5 deletions lib/jsdom/browser/Window.js
Expand Up @@ -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 () {};

Expand Down
3 changes: 0 additions & 3 deletions lib/jsdom/browser/parser/html.js
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down
Expand Up @@ -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.");
}
Expand Down Expand Up @@ -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"
);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/jsdom/living/helpers/custom-elements.js
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/jsdom/living/helpers/html-constructor.js
Expand Up @@ -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");
Expand Down

0 comments on commit 4cca088

Please sign in to comment.