Observe attributes for #637 #641

Closed
wants to merge 9 commits into
from

Conversation

Projects
None yet
1 participant
@justinbmeyer
Contributor

justinbmeyer commented Jan 4, 2014

Pertaining to #637, this pull request lets you listen to when HTML attributes change. For example:

var div = $("<div>")

div.bind("attributes", function(ev){
  ev.attributeName //-> "foo"
  ev.oldValue //-> null
  ev.type //-> "attributes"
})

div.attr("foo","bar")

It integrates directly with jQuery and Zepto's attr,and removeAttr, Mootool's set, and Dojo's dojo.setAttr and dojo.removeAttr.

It's tested against live-binding so that changes to attrValue in the following will fire attributes events:

<div foo="{{attrValue}"/>

Attributes with jQuery works via MutationObserver in browsers that support it. No other library uses MutationObservers. All browsers should work, but I have not tested IE.

@justinbmeyer

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer Jan 22, 2014

Contributor

merged this into minor myself ...

Contributor

justinbmeyer commented Jan 22, 2014

merged this into minor myself ...

@justinbmeyer justinbmeyer deleted the observe-attributes branch May 2, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment