Skip to content

Commit

Permalink
Implement the translate attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Zirro authored and domenic committed May 12, 2019
1 parent 1a70afa commit 5146cb2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
24 changes: 24 additions & 0 deletions lib/jsdom/living/nodes/HTMLElement-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,30 @@ class HTMLElementImpl extends ElementImpl {
}
}

// https://html.spec.whatwg.org/multipage/dom.html#the-translate-attribute
get translate() {
const translateAttr = this.getAttributeNS(null, "translate");

if (translateAttr === "yes" || translateAttr === "") {
return true;
} else if (translateAttr === "no") {
return false;
}

if (this === this.ownerDocument.documentElement) {
return true;
}

return this.parentElement && this.parentElement.translate;
}
set translate(value) {
if (value === true) {
this.setAttributeNS(null, "translate", "yes");
} else {
this.setAttributeNS(null, "translate", "no");
}
}

click() {
// https://html.spec.whatwg.org/multipage/interaction.html#dom-click
// https://html.spec.whatwg.org/multipage/webappapis.html#fire-a-synthetic-mouse-event
Expand Down
2 changes: 1 addition & 1 deletion lib/jsdom/living/nodes/HTMLElement.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ interface HTMLElement : Element {
// metadata attributes
[CEReactions, Reflect] attribute DOMString title;
[CEReactions, Reflect] attribute DOMString lang;
// [CEReactions] attribute boolean translate;
[CEReactions] attribute boolean translate;
[CEReactions] attribute DOMString dir;
[SameObject] readonly attribute DOMStringMap dataset;

Expand Down
6 changes: 0 additions & 6 deletions test/web-platform-tests/to-run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,6 @@ the-lang-attribute-007.html: [fail, Unknown]
the-lang-attribute-008.html: [fail, Unknown]
the-lang-attribute-009.html: [fail, Unknown]
the-lang-attribute-010.html: [fail, Unknown]
the-translate-attribute-007.html: [fail, Unknown]
the-translate-attribute-008.html: [fail, Unknown]
the-translate-attribute-009.html: [fail, Unknown]
the-translate-attribute-010.html: [fail, Unknown]
the-translate-attribute-011.html: [fail, Unknown]
the-translate-attribute-012.html: [fail, Unknown]

---

Expand Down

0 comments on commit 5146cb2

Please sign in to comment.