diff --git a/lib/jsdom/living/helpers/ce-reactions.js b/lib/jsdom/living/helpers/ce-reactions.js index 58809edd88..692524aa18 100644 --- a/lib/jsdom/living/helpers/ce-reactions.js +++ b/lib/jsdom/living/helpers/ce-reactions.js @@ -1,6 +1,7 @@ "use strict"; const { CUSTOM_ELEMENT_REACTIONS_STACK, invokeCEReactions } = require("./custom-elements"); +const idlUtils = require("../generated/utils"); /** * Mapping of all the property interfaces that are marked with the [CEReaction] attributes. @@ -349,7 +350,9 @@ const CE_REACTIONS_INTERFACES = { "bgColor" ], HTMLTimeElement: ["dateTime"], - DOMStringMap: ["void"], + DOMStringMap: [ + "void" + ], HTMLElement: [ "title", "lang", @@ -672,5 +675,6 @@ function patchInterfaces(interfaces) { } module.exports = { - patchInterfaces + patchInterfaces, + wrapWithCEReactions }; diff --git a/lib/jsdom/living/nodes/DOMStringMap-impl.js b/lib/jsdom/living/nodes/DOMStringMap-impl.js index 4941c3e8fb..7471d4b534 100644 --- a/lib/jsdom/living/nodes/DOMStringMap-impl.js +++ b/lib/jsdom/living/nodes/DOMStringMap-impl.js @@ -4,6 +4,7 @@ const idlUtils = require("../generated/utils.js"); const { setAttributeValue, removeAttributeByName } = require("../attributes"); const validateName = require("../helpers/validate-names").name; const DOMException = require("domexception"); +const { wrapWithCEReactions } = require("../helpers/ce-reactions"); const dataAttrRe = /^data-([^A-Z]*)$/; @@ -15,7 +16,7 @@ function attrSnakeCase(name) { return name.replace(/[A-Z]/g, match => `-${match.toLowerCase()}`); } -exports.implementation = class DOMStringMapImpl { +class DOMStringMapImpl { constructor(args, privateData) { this._element = privateData.element; } @@ -57,4 +58,12 @@ exports.implementation = class DOMStringMapImpl { name = `data-${attrSnakeCase(name)}`; removeAttributeByName(this._element, name); } -}; +} + +// 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]); + +exports.implementation = DOMStringMapImpl; diff --git a/test/web-platform-tests/to-run.yaml b/test/web-platform-tests/to-run.yaml index 2b8c32f881..7ab3c5a434 100644 --- a/test/web-platform-tests/to-run.yaml +++ b/test/web-platform-tests/to-run.yaml @@ -104,21 +104,20 @@ microtasks-and-constructors.html: [fail, Usage of external scripts doesn't block parser/parser-constructs-custom-element-synchronously.html: [fail, Usage of external scripts doesn't block HTML parsing, https://github.com/jsdom/jsdom/issues/2413] parser/parser-sets-attributes-and-children.html: [fail, Usage of external scripts doesn't block HTML parsing, https://github.com/jsdom/jsdom/issues/2413] parser/parser-uses-constructed-element.html: [fail, Usage of external scripts doesn't block HTML parsing, https://github.com/jsdom/jsdom/issues/2413] -# parser/parser-uses-registry-of-owner-document.html: [fail, TODO] +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, TODO] +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, TODO] -reactions/CSSStyleDeclaration.html: [fail, TODO] -reactions/DOMStringMap.html: [fail, TODO] +range-and-constructors.html: [fail, Range is not implemented] +reactions/CSSStyleDeclaration.html: [fail, CSSStyleDeclaration is not implemented using wedidl2js] reactions/Document.html: [fail, TODO] -reactions/ElementContentEditable.html: [fail, TODO] -reactions/HTMLButtonElement.html: [fail, TODO] +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, TODO] -reactions/Selection.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]