Skip to content

Commit

Permalink
Property Shim needs to handle build output from apply shim
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreedm committed Jul 29, 2016
1 parent 80fc971 commit d726a51
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/lib/style-properties.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@
// fallback may be --a or var(--a) or literal
propertyValue = self.valueForProperty(props[fallback] || fallback, props) ||
fallback;
} else if (propertyValue === 'apply-shim-inherit') {
// CSS build will replace `inherit` with `apply-shim-inherit`
// for use with native css variables.
// Since we have full control, we can use `inherit` directly.
propertyValue = 'inherit';
}
return prefix + (propertyValue || '') + suffix;
};
Expand Down
45 changes: 44 additions & 1 deletion test/unit/styling-cross-scope-apply.html
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,37 @@
</script>
</dom-module>

<style is="custom-style">
:root {
/*--build: {
color: inherit;
}*/
--build_-_color: apply-shim-inherit;
}
x-built {
color: rgb(123, 123, 123);
}
</style>
<dom-module id="x-built">
<template>
<style>
#child {
color: rgb(0, 0, 0);
/* @apply --build */
color: var(--build_-_color, rgb(0, 0, 0));
}
</style>
<div id="child"></div>
</template>
<script>
HTMLImports.whenReady(function() {
Polymer({
is: 'x-built'
})
});
</script>
</dom-module>

<script>
suite('scoped-styling-apply', function() {
function assertComputed(element, value, property) {
Expand Down Expand Up @@ -851,7 +882,9 @@
assertComputed(parent2.$.child, '0px');
assertComputed(parent3.$.child, 'rgb(255, 0, 0)', 'color');
assertComputed(parent3.$.child, '0px');
if (Polymer.Settings.useNativeCSSProperties && Polymer.Settings.useNativeShadow) {
if (!stylesBuilt && Polymer.Settings.useNativeCSSProperties && Polymer.Settings.useNativeShadow) {
// disable test if css build ran
// the styles will have been preprocessed with all properties for the mixin
var parent1Text = getStyleText(parent1.$.child);
var parent2Text = getStyleText(parent2.$.child);
var parent3Text = getStyleText(parent3.$.child);
Expand Down Expand Up @@ -907,6 +940,16 @@
assertComputed(e.$.child, 'rgb(0, 0, 0)', 'color');
assertComputed(e.$.child, '0px');
});

test('styleProperties can handle builds processed with applyShim w.r.t "inherit"', function() {
if (navigator.userAgent.match(/Trident/)) {
this.skip();
}
var e = document.createElement('x-built');
document.body.appendChild(e);
CustomElements.takeRecords();
assertComputed(e.$.child, 'rgb(123, 123, 123)', 'color');
});
});

</script>
Expand Down

0 comments on commit d726a51

Please sign in to comment.