Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Unified Diff: third_party/WebKit/LayoutTests/shadow-dom/resources/shadow-dom.js

Issue 2036933002: Do not use a non-standard label attribute in shadow-dom.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/shadow-dom/event-path-related-target-scoped.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/shadow-dom/resources/shadow-dom.js
diff --git a/third_party/WebKit/LayoutTests/shadow-dom/resources/shadow-dom.js b/third_party/WebKit/LayoutTests/shadow-dom/resources/shadow-dom.js
index 7b4841fb571d55c4bb83db470d6140107bb12278..488283fcb35c6f79cab84a9c447d54cc78985d1d 100644
--- a/third_party/WebKit/LayoutTests/shadow-dom/resources/shadow-dom.js
+++ b/third_party/WebKit/LayoutTests/shadow-dom/resources/shadow-dom.js
@@ -67,27 +67,27 @@ function getNodeInComposedTree(path)
function createTestTree(node) {
- let labels = {};
+ let ids = {};
function attachShadowFromTemplate(template) {
let parent = template.parentNode;
parent.removeChild(template);
let shadowRoot = parent.attachShadow({mode: template.getAttribute('data-mode')});
- let label = template.getAttribute('label');
- if (label) {
- shadowRoot.id = label;
- labels[label] = shadowRoot;
+ let id = template.id;
+ if (id) {
+ shadowRoot.id = id;
+ ids[id] = shadowRoot;
}
shadowRoot.appendChild(document.importNode(template.content, true));
return shadowRoot;
}
function walk(root) {
- if (root.getAttribute && root.getAttribute('label')) {
- labels[root.getAttribute('label')] = root;
+ if (root.id) {
+ ids[root.id] = root;
}
- for (let e of Array.from(root.querySelectorAll('[label]'))) {
- labels[e.getAttribute('label')] = e;
+ for (let e of Array.from(root.querySelectorAll('[id]'))) {
+ ids[e.id] = e;
}
for (let e of Array.from(root.querySelectorAll('template'))) {
walk(attachShadowFromTemplate(e));
@@ -95,15 +95,12 @@ function createTestTree(node) {
}
walk(node.cloneNode(true));
- return labels;
+ return ids;
}
function dispatchEventWithLog(nodes, target, event) {
function labelFor(e) {
- if (e.getAttribute && e.getAttribute('label')) {
- return e.getAttribute('label');
- }
return e.id || e.tagName;
}
@@ -114,12 +111,12 @@ function dispatchEventWithLog(nodes, target, event) {
for (let node = startingNode; node; node = node.parentNode) {
if (attachedNodes.indexOf(node) >= 0)
continue;
- let label = labelFor(node);
- if (!label)
+ let id = node.id;
+ if (!id)
continue;
attachedNodes.push(node);
node.addEventListener(event.type, (e) => {
- log.push([label,
+ log.push([id,
event.relatedTarget ? labelFor(event.relatedTarget) : null,
event.composedPath().map((n) => {
return labelFor(n);
« no previous file with comments | « third_party/WebKit/LayoutTests/shadow-dom/event-path-related-target-scoped.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698