mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
ShadyCSS is back
This commit is contained in:
parent
2c9954f950
commit
b163f32888
@ -17,8 +17,7 @@
|
||||
"HTMLImports": true,
|
||||
"Polymer": true,
|
||||
"ShadyDOM": true,
|
||||
"ScopingShim": true,
|
||||
"ApplyShim": true,
|
||||
"ShadyCSS": true,
|
||||
"goog": true
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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');
|
||||
|
Loading…
Reference in New Issue
Block a user