Created
August 7, 2013 19:33
-
-
Save wanderview/6177669 to your computer and use it in GitHub Desktop.
onClickHandler() proposal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function onClickHandler(evt) { | |
var target = evt.target; | |
var dataset = target.dataset || {}; | |
var parentDataset = target.parentNode ? | |
(target.parentNode.dataset || {}) : {}; | |
var uuid = dataset.uuid; | |
var node = target; | |
if (!uuid) { | |
uuid = parentDataset.uuid; | |
node = target.parentNode; | |
} | |
if (uuid) { | |
callbacks.forEach(function(callback) { | |
callback(uuid, node); | |
}); | |
} | |
evt.preventDefault(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment