Commit 24201e7
feat: update wikimedia/less.php from 4.x to 5.x (#4225)
* chore: Prep for upgrade to Less.php 5
The only two major changes in Less.php 5.0 are:
* Remove `import_callback`.
* Change default math from "always" (strictMath: false) to "parens-division".
The import_callback option was deprecated in 4.x, because it exposed a number
of internal classes, all of which had to be used in order to work, including
carefully obtaining and then returning the `pathAndUri[1]` value.
Upstream change: https://gerrit.wikimedia.org/r/1010962
Docs: https://github.com/wikimedia/less.php/blob/v4.4.1/lib/Less/Parser.php#L592-L617
== import_callback ==
The SetImportDirs() method has been available for a long time already,
and is instead given a simple string path (already resolved), and must
return `null|array{0:?string,1:?string}`. Thus if it doesn't want to
override, it can simply not return (implied null), which is equiv
to `[null,null]` and the second URI value is optional, defaulting to
the default.
== math ==
In Less.js 1.x-3.x the default was `strictMath: false`, which evaluates math eagerly,
instead of only "strictly" between parenthesis. This had the downside of
interpreting "/" slashes in newer CSS syntax as Less division, instead of as
separator between values in those CSS features (aspect-ratio, border-radius, font).
As such, Less.js 4.x and Less.php 5.x, rename "strictMath" to "math", with a new
third option "parens-division" as the default alongside "always"
(aka `strictMath: false`) and "parens" (aka `strictMath: true`). This new
option still eagerly evaluated math in most cases (plus, minus, multiply) but
no longer for division. I don't know if or when Flarum wants to adopt this new
default, but for now, to minimise disruption and unblock the Less.php upgrade,
I suggest simply setting `strictMath: false` explicitly so that Less.php 5
behaves the same as before.
This decouples the trivial Less.php upgrade from the (potentially non-trivial,
or unwanted) math migration.
Ref https://phabricator.wikimedia.org/T366445.
Ref https://github.com/wikimedia/less.php/blob/master/CHANGES.md.
== Custom properties ==
In Less.js 3.5, custom properties were natively supported which
included a change to no longer evaluate math expressions there.
This is separate from the general case, which remains eagerly
evaluated under the `strictMath:false` setting.
You can still perform calclations in custom properties with `calc()`.
Ref less/less.js#3317
* feat: update wikimedia/less.php from 4.x to 5.x
* fix: workaround the removed import_callback so that replaced less is still processed
* chore: styleci
---------
Co-authored-by: IanM <[email protected]>1 parent 813bff7 commit 24201e7
File tree
5 files changed
+47
-41
lines changed- framework/core
- src/Frontend/Compiler
- tests
- fixtures/less
- integration/extenders
5 files changed
+47
-41
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
175 | | - | |
| 175 | + | |
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | 14 | | |
16 | | - | |
17 | 15 | | |
18 | | - | |
19 | 16 | | |
20 | 17 | | |
21 | 18 | | |
| |||
83 | 80 | | |
84 | 81 | | |
85 | 82 | | |
| 83 | + | |
86 | 84 | | |
87 | 85 | | |
88 | | - | |
89 | 86 | | |
90 | 87 | | |
91 | 88 | | |
| |||
94 | 91 | | |
95 | 92 | | |
96 | 93 | | |
97 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
98 | 103 | | |
99 | 104 | | |
100 | 105 | | |
| |||
137 | 142 | | |
138 | 143 | | |
139 | 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 | + | |
140 | 174 | | |
141 | 175 | | |
142 | 176 | | |
| |||
155 | 189 | | |
156 | 190 | | |
157 | 191 | | |
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 | 192 | | |
191 | 193 | | |
192 | 194 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
| |||
119 | 123 | | |
120 | 124 | | |
121 | 125 | | |
122 | | - | |
| 126 | + | |
123 | 127 | | |
124 | 128 | | |
125 | 129 | | |
| |||
0 commit comments