Skip to content

Commit

Permalink
Add HTMLOrSVGElement interface mixin
Browse files Browse the repository at this point in the history
We already had our version of the mixin in HTMLAndSVGElementShared, so
just rename that to the official name.

Also take care of the change to allow nonce on any element.
  • Loading branch information
TimothyGu authored and domenic committed May 27, 2019
1 parent 8533b57 commit 1c8e963
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 25 deletions.
6 changes: 3 additions & 3 deletions lib/jsdom/living/nodes/HTMLElement-impl.js
Expand Up @@ -4,15 +4,15 @@ const ElementImpl = require("./Element-impl").implementation;
const MouseEvent = require("../generated/MouseEvent");
const ElementCSSInlineStyleImpl = require("./ElementCSSInlineStyle-impl").implementation;
const GlobalEventHandlersImpl = require("./GlobalEventHandlers-impl").implementation;
const HTMLAndSVGElementSharedImpl = require("./HTMLAndSVGElementShared-impl").implementation;
const HTMLOrSVGElementImpl = require("./HTMLOrSVGElement-impl").implementation;
const { firstChildWithLocalName } = require("../helpers/traversal");
const { isDisabled } = require("../helpers/form-controls");
const { fireAnEvent } = require("../helpers/events");

class HTMLElementImpl extends ElementImpl {
constructor(args, privateData) {
super(args, privateData);
this._initHTMLAndSVGElement();
this._initHTMLOrSVGElement();
this._initElementCSSInlineStyle();
this._initGlobalEvents();

Expand Down Expand Up @@ -151,7 +151,7 @@ class HTMLElementImpl extends ElementImpl {

mixin(HTMLElementImpl.prototype, ElementCSSInlineStyleImpl.prototype);
mixin(HTMLElementImpl.prototype, GlobalEventHandlersImpl.prototype);
mixin(HTMLElementImpl.prototype, HTMLAndSVGElementSharedImpl.prototype);
mixin(HTMLElementImpl.prototype, HTMLOrSVGElementImpl.prototype);

module.exports = {
implementation: HTMLElementImpl
Expand Down
11 changes: 4 additions & 7 deletions lib/jsdom/living/nodes/HTMLElement.webidl
Expand Up @@ -7,28 +7,25 @@ interface HTMLElement : Element {
[CEReactions, Reflect] attribute DOMString lang;
[CEReactions] attribute boolean translate;
[CEReactions] attribute DOMString dir;
[SameObject] readonly attribute DOMStringMap dataset;

// user interaction
[CEReactions, Reflect] attribute boolean hidden;
void click();
[CEReactions] attribute long tabIndex;
// We don't support FocusOptions yet
// void focus(optional FocusOptions options);
void focus();
void blur();
[CEReactions, Reflect] attribute DOMString accessKey;
// readonly attribute DOMString accessKeyLabel;
[CEReactions] attribute boolean draggable;
// [CEReactions] attribute boolean spellcheck;
// [CEReactions] attribute DOMString autocapitalize;

// [CEReactions] attribute [TreatNullAs=EmptyString] DOMString innerText;

// ElementInternals attachInternals();
};

HTMLElement includes GlobalEventHandlers;
// HTMLElement includes DocumentAndElementEventHandlers;
HTMLElement includes ElementContentEditable;
// HTMLElement includes HTMLOrSVGElement;
HTMLElement includes HTMLOrSVGElement;

// https://drafts.csswg.org/cssom-view/#extensions-to-the-htmlelement-interface
partial interface HTMLElement {
Expand Down
1 change: 0 additions & 1 deletion lib/jsdom/living/nodes/HTMLLinkElement.webidl
Expand Up @@ -8,7 +8,6 @@ interface HTMLLinkElement : HTMLElement {
// [CEReactions] attribute DOMString as; // (default "")
[SameObject, PutForwards=value] readonly attribute DOMTokenList relList;
[CEReactions, Reflect] attribute DOMString media;
// [CEReactions] attribute DOMString nonce;
// [CEReactions] attribute DOMString integrity;
[CEReactions, Reflect] attribute DOMString hreflang;
[CEReactions, Reflect] attribute DOMString type;
Expand Down
Expand Up @@ -4,8 +4,8 @@ const conversions = require("webidl-conversions");
const focusing = require("../helpers/focusing");
const DOMStringMap = require("../generated/DOMStringMap");

class HTMLAndSVGElementSharedImpl {
_initHTMLAndSVGElement() {
class HTMLOrSVGElementImpl {
_initHTMLOrSVGElement() {
this._tabIndex = 0;
this._dataset = DOMStringMap.createImpl([], { element: this });
}
Expand Down Expand Up @@ -53,4 +53,4 @@ class HTMLAndSVGElementSharedImpl {
}
}

exports.implementation = HTMLAndSVGElementSharedImpl;
exports.implementation = HTMLOrSVGElementImpl;
11 changes: 11 additions & 0 deletions lib/jsdom/living/nodes/HTMLOrSVGElement.webidl
@@ -0,0 +1,11 @@
interface mixin HTMLOrSVGElement {
[SameObject] readonly attribute DOMStringMap dataset;
// TODO: Shouldn't be directly [Reflect]ed
[Reflect] attribute DOMString nonce; // intentionally no [CEReactions]

[CEReactions] attribute long tabIndex;
// We don't support FocusOptions yet
// void focus(optional FocusOptions options);
void focus();
void blur();
};
1 change: 0 additions & 1 deletion lib/jsdom/living/nodes/HTMLScriptElement.webidl
Expand Up @@ -8,7 +8,6 @@ interface HTMLScriptElement : HTMLElement {
[CEReactions, Reflect] attribute boolean defer;
[CEReactions, Reflect] attribute DOMString? crossOrigin;
[CEReactions] attribute DOMString text;
[CEReactions, Reflect] attribute DOMString nonce;
// [CEReactions, Reflect] attribute DOMString integrity;


Expand Down
1 change: 0 additions & 1 deletion lib/jsdom/living/nodes/HTMLStyleElement.webidl
Expand Up @@ -3,7 +3,6 @@
HTMLConstructor]
interface HTMLStyleElement : HTMLElement {
[CEReactions, Reflect] attribute DOMString media;
[CEReactions, Reflect] attribute DOMString nonce;

// also has obsolete members
};
Expand Down
6 changes: 3 additions & 3 deletions lib/jsdom/living/nodes/SVGElement-impl.js
Expand Up @@ -7,12 +7,12 @@ const SVGAnimatedString = require("../generated/SVGAnimatedString");
const ElementImpl = require("./Element-impl").implementation;
const ElementCSSInlineStyleImpl = require("./ElementCSSInlineStyle-impl").implementation;
const GlobalEventHandlersImpl = require("./GlobalEventHandlers-impl").implementation;
const HTMLAndSVGElementSharedImpl = require("./HTMLAndSVGElementShared-impl").implementation;
const HTMLOrSVGElementImpl = require("./HTMLOrSVGElement-impl").implementation;

class SVGElementImpl extends ElementImpl {
constructor(args, privateData) {
super(args, privateData);
this._initHTMLAndSVGElement();
this._initHTMLOrSVGElement();
this._initElementCSSInlineStyle();
this._initGlobalEvents();
}
Expand Down Expand Up @@ -46,6 +46,6 @@ SVGElementImpl.attributeRegistry = new Map();

mixin(SVGElementImpl.prototype, ElementCSSInlineStyleImpl.prototype);
mixin(SVGElementImpl.prototype, GlobalEventHandlersImpl.prototype);
mixin(SVGElementImpl.prototype, HTMLAndSVGElementSharedImpl.prototype);
mixin(SVGElementImpl.prototype, HTMLOrSVGElementImpl.prototype);

exports.implementation = SVGElementImpl;
8 changes: 2 additions & 6 deletions lib/jsdom/living/nodes/SVGElement.webidl
Expand Up @@ -4,15 +4,11 @@ interface SVGElement : Element {
// TODO: implement reflection in webidl2js
[SameObject] readonly attribute SVGAnimatedString className;

[SameObject] readonly attribute DOMStringMap dataset;

readonly attribute SVGSVGElement? ownerSVGElement;
readonly attribute SVGElement? viewportElement;

attribute long tabIndex;
void focus();
void blur();
};

SVGElement includes GlobalEventHandlers;
// SVGElement includes DocumentAndElementEventHandlers;
// SVGElement includes SVGElementInstance;
SVGElement includes HTMLOrSVGElement;

0 comments on commit 1c8e963

Please sign in to comment.