Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[Shadow DOM] Make createDOM() function used in testing Shadow DOM mor…
…e flexible. https://bugs.webkit.org/show_bug.cgi?id=79745 Reviewed by Dimitri Glazkov. Replaces createDom and createShadow function defined in LayoutTests/fast/dom/shadow/create-dom.js with more flexible one. Now we can represent a shadow host which has both light children and ShadowRoots in one expression. * fast/dom/shadow/access-key.html: * fast/dom/shadow/get-element-by-id-in-shadow-root.html: * fast/dom/shadow/resources/create-dom.js: (createShadowRoot): (createDOM): * fast/dom/shadow/shadow-boundary-events.html: Canonical link: https://commits.webkit.org/96948@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@109191 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
5 changed files
with
72 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,28 @@ | ||
// This function can take optional child elements as arguments[2:]. | ||
function createShadow(tagName, attributes) | ||
function createShadowRoot() | ||
{ | ||
var element = document.createElement(tagName); | ||
for (var name in attributes) | ||
element.setAttribute(name, attributes[name]); | ||
var shadow = internals.ensureShadowRoot(element); | ||
var childElements = Array.prototype.slice.call(arguments, 2); | ||
for (var i = 0; i < childElements.length; ++i) | ||
shadow.appendChild(childElements[i]); | ||
return element; | ||
return {'isShadowRoot': true, | ||
'children': Array.prototype.slice.call(arguments)}; | ||
} | ||
|
||
// This function can take optional child elements as arguments[2:]. | ||
function createDom(tagName, attributes) | ||
// This function can take optional child elements, which might be a result of createShadowRoot(), as arguments[2:]. | ||
function createDOM(tagName, attributes) | ||
{ | ||
var element = document.createElement(tagName); | ||
for (var name in attributes) | ||
element.setAttribute(name, attributes[name]); | ||
var childElements = Array.prototype.slice.call(arguments, 2); | ||
for (var i = 0; i < childElements.length; ++i) | ||
element.appendChild(childElements[i]); | ||
for (var i = 0; i < childElements.length; ++i) { | ||
var child = childElements[i]; | ||
if (child.isShadowRoot) { | ||
var shadowRoot; | ||
if (window.WebKitShadowRoot) | ||
shadowRoot = new WebKitShadowRoot(element); | ||
else | ||
shadowRoot = new internals.ensureShadowRoot(element); | ||
for (var j = 0; j < child.children.length; ++j) | ||
shadowRoot.appendChild(child.children[j]); | ||
} else | ||
element.appendChild(child); | ||
} | ||
return element; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters