Skip to content

Commit

Permalink
Add document.embeds, plugins, and scripts
Browse files Browse the repository at this point in the history
They were supposed to be added in v9.5.0, but I forgot to un-comment them in the IDL file.

Also fix a small correctness issue with HTMLCollection which helps one of the docuement.images tests pass.

Closes #1660.
  • Loading branch information
domenic committed Dec 19, 2016
1 parent 5261738 commit 30f7906
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
5 changes: 5 additions & 0 deletions lib/jsdom/living/html-collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ function resetHTMLCollectionTo(collection, impls) {
return;
}

// Don't override existing named ones
if (keys.includes(value)) {
return;
}

if (conflictKeys.has(value)) {
collection[privates].conflictElements[value] = wrapper;
} else {
Expand Down
6 changes: 3 additions & 3 deletions lib/jsdom/living/nodes/Document.idl
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ partial /*sealed*/ interface Document {
attribute HTMLElement? body;
readonly attribute HTMLHeadElement? head;
[SameObject] readonly attribute HTMLCollection images;
// [SameObject] readonly attribute HTMLCollection embeds;
// [SameObject] readonly attribute HTMLCollection plugins;
[SameObject] readonly attribute HTMLCollection embeds;
[SameObject] readonly attribute HTMLCollection plugins;
[SameObject] readonly attribute HTMLCollection links;
[SameObject] readonly attribute HTMLCollection forms;
// [SameObject] readonly attribute HTMLCollection scripts;
[SameObject] readonly attribute HTMLCollection scripts;
NodeList getElementsByName(DOMString elementName);
readonly attribute HTMLScriptElement? currentScript;

Expand Down
13 changes: 0 additions & 13 deletions test/level2/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -19475,19 +19475,6 @@ exports.tests = {
);
},

htmlcollection_index_access_prefers_id_over_name: function(test) {
jsdom.env(
'<form><input name="test"><input id="test"><input id="test2"><input name="test2"></form>', function (err, window) {
var form = window.document.getElementsByTagName('form')[0];
var elem = form.elements.test;
test.strictEqual(elem && elem.getAttribute('id'), 'test');
elem = form.elements.test2;
test.strictEqual(elem && elem.getAttribute('id'), 'test2');
test.done();
}
);
},

parsing_with_bad_html_tag: function(test) {
var doc;
test.doesNotThrow(function () {
Expand Down
8 changes: 8 additions & 0 deletions test/web-platform-tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ describe("Web Platform Tests", () => {
"html/browsers/offline/browser-state/navigator_online_online.html",
// "html/browsers/windows/browsing-context-first-created.xhtml", // jsdom will try to feed <![CDATA[ to the script parser, causing errors
"html/dom/documents/dom-tree-accessors/Document.body.html",
"html/dom/documents/dom-tree-accessors/Document.getElementsByClassName-null-undef.html",
"html/dom/documents/dom-tree-accessors/Element.getElementsByClassName-null-undef.html",
"html/dom/documents/dom-tree-accessors/document.embeds-document.plugins-01.html",
// "html/dom/documents/dom-tree-accessors/document.forms.html", // something wonky with HTMLCollection
"html/dom/documents/dom-tree-accessors/document.getElementsByClassName-same.html",
"html/dom/documents/dom-tree-accessors/document.head-01.html",
"html/dom/documents/dom-tree-accessors/document.head-02.html",
"html/dom/documents/dom-tree-accessors/document.images.html",
"html/dom/documents/dom-tree-accessors/document.title-01.html",
"html/dom/documents/dom-tree-accessors/document.title-02.xhtml",
"html/dom/documents/dom-tree-accessors/document.title-03.html",
Expand Down

0 comments on commit 30f7906

Please sign in to comment.