Skip to content

Commit

Permalink
0.1.2, rewrote CSS path-building code; now much cooler
Browse files Browse the repository at this point in the history
  • Loading branch information
Joss Crowcroft committed Mar 28, 2011
1 parent d4d09cd commit 13b3e21
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
Simple JavaScript DOM Inspector v0.1.2
======================================

Highlights hovered elements with a 2px red outline, and then logs the element's full
CSS selector path when clicked. It could also display the selected element's XPath,
or do pretty much anything with it in the callback function.
Highlights hovered elements with a 2px red outline, and then logs the element's full CSS selector path when clicked. It could also display the selected element's XPath, or do pretty much anything with it in the callback function.

The CSS selector path-building code tries to be as specific as possible, but can also
build a more optimised CSS selector, stopping at the first parent with a specific ID.
The CSS selector path-building code tries to be as specific as possible, but can also build a more optimised CSS selector, stopping at the first parent with a specific ID.

It also checks to see whether any part of the CSS path matches multiple elements, or if
any element has no ID or CSS class, and adds specific "nth-child" pseudo-selectors
where needed for full CSS paths.
Optionally, it also checks to see whether any part of the CSS path matches multiple elements, or if any element has no ID or CSS class, and adds specific "nth-child" pseudo-selectors where needed for full CSS paths.

* Example optimised CSS path: `#content .left p img`
* Example full CSS path: `html body #main #content .left p img`
Expand All @@ -20,8 +15,7 @@ Hit escape key to cancel the inspector.

NB: XPath code removed as it didn't really work very well, need to write from scratch.

Started putting in IE support, but won't work in IE just yet, check back next week
for that (so far, tested in FF4, Chrome, Safari, Opera 11.)
Started putting in IE support, but won't work in IE just yet, check back next week for that (so far, tested in FF4, Chrome, Safari, Opera 11.)

No warranty; probably won't break the internet. Improvements and linkbacks welcome!

Expand Down

0 comments on commit 13b3e21

Please sign in to comment.