Skip to content

Commit

Permalink
Implement the details, picture and marquee elements
Browse files Browse the repository at this point in the history
The marquee element is mostly a stub, and the actual picture selection logic is not implemented either. But this at least gives them all the right element interface, and for details is a full implementation.
  • Loading branch information
Zirro authored and domenic committed Sep 24, 2017
1 parent 150c83b commit eaa046d
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 0 deletions.
40 changes: 40 additions & 0 deletions 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
};
5 changes: 5 additions & 0 deletions lib/jsdom/living/nodes/HTMLDetailsElement.idl
@@ -0,0 +1,5 @@
[Exposed=Window,
HTMLConstructor]
interface HTMLDetailsElement : HTMLElement {
[CEReactions, Reflect] attribute boolean open;
};
9 changes: 9 additions & 0 deletions 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
};
22 changes: 22 additions & 0 deletions 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();
};
9 changes: 9 additions & 0 deletions 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
};
3 changes: 3 additions & 0 deletions lib/jsdom/living/nodes/HTMLPictureElement.idl
@@ -0,0 +1,3 @@
[Exposed=Window,
HTMLConstructor]
interface HTMLPictureElement : HTMLElement {};
12 changes: 12 additions & 0 deletions lib/jsdom/living/register-elements.js
Expand Up @@ -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"]
Expand Down Expand Up @@ -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: []
Expand Down Expand Up @@ -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"]
Expand Down
6 changes: 6 additions & 0 deletions test/web-platform-tests/index.js
Expand Up @@ -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 <base> 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",
Expand Down Expand Up @@ -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 <a target>
"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
Expand Down

0 comments on commit eaa046d

Please sign in to comment.