Skip to content

Commit c1ebf1e

Browse files
authored
Merge pull request Polymer#3826 from Polymer/build-inherit
Property Shim needs to handle build output from apply shim
2 parents 80fc971 + d726a51 commit c1ebf1e

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

src/lib/style-properties.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,11 @@
164164
// fallback may be --a or var(--a) or literal
165165
propertyValue = self.valueForProperty(props[fallback] || fallback, props) ||
166166
fallback;
167+
} else if (propertyValue === 'apply-shim-inherit') {
168+
// CSS build will replace `inherit` with `apply-shim-inherit`
169+
// for use with native css variables.
170+
// Since we have full control, we can use `inherit` directly.
171+
propertyValue = 'inherit';
167172
}
168173
return prefix + (propertyValue || '') + suffix;
169174
};

test/unit/styling-cross-scope-apply.html

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,37 @@
656656
</script>
657657
</dom-module>
658658

659+
<style is="custom-style">
660+
:root {
661+
/*--build: {
662+
color: inherit;
663+
}*/
664+
--build_-_color: apply-shim-inherit;
665+
}
666+
x-built {
667+
color: rgb(123, 123, 123);
668+
}
669+
</style>
670+
<dom-module id="x-built">
671+
<template>
672+
<style>
673+
#child {
674+
color: rgb(0, 0, 0);
675+
/* @apply --build */
676+
color: var(--build_-_color, rgb(0, 0, 0));
677+
}
678+
</style>
679+
<div id="child"></div>
680+
</template>
681+
<script>
682+
HTMLImports.whenReady(function() {
683+
Polymer({
684+
is: 'x-built'
685+
})
686+
});
687+
</script>
688+
</dom-module>
689+
659690
<script>
660691
suite('scoped-styling-apply', function() {
661692
function assertComputed(element, value, property) {
@@ -851,7 +882,9 @@
851882
assertComputed(parent2.$.child, '0px');
852883
assertComputed(parent3.$.child, 'rgb(255, 0, 0)', 'color');
853884
assertComputed(parent3.$.child, '0px');
854-
if (Polymer.Settings.useNativeCSSProperties && Polymer.Settings.useNativeShadow) {
885+
if (!stylesBuilt && Polymer.Settings.useNativeCSSProperties && Polymer.Settings.useNativeShadow) {
886+
// disable test if css build ran
887+
// the styles will have been preprocessed with all properties for the mixin
855888
var parent1Text = getStyleText(parent1.$.child);
856889
var parent2Text = getStyleText(parent2.$.child);
857890
var parent3Text = getStyleText(parent3.$.child);
@@ -907,6 +940,16 @@
907940
assertComputed(e.$.child, 'rgb(0, 0, 0)', 'color');
908941
assertComputed(e.$.child, '0px');
909942
});
943+
944+
test('styleProperties can handle builds processed with applyShim w.r.t "inherit"', function() {
945+
if (navigator.userAgent.match(/Trident/)) {
946+
this.skip();
947+
}
948+
var e = document.createElement('x-built');
949+
document.body.appendChild(e);
950+
CustomElements.takeRecords();
951+
assertComputed(e.$.child, 'rgb(123, 123, 123)', 'color');
952+
});
910953
});
911954

912955
</script>

0 commit comments

Comments
 (0)