Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Feature test for text-overflow: ellipsis; with YUI3
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'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 = cloned = null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment