Sha256: ab704411545ecdbd500ddb81df211dcb0746b20420738acad7d7a0a3e0726c6f

Contents?: true

Size: 895 Bytes

Versions: 1

Compression:

Stored size: 895 Bytes

Contents

m = Element.prototype.matches or
    Element.prototype.matchesSelector or
    Element.prototype.mozMatchesSelector or
    Element.prototype.msMatchesSelector or
    Element.prototype.oMatchesSelector or
    Element.prototype.webkitMatchesSelector

Quails.matches = (element, selector) ->
  if selector.exclude?
    m.call(element, selector.selector) and not m.call(element, selector.exclude)
  else
    m.call(element, selector)

# get and set data on a given element using "expando properties"
# See: https://developer.mozilla.org/en-US/docs/Glossary/Expando
expando = '_ujsData'

Quails.getData = (element, key) ->
  element[expando]?[key]

Quails.setData = (element, key, value) ->
  element[expando] ?= {}
  element[expando][key] = value

# a wrapper for document.querySelectorAll
# returns an Array
Quails.$ = (selector) ->
  Array.prototype.slice.call(document.querySelectorAll(selector))

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-on-quails-0.1.0 actionview/app/assets/javascripts/rails-ujs/utils/dom.coffee