diff --git a/packages/less/less_tests.js b/packages/less/less_tests.js index 69be1dd4f1..8c7986cecd 100644 --- a/packages/less/less_tests.js +++ b/packages/less/less_tests.js @@ -1,20 +1,23 @@ Tinytest.add("less - presence", function(test) { - // find the .less stylesheet, whose first rule contains "less-tests" - // in the selector - var sheet = _.find(document.styleSheets, function(sh) { - var rules = sh.cssRules || sh.rules; - return /less-tests/.test(rules[0].selectorText); - }); + var div = document.createElement("DIV"); + div.style.height = '0'; + div.style.overflow = 'hidden'; + div.innerHTML = '
'; + document.body.appendChild(div); - test.isTrue(sheet); + var p = div.firstChild; + var leftBorder; + if (p.currentStyle) { // IE + leftBorder = p.currentStyle.borderLeftWidth; + } else { + leftBorder = + window.getComputedStyle(p, null).getPropertyValue('border-left-width'); + } - // `cssRules` is the W3C name, but isn't supported in IE until - // version 9. IE<=8 has `rules`. We prefer `cssRules` as - // it is less likely to have quirks if both are present. - var rules = sheet.cssRules || sheet.rules; + test.equal(leftBorder, "13px"); - test.equal(rules[1].style.borderLeftWidth, "13px"); + div.parentNode.removeChild(div); }); diff --git a/packages/less/less_tests.less b/packages/less/less_tests.less index bddcfb8800..80e7d0fd22 100644 --- a/packages/less/less_tests.less +++ b/packages/less/less_tests.less @@ -4,5 +4,5 @@ @unlucky: 13px; .unlucky-left-border { - border-left-width: @unlucky; + border-left: @unlucky solid white; }