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

Unified Diff: Source/devtools/front_end/DOMPresentationUtils.js

Issue 83123002: DevTools: Move DOMNode.appropriateSelectorFor() into DOMPresentationUtil. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 1 month 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 | « Source/devtools/front_end/DOMAgent.js ('k') | Source/devtools/front_end/ElementsPanel.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/DOMPresentationUtils.js
diff --git a/Source/devtools/front_end/DOMPresentationUtils.js b/Source/devtools/front_end/DOMPresentationUtils.js
index 181fcd90dfbdcacc13943426fe3be6e92a5438d3..67f1392eb06d7ce309983879ec2b22ab16c2ab5f 100644
--- a/Source/devtools/front_end/DOMPresentationUtils.js
+++ b/Source/devtools/front_end/DOMPresentationUtils.js
@@ -158,3 +158,30 @@ WebInspector.DOMPresentationUtils.buildImagePreviewContents = function(imageURL,
userCallback(container);
}
}
+
+/**
+ * @param {!WebInspector.DOMNode} node
+ * @param {boolean=} justSelector
+ * @return {string}
+ */
+WebInspector.DOMPresentationUtils.appropriateSelectorFor = function(node, justSelector)
+{
+ var lowerCaseName = node.localName() || node.nodeName().toLowerCase();
+
+ var id = node.getAttribute("id");
+ if (id) {
+ var selector = "#" + id;
+ return (justSelector ? selector : lowerCaseName + selector);
+ }
+
+ var className = node.getAttribute("class");
+ if (className) {
+ var selector = "." + className.trim().replace(/\s+/g, ".");
+ return (justSelector ? selector : lowerCaseName + selector);
+ }
+
+ if (lowerCaseName === "input" && node.getAttribute("type"))
+ return lowerCaseName + "[type=\"" + node.getAttribute("type") + "\"]";
+
+ return lowerCaseName;
+}
« no previous file with comments | « Source/devtools/front_end/DOMAgent.js ('k') | Source/devtools/front_end/ElementsPanel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698