Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shim CSS Mixins in terms of CSS Custom Properties (#3587)
* check for native css variables * keep custom properties, still unpack mixins * make `updateStyles` (modulo @apply) work with native custom properties. make `getComputedStyleValue` work with native custom properties. * modifications * sigh * fix tests in firefox safari and chrome 49 * add back missing styleutil code in x-styling * support all the fallback cases with nested parens * fix rules with property and mixin definitions for native * First draft of @apply shim ```css --foo: { color: red; border: 2px solid black; } @apply --foo; ``` becomes ```css --foo-color: red; --foo-border: 2px solid black; color: var(--foo-color); border: var(--foo-border); ``` * step 3 * Process stylesheets in custom-styles move apply-shim to lib Fix some tests * always add semicolon in flattenMixin * reset order back to master * step 4 * Temporary ordering fixup for native @apply shim. * better step 5 * make custom-style support @apply shim. * * make @apply regex match globally * fix custom-style test's late registrations. * Collect default property values between consumption and application No more global for defaults No need to process keyframe rules * stupid stateful regexes * Handle realiasing mixins (step 6) Fix up shim var syntax `var(--a, --b)` to `var(--a, var(--b))` Disable native variables in Safari 9.1 until https://bugs.webkit.org/show_bug.cgi?id=155782 is fixed * Add more tests for apply shim Test new `@apply --foo` syntax Test aliasing mixins with var Test fixing bad var syntax `var(--a, --b)` -> `var(--a, var(--b))` * fix :root for apply shim * add StyleTransformer smoke test. * Move regexes from style-properties to style-util for easier sharing Clean up dependencies in apply-shim Remove lazyRegister hack * Move check for CSS Custom Properties to settings lib Enabled only if support is detected and `lazyRegister` setting is used. Override with `Polymer = {useNativeCSSProperties: true}` before polymer is loaded. * add apply shim to smoke test * actually let uses set useNativeCSSProperties false * SCOPE_SELECTORS needs to work with built selectors for custom-style and elements * No need to decorate styles for apply shim * apply mixins and gather defaults incrementally * Fix @apply consumption to incrementally process rule text When >1 mixin is consumed, correctly use properties produced by last mixin as fallbacks for current mixin LOTS more comments, more descriptive comment names Micro-opts * MORE APPLY SHIM TESTING Actually test apply shim (needs lazyRegister), and test with shadow dom * Make sure @apply without parens works in property shim as expected * Simpler tracking of mixin properties Address naming feedback Use property map in apply map to keep better track of properties to set to 'initial' when mixins are redefined * Support builds of CSS PolymerBuild supports one property, css, which can be 'shady' or 'shadow'. 'shadow' is a "universal" build, which will work in shadydom or shadowdom. 'shady' will only work in shadydom. * patch a few spots that custom property shim needs to know about the build * still need to transform the selectors if a shadow build was the source * support tests with build to choose the right property * make `importHref` avoid re-importing already loaded resources. * One more spot a shady build will break custom property shim :root will be calculated to `hostname > *.hostname` by the build * A few more allowances for the builds * mark elements and custom-styles as built, no globals * use propertyDataFromStyles for :host and :root Fixes #3610 `:host(tag-name)` * make tests pass by hacking `propertyDataFromStyles`, needs refactoring. * Search for properties in :host and :root rules at the same time - Remove caching, does not apply with @media may invalidate - custom-style will forward css-build state to the rules for property lookup * Don't expect shady built styles to be in head Can't be sharded like that :( Fix polyfill shadowdom and style-defaults with matchesSelector on <html> element Fix url test with getPropertyValue when quotes are not present (the string is escaped with '/') * Fixes #3637. Normalizes attached timing between Shady and Shadow DOM under native Custom Elements. * Fixes #3638. Avoid spamming document.head with already loaded link elements when importHref is called repeatedly with the same url. * actually listen for the error event (unclear how to test error without server support) * fix typo * fix lint errors * fix bad merge conflict * Safari 9.1.1 is still busted, drop minor version check for AppleWebKit * only apply statically shimmed styles if the element has cssText (this optimization can be made because elements always have a placeholder comment node to indicate style position). * * slight optimization: cache cssBuild info on element. * avoid decorating elements whenever there is a css build (of any type) * revert dom scoping change and add clarifying comment about why this is needed when there is a non-shady build. * formatting * custom-style: avoid applying shimmed custom properties when native custom properties are in use. * avoid shimming styles under shady dom when there is a shady css build. * custom-style: when native custom properties are in use and no build is available, avoid applying shimmed properties and only update the style to reflect apply shim changes. * avoid work in the presence of a css build. * add test for :host(element-name) * correct custom-style under shadow build when using shady and custom properties. * fix tests to not rely on order in className * Support custom-style with css-build status in HTMLImports polyfill - Copy css-build status to cloned style in main document - Move css-build status out of ast - Instead forward a reference to the style in the ast walker callback * Clean up logic in custom-style _apply More easy to see that no work happens if using a targeted css build with native custom properties * Loop over all property names ever used for a mixin Add test to show that redefining a mixin works as expected * Bail early if rule does not have properties checking for native css custom properties is not needed in the property shim anymore * Comments. * test that invalid @media rules do *not* apply via the custom properties shim. * Use `_-_` as seperator for apply-shim created variables Differentiates apply-shim variables more obviously from user variables #3587 (comment) * Fix custom-style test with new separator * fix a few more tests for built styles * Revert "Fixes #3637. Normalizes attached timing between Shady and Shadow DOM under native Custom Elements." This reverts commit 9d272e0. * [ci skip] PolymerBuild global has been removed
- Loading branch information