From b163f3288870bb716c5d2ba2c7f8f7e28ff21952 Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Tue, 14 Feb 2017 23:06:45 -0800 Subject: [PATCH] ShadyCSS is back --- .eslintrc.json | 3 +-- src/lib/flush.html | 4 ++-- test/unit/custom-style.html | 10 +++++----- test/unit/styling-cross-scope-apply.html | 18 +++++++++--------- test/unit/styling-cross-scope-var.html | 12 ++++++------ 5 files changed, 23 insertions(+), 24 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 41fb9e9a..12b7b508 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -17,8 +17,7 @@ "HTMLImports": true, "Polymer": true, "ShadyDOM": true, - "ScopingShim": true, - "ApplyShim": true, + "ShadyCSS": true, "goog": true } } diff --git a/src/lib/flush.html b/src/lib/flush.html index 51cbc4e7..e7a9df08 100644 --- a/src/lib/flush.html +++ b/src/lib/flush.html @@ -35,8 +35,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN let shadyDOM, debouncers; do { shadyDOM = window.ShadyDOM && ShadyDOM.flush(); - if (window.ScopingShim) { - ScopingShim.flush(); + if (window.ShadyCSS && window.ShadyCSS.ScopingShim) { + window.ShadyCSS.ScopingShim.flush(); } debouncers = flushDebouncers(); } while (shadyDOM || debouncers); diff --git a/test/unit/custom-style.html b/test/unit/custom-style.html index 32be7b6f..376e42a6 100644 --- a/test/unit/custom-style.html +++ b/test/unit/custom-style.html @@ -313,19 +313,19 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN test('custom properties registered as defaults', function() { var propsToCheck = ['--italic']; - if (!window.ScopingShim || ScopingShim.nativeCss || stylesBuilt) { - var sep = ApplyShim._separator; + if (!window.ShadyCSS || ShadyCSS.nativeCss || stylesBuilt) { + var sep = window.ShadyCSS.ApplyShim._separator; propsToCheck.push('--bag' + sep + 'margin', '--bag' + sep + 'border'); } else { propsToCheck.push('--bag'); } - if (!window.ScopingShim || ScopingShim.nativeCss) { + if (!window.ShadyCSS || ShadyCSS.nativeCss) { var cs = getComputedStyle(document.documentElement); propsToCheck.forEach(function(p) { assert.ok(cs.getPropertyValue(p)); }); } else { - var props = ScopingShim._documentOwner.__styleInfo.styleProperties; + var props = ShadyCSS.ScopingShim._documentOwner.__styleInfo.styleProperties; propsToCheck.forEach(function(p) { assert.property(props, p); }); @@ -354,7 +354,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN }); test('imported custom-styles apply', function() { - if (stylesBuilt && window.ScopingShim && !ScopingShim.nativeCss) { + if (stylesBuilt && window.ShadyCSS && !ShadyCSS.nativeCss) { // css build will test this by using vulcanize. // this inlines the custom-style after the consumption point, and changes the timing for custom property shim // Force an update style for this weird corner case in the tests diff --git a/test/unit/styling-cross-scope-apply.html b/test/unit/styling-cross-scope-apply.html index 9aac26e3..dae32fd2 100644 --- a/test/unit/styling-cross-scope-apply.html +++ b/test/unit/styling-cross-scope-apply.html @@ -462,21 +462,21 @@ suite('scoped-styling-apply', function() { }); test('variable mixins calculated correctly and inherit', function() { - if (!window.ScopingShim || ScopingShim.nativeCss) { + if (!window.ShadyCSS || ShadyCSS.nativeCss) { this.skip(); } var suffix = ''; if (stylesBuilt) { - suffix = ApplyShim._separator + 'border'; + suffix = window.ShadyCSS.ApplyShim._separator + 'border'; } var e = styled; - var info = ScopingShim._styleInfoForNode(e); + var info = ShadyCSS.ScopingShim._styleInfoForNode(e); assert.property(info.styleProperties, '--mixin1' + suffix); assert.property(info.styleProperties, '--mixin2' + suffix); assert.property(info.styleProperties, '--mixin3' + suffix); assert.property(info.styleProperties, '--mixin4' + suffix); e = styled.$.child; - info = ScopingShim._styleInfoForNode(e); + info = ShadyCSS.ScopingShim._styleInfoForNode(e); assert.property(info.styleProperties, '--mixin1' + suffix); assert.property(info.styleProperties, '--mixin2' + suffix); assert.property(info.styleProperties, '--mixin3' + suffix); @@ -498,13 +498,13 @@ suite('scoped-styling-apply', function() { var url = 'http://www.google.com/icon.png'; var e = styled.$.child; var actual, unescaped; - if (window.ScopingShim && ScopingShim.nativeCssApply) { + if (window.ShadyCSS && ShadyCSS.nativeCssApply) { actual = getComputedStyle(e).getPropertyValue('--mixin2'); // if strings aren't used in the url, getPropertyValue will escape the string, which breaks assert.include unescaped = actual.replace(/\\/g, ''); assert.include(unescaped, url); - } else if (!window.ScopingShim || ScopingShim.nativeCss) { - var propertyName = '--mixin2' + ApplyShim._separator + 'background'; + } else if (!window.ShadyCSS || ShadyCSS.nativeCss) { + var propertyName = '--mixin2' + window.ShadyCSS.ApplyShim._separator + 'background'; actual = getComputedStyle(e).getPropertyValue(propertyName); // if strings aren't used in the url, getPropertyValue will escape the string, which breaks assert.include unescaped = actual.replace(/\\/g, ''); @@ -512,9 +512,9 @@ suite('scoped-styling-apply', function() { } else { var propName = '--mixin2'; if (stylesBuilt) { - propName = propName + ApplyShim._separator + 'background'; + propName = propName + window.ShadyCSS.ApplyShim._separator + 'background'; } - var info = ScopingShim._styleInfoForNode(e); + var info = ShadyCSS.ScopingShim._styleInfoForNode(e); assert.include(info.styleProperties[propName], url); assert.include(info.customStyle.textContent, url); } diff --git a/test/unit/styling-cross-scope-var.html b/test/unit/styling-cross-scope-var.html index 056b134f..350b50ef 100644 --- a/test/unit/styling-cross-scope-var.html +++ b/test/unit/styling-cross-scope-var.html @@ -838,7 +838,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN }); test('invalid variables not parsed', function() { - if (!window.ScopingShim || ScopingShim.nativeCss) { + if (!window.ShadyCSS || ShadyCSS.nativeCss) { this.skip(); } assert.notProperty(styled.__styleInfo.styleProperties, 'x--invalid'); @@ -893,13 +893,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN styled.$.child.classList.add('special'); var l = document.querySelectorAll('style').length; styled.updateStyles(); - if (styled.shadyRoot && window.ScopingShim && !ScopingShim.nativeCss) { + if (styled.shadyRoot && window.ShadyCSS && !ShadyCSS.nativeCss) { assert.equal(document.querySelectorAll('style').length, l+4); } assertComputed(styled.$.child.$.me, '12px'); styled.$.child.classList.remove('special'); styled.updateStyles(); - if (styled.shadyRoot && window.ScopingShim && !ScopingShim.nativeCss) { + if (styled.shadyRoot && window.ShadyCSS && !ShadyCSS.nativeCss) { assert.equal(document.querySelectorAll('style').length, l); } assertComputed(styled.$.child.$.me, '2px'); @@ -1024,7 +1024,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN // late bound property does *not* resolve using inherited value var o3 = styled.$.overrides3; - if (window.ScopingShim && !ScopingShim.nativeCss) { + if (window.ShadyCSS && !ShadyCSS.nativeCss) { assert.equal(o3.__styleInfo.styleProperties['--late'], '', 'property should not be late bound'); } assertStylePropertyValue(o3.$.late, '--fillin', '16px'); @@ -1079,12 +1079,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN }); test('producing a var that consumes results in static and not dynamic stylesheet', function() { - if (!window.ScopingShim || ScopingShim.nativeCss) { + if (!window.ShadyCSS || ShadyCSS.nativeCss) { this.skip(); } var d = document.createElement('x-var-produce-via-consume'); document.body.appendChild(d); - var styleRoot = (!window.ScopingShim || ScopingShim.nativeShadow) ? d.shadowRoot : document.head; + var styleRoot = (!window.ShadyCSS || ShadyCSS.nativeShadow) ? d.shadowRoot : document.head; var staticStyle = styleRoot.querySelector('style[scope=x-var-produce-via-consume]'); assert.ok(staticStyle); assert.match(staticStyle.textContent, /display/, 'static style does not contain style content');