Repository navigation
Commit 6c0acef
committed
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 removed1 parent adef722 commit 6c0acef
24 files changed
Lines changed: 1254 additions & 221 deletions
File tree
- src
- lib
- standard
- test
- smoke
- style-transformer
- unit
- dynamic-imports
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
178 | | - | |
| 178 | + | |
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
| |||
0 commit comments