diff --git a/lib/jsdom/living/nodes/HTMLDetailsElement-impl.js b/lib/jsdom/living/nodes/HTMLDetailsElement-impl.js new file mode 100644 index 0000000000..b6d5643176 --- /dev/null +++ b/lib/jsdom/living/nodes/HTMLDetailsElement-impl.js @@ -0,0 +1,40 @@ +"use strict"; + +const Event = require("../generated/Event.js"); + +const HTMLElementImpl = require("./HTMLElement-impl").implementation; + +class HTMLDetailsElementImpl extends HTMLElementImpl { + constructor(args, privateData) { + super(args, privateData); + + this._taskQueue = null; + } + + _dispatchToggleEvent() { + this._taskQueue = null; + + this._dispatch( + Event.createImpl(["toggle", { + bubbles: false, cancelable: false + }], { isTrusted: true }) + ); + } + + _attrModified(name, value, oldValue) { + super._attrModified(name, value, oldValue); + + if (name === "open" && this._taskQueue === null) { + // Check that the attribute is added or removed, not merely changed + if (value !== oldValue && + value !== null && oldValue === null || + value === null && oldValue !== null) { + this._taskQueue = setTimeout(this._dispatchToggleEvent.bind(this), 0); + } + } + } +} + +module.exports = { + implementation: HTMLDetailsElementImpl +}; diff --git a/lib/jsdom/living/nodes/HTMLDetailsElement.idl b/lib/jsdom/living/nodes/HTMLDetailsElement.idl new file mode 100644 index 0000000000..ea1e38899d --- /dev/null +++ b/lib/jsdom/living/nodes/HTMLDetailsElement.idl @@ -0,0 +1,5 @@ +[Exposed=Window, + HTMLConstructor] +interface HTMLDetailsElement : HTMLElement { + [CEReactions, Reflect] attribute boolean open; +}; diff --git a/lib/jsdom/living/nodes/HTMLMarqueeElement-impl.js b/lib/jsdom/living/nodes/HTMLMarqueeElement-impl.js new file mode 100644 index 0000000000..66371cbced --- /dev/null +++ b/lib/jsdom/living/nodes/HTMLMarqueeElement-impl.js @@ -0,0 +1,9 @@ +"use strict"; + +const HTMLElementImpl = require("./HTMLElement-impl").implementation; + +class HTMLMarqueeElementImpl extends HTMLElementImpl { } + +module.exports = { + implementation: HTMLMarqueeElementImpl +}; diff --git a/lib/jsdom/living/nodes/HTMLMarqueeElement.idl b/lib/jsdom/living/nodes/HTMLMarqueeElement.idl new file mode 100644 index 0000000000..d9cdb79416 --- /dev/null +++ b/lib/jsdom/living/nodes/HTMLMarqueeElement.idl @@ -0,0 +1,22 @@ +[Exposed=Window, + HTMLConstructor] +interface HTMLMarqueeElement : HTMLElement { + [CEReactions, Reflect] attribute DOMString behavior; + [CEReactions, Reflect=bgcolor] attribute DOMString bgColor; + [CEReactions, Reflect] attribute DOMString direction; + [CEReactions, Reflect] attribute DOMString height; + [CEReactions, Reflect] attribute unsigned long hspace; +// [CEReactions] attribute long loop; + [CEReactions, Reflect=scrollamount] attribute unsigned long scrollAmount; + [CEReactions, Reflect=scrolldelay] attribute unsigned long scrollDelay; + [CEReactions, Reflect=truespeed] attribute boolean trueSpeed; + [CEReactions, Reflect] attribute unsigned long vspace; + [CEReactions, Reflect] attribute DOMString width; + +// attribute EventHandler onbounce; +// attribute EventHandler onfinish; +// attribute EventHandler onstart; + +// void start(); +// void stop(); +}; diff --git a/lib/jsdom/living/nodes/HTMLPictureElement-impl.js b/lib/jsdom/living/nodes/HTMLPictureElement-impl.js new file mode 100644 index 0000000000..6d2062f0f4 --- /dev/null +++ b/lib/jsdom/living/nodes/HTMLPictureElement-impl.js @@ -0,0 +1,9 @@ +"use strict"; + +const HTMLElementImpl = require("./HTMLElement-impl").implementation; + +class HTMLPictureElementImpl extends HTMLElementImpl { } + +module.exports = { + implementation: HTMLPictureElementImpl +}; diff --git a/lib/jsdom/living/nodes/HTMLPictureElement.idl b/lib/jsdom/living/nodes/HTMLPictureElement.idl new file mode 100644 index 0000000000..d71b87d794 --- /dev/null +++ b/lib/jsdom/living/nodes/HTMLPictureElement.idl @@ -0,0 +1,3 @@ +[Exposed=Window, + HTMLConstructor] +interface HTMLPictureElement : HTMLElement {}; diff --git a/lib/jsdom/living/register-elements.js b/lib/jsdom/living/register-elements.js index 00cdc24046..10ad20c55a 100644 --- a/lib/jsdom/living/register-elements.js +++ b/lib/jsdom/living/register-elements.js @@ -106,6 +106,10 @@ const mappings = { file: require("./generated/HTMLDataListElement.js"), tags: ["datalist"] }, + HTMLDetailsElement: { + file: require("./generated/HTMLDetailsElement.js"), + tags: ["details"] + }, HTMLDialogElement: { file: require("./generated/HTMLDialogElement.js"), tags: ["dialog"] @@ -194,6 +198,10 @@ const mappings = { file: require("./generated/HTMLMapElement.js"), tags: ["map"] }, + HTMLMarqueeElement: { + file: require("./generated/HTMLMarqueeElement.js"), + tags: ["marquee"] + }, HTMLMediaElement: { file: require("./generated/HTMLMediaElement.js"), tags: [] @@ -242,6 +250,10 @@ const mappings = { file: require("./generated/HTMLParamElement.js"), tags: ["param"] }, + HTMLPictureElement: { + file: require("./generated/HTMLPictureElement.js"), + tags: ["picture"] + }, HTMLPreElement: { file: require("./generated/HTMLPreElement.js"), tags: ["listing", "pre", "xmp"] diff --git a/test/web-platform-tests/index.js b/test/web-platform-tests/index.js index 48692fee05..1633a8c5b1 100644 --- a/test/web-platform-tests/index.js +++ b/test/web-platform-tests/index.js @@ -175,6 +175,10 @@ describe("Web Platform Tests", () => { "html/editing/focus/document-level-focus-apis/document-level-apis.html", "html/editing/focus/sequential-focus-navigation-and-the-tabindex-attribute/focus-tabindex-default-value.html", // "html/infrastructure/urls/terminology-0/document-base-url.html", // we don't support srcdoc correctly + // "html/obsolete/requirements-for-implementations/the-marquee-element-0/marquee-events.html", // events are not implemented + // "html/obsolete/requirements-for-implementations/the-marquee-element-0/marquee-loop.html", // only basic reflection is implemented + // "html/obsolete/requirements-for-implementations/the-marquee-element-0/marquee-scrollamount.html", // only basic reflection is implemented + // "html/obsolete/requirements-for-implementations/the-marquee-element-0/marquee-scrolldelay.html", // only basic reflection is implemented "html/obsolete/requirements-for-implementations/other-elements-attributes-and-apis/nothing.html", "html/semantics/forms/attributes-common-to-form-controls/disabled-elements-01.html", "html/semantics/forms/resetting-a-form/reset-form-2.html", @@ -220,6 +224,8 @@ describe("Web Platform Tests", () => { "html/semantics/document-metadata/the-base-element/base_href_unspecified.html", // "html/semantics/document-metadata/the-base-element/base_multiple.html", // we don't support navigation via "html/semantics/document-metadata/the-base-element/base_srcdoc.html", + "html/semantics/interactive-elements/the-details-element/details.html", + // "html/semantics/interactive-elements/the-details-element/toggleEvent.html", // the ninth test requires a streaming HTML parser to pass "html/semantics/scripting-1/the-script-element/script-language-type.html", "html/semantics/scripting-1/the-script-element/script-languages-01.html", // "html/semantics/scripting-1/the-script-element/script-languages-02.html", // our script execution timing is off; see discussion in https://github.com/tmpvar/jsdom/pull/1406