Skip to content

Commit

Permalink
finish tiraging rest of the bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
pmdartus committed Sep 18, 2019
1 parent cf21cd1 commit 7194048
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 26 deletions.
6 changes: 5 additions & 1 deletion lib/jsdom/browser/parser/html.js
Expand Up @@ -173,7 +173,11 @@ class JSDOMParse5Adapter {
Object.assign(JSDOMParse5Adapter.prototype, serializationAdapter);

function parseFragment(markup, contextElement) {
const ownerDocument = contextElement._ownerDocument;
// TODO: Readjust the content document.
// Explain better
const ownerDocument = contextElement.localName === "template" ?
contextElement.content._ownerDocument :
contextElement._ownerDocument;

const config = Object.assign({}, ownerDocument._parseOptions, {
treeAdapter: new JSDOMParse5Adapter(ownerDocument, {
Expand Down
2 changes: 0 additions & 2 deletions lib/jsdom/living/helpers/ce-reactions.js
Expand Up @@ -444,7 +444,6 @@ const CE_REACTIONS_INTERFACES = {
],
HTMLHeadingElement: ["align"],
HTMLTextAreaElement: [

"autocomplete",
"autofocus",
"cols",
Expand All @@ -463,7 +462,6 @@ const CE_REACTIONS_INTERFACES = {
"value"
],
HTMLButtonElement: [

"autofocus",
"disabled",
"formAction",
Expand Down
10 changes: 5 additions & 5 deletions lib/jsdom/living/helpers/custom-elements.js
Expand Up @@ -172,10 +172,10 @@ function invokeCEReactions(elementQueue) {
) {
const reactions = element._ceReactionQueue;

while (reactions.length > 0) {
const reaction = reactions.shift();
try {
while (reactions.length > 0) {
const reaction = reactions.shift();

try {
switch (reaction.type) {
case "upgrade":
upgradeElement(reaction.definition, element);
Expand All @@ -185,9 +185,9 @@ function invokeCEReactions(elementQueue) {
reaction.callback.apply(wrapperForImpl(element), reaction.args);
break;
}
} catch (error) {
reportException(element._ownerDocument._defaultView, error);
}
} catch (error) {
reportException(element._ownerDocument._defaultView, error);
}
}
}
Expand Down
11 changes: 7 additions & 4 deletions lib/jsdom/living/nodes/DOMStringMap-impl.js
Expand Up @@ -60,10 +60,13 @@ class DOMStringMapImpl {
}
}

// This is poor work-around to make [CEReactions] work with interfaces using proxies.
// TODO: This is poor work-around to make [CEReactions] work with interfaces using proxies.
// Instead of patching the interfaces, in those cases we patch directly the class impl
DOMStringMapImpl.prototype[idlUtils.namedSetNew] = wrapWithCEReactions(DOMStringMapImpl.prototype[idlUtils.namedSetNew]);
DOMStringMapImpl.prototype[idlUtils.namedSetExisting] = wrapWithCEReactions(DOMStringMapImpl.prototype[idlUtils.namedSetExisting]);
DOMStringMapImpl.prototype[idlUtils.namedDelete] = wrapWithCEReactions(DOMStringMapImpl.prototype[idlUtils.namedDelete]);
DOMStringMapImpl.prototype[idlUtils.namedSetNew] =
wrapWithCEReactions(DOMStringMapImpl.prototype[idlUtils.namedSetNew]);
DOMStringMapImpl.prototype[idlUtils.namedSetExisting] =
wrapWithCEReactions(DOMStringMapImpl.prototype[idlUtils.namedSetExisting]);
DOMStringMapImpl.prototype[idlUtils.namedDelete] =
wrapWithCEReactions(DOMStringMapImpl.prototype[idlUtils.namedDelete]);

exports.implementation = DOMStringMapImpl;
12 changes: 10 additions & 2 deletions lib/jsdom/living/nodes/HTMLOptionsCollection-impl.js
Expand Up @@ -6,8 +6,9 @@ const { DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_CONTAINED_BY } = require("
const Element = require("../generated/Element");
const Node = require("../generated/Node");
const HTMLCollectionImpl = require("./HTMLCollection-impl").implementation;
const { wrapWithCEReactions } = require("../helpers/ce-reactions");

exports.implementation = class HTMLOptionsCollectionImpl extends HTMLCollectionImpl {
class HTMLOptionsCollectionImpl extends HTMLCollectionImpl {
// inherits supported property indices
get length() {
this._update();
Expand Down Expand Up @@ -104,4 +105,11 @@ exports.implementation = class HTMLOptionsCollectionImpl extends HTMLCollectionI
set selectedIndex(value) {
this._element.selectedIndex = value;
}
};
}

// TODO: This is poor work-around to make [CEReactions] work with interfaces using proxies.
// Instead of patching the interfaces, in those cases we patch directly the class impl
HTMLOptionsCollectionImpl.prototype[idlUtils.indexedSetNew] =
wrapWithCEReactions(HTMLOptionsCollectionImpl.prototype[idlUtils.indexedSetNew]);

exports.implementation = HTMLOptionsCollectionImpl;
1 change: 1 addition & 0 deletions lib/jsdom/living/nodes/HTMLSelectElement-impl.js
Expand Up @@ -13,6 +13,7 @@ const HTMLCollection = require("../generated/HTMLCollection");
const HTMLOptionsCollection = require("../generated/HTMLOptionsCollection");
const { domSymbolTree } = require("../helpers/internal-constants");
const { getLabelsForLabelable, formOwner } = require("../helpers/form-controls");
const { wrapWithCEReactions } = require("../helpers/ce-reactions");

class HTMLSelectElementImpl extends HTMLElementImpl {
constructor(args, privateData) {
Expand Down
23 changes: 11 additions & 12 deletions test/web-platform-tests/to-run.yaml
Expand Up @@ -108,20 +108,19 @@ parser/parser-uses-registry-of-owner-document.html: [fail, TODO]
parser/serializing-html-fragments.html: [fail, parse5 doesn't support is attribute for serialization]
perform-microtask-checkpoint-before-construction.html: [fail, impossible to implement microtask checkpoint without patching Promise]
pseudo-class-defined.html: [timeout, :defined is not defined and throws]
range-and-constructors.html: [fail, Range is not implemented]
range-and-constructors.html: [fail, Range is not implemented, https://github.com/jsdom/jsdom/issues/317]
reactions/CSSStyleDeclaration.html: [fail, CSSStyleDeclaration is not implemented using wedidl2js]
reactions/Document.html: [fail, TODO]
reactions/Document.html: [fail,
Document.execCommand is not implemented, https://github.com/jsdom/jsdom/issues/1539
Document.write implementation is not spec compliant]
reactions/ElementContentEditable.html: [fail, contentEditable is not implemented]
# reactions/HTMLButtonElement.html: [fail, TODO]
reactions/HTMLElement.html: [fail, TODO]
reactions/HTMLOptionsCollection.html: [fail, TODO]
reactions/HTMLSelectElement.html: [fail, TODO]
reactions/Range.html: [fail, Range is not implemented]
reactions/Selection.html: [fail, Selection is not implemented]
throw-on-dynamic-markup-insertion-counter-construct.html: [timeout, TODO]
throw-on-dynamic-markup-insertion-counter-reactions.html: [timeout, TODO]
upgrading/Document-importNode.html: [fail, TODO]
upgrading/upgrading-enqueue-reactions.html: [fail, TODO]
reactions/HTMLButtonElement.html: [fail, HTMLButtonElement doesn't implement formAction formEnctype and formMethod]
reactions/HTMLElement.html: [fail, translate and spellcheck attributes are not implemented on HTMLElement]
reactions/Range.html: [fail, Range is not implemented, https://github.com/jsdom/jsdom/issues/317]
reactions/Selection.html: [fail, Selection is not implemented, https://github.com/jsdom/jsdom/issues/937]
throw-on-dynamic-markup-insertion-counter-construct.html: [timeout, Document.write implementation is not spec compliant]
throw-on-dynamic-markup-insertion-counter-reactions.html: [timeout, Document.write implementation is not spec compliant]
upgrading/Document-importNode.html: [fail, HTMLElement constructor is patched for each window and is different than the one used via createElement, TODO]

---

Expand Down

0 comments on commit 7194048

Please sign in to comment.