Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Sizzle selector builder
CoffeeScript JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
dist
node_modules/grunt-coffee
src
README.md
grunt.js

README.md

unsizzle

Sizzle selector builder.

Given a target-based event, unsizzle will do it's best to build a sizzle selector string back to the given target. The plugin walks the DOM from the target through every parent until it finds an ID or exhausts the list of parents.

How to use it

Using unsizzle to remember what was clicked

clickHistory = []

$('#element').on 'click' (evt) ->
    clickHistory.push unsizzle evt

showHistory = ->
    for selector in clickHistory
        $(selector).effect 'highlight'

Using unsizzle on nodes

x = document.getElementById 'element'
selector = unsizzle x

API

Core

unsizzle(objOrNode)

Returns a selector from either a node or object

unsizzle.node(node)

Returns a selector from a node.

unsizzle.event(eventObj)

Returns a selector from an event object.

unsizzle.selector(node)

Returns a unique selector for an individual node by looking at the node's siblings.

unsizzle.join(tag, id, classList, position)

Concatenates the given arguments into a usable selector.

Utilities

unsizzle.hasSiblings(node)
unsizzle.isEvent(obj)
unsizzle.isNode(obj)

Contributing

Build with grunt!

Write some tests!

Something went wrong with that request. Please try again.