Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions css-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,14 @@ var trim = require('trim')
, id = elm.getAttribute('id')

if (id) {
list.unshift(tag + '#' + trim(id))
return list
list.unshift( tag + '#' + trim(id) )
var isUnique = rootNode.querySelectorAll(list.join('>')).length === 1
if (isUnique){
return list
} else {
list.shift()
selector.push('#' + trim(id))
}
}

if (className)
Expand All @@ -57,4 +63,4 @@ var trim = require('trim')

module.exports = function (elm, rootNode) {
return path(elm, rootNode, []).join(' > ')
}
}