Created
September 29, 2016 16:36
-
-
Save mcmullengreg/0b0d869c407d1f8cd6d528f4ae786054 to your computer and use it in GitHub Desktop.
This file contains hidden or 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() { | |
var isSet = function(val) { | |
return val !== null && val !== ''; | |
}; | |
var el = {{element}}; | |
var val = ( isSet(el.getAttribute('data-label')) ? el.getAttribute('data-label') : el.text ); | |
while (el && el !== document.body && !isSet(val)) { | |
el = el.parentElement; | |
val = el.getAttribute('data-label'); | |
} | |
return isSet(val) ? val : 'not set'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment