Created
April 9, 2011 01:59
-
-
Save danbeam/911037 to your computer and use it in GitHub Desktop.
Feature test for text-overflow: ellipsis; with YUI3
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
YUI().use('gallery-ellipsis', function (Y) { | |
// must wait to append hidden node | |
Y.on('domready', function () { | |
// create a hidden node and try to style it | |
var cloned, | |
hidden = Y.Node.create('<div style="visibility:hidden;position:absolute;white-space:nowrap;overflow:hidden;"></div>'), | |
rules = ['textOverflow', 'OTextOverflow']; | |
Y.each(rules, function (rule) { | |
hidden.setStyle(rule, 'ellipsis'); | |
}); | |
// add to DOM | |
Y.one('body').appendChild(hidden); | |
// deep clone the node (include attributes) | |
cloned = hidden.cloneNode(true); | |
Y.some(rules, function (rule) { | |
if ('ellipsis' === cloned.getStyle(rule)) { | |
Y.DOM.ellipsis.nativeRule = rule; | |
Y.DOM.ellipsis.nativeSupport = true; | |
return true; | |
} | |
}); | |
// clean-up | |
hidden.remove(); | |
hidden = cloned = null; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment