sass 3.2.0.alpha.55 → 3.2.0.alpha.56
Sign up to get free protection for your applications and to get access to all the features.
- data/REVISION +1 -1
- data/VERSION +1 -1
- data/lib/sass/selector/sequence.rb +65 -5
- data/test/sass/extend_test.rb +72 -0
- metadata +5 -5
data/REVISION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
ade170e613352cd597338cf29e865d98e8316f9b
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.2.0.alpha.
|
1
|
+
3.2.0.alpha.56
|
@@ -134,10 +134,11 @@ module Sass
|
|
134
134
|
last_current.unshift(current.pop)
|
135
135
|
end
|
136
136
|
befores = Sass::Util.flatten(befores.map do |before|
|
137
|
-
subweave(before, current)
|
137
|
+
next [] unless sub = subweave(before, current)
|
138
|
+
sub.map {|seqs| seqs + last_current}
|
138
139
|
end, 1)
|
139
|
-
return befores if afters.empty?
|
140
140
|
end
|
141
|
+
return befores
|
141
142
|
end
|
142
143
|
|
143
144
|
# This interweaves two lists of selectors,
|
@@ -149,14 +150,14 @@ module Sass
|
|
149
150
|
# `.foo .baz .bar .bang`, `.foo .baz .bar.bang`, `.foo .baz .bang .bar`,
|
150
151
|
# and so on until `.baz .bang .foo .bar`.
|
151
152
|
#
|
152
|
-
# @overload def subweave(seq1, seq2)
|
153
153
|
# @param seq1 [Array<SimpleSequence or String>]
|
154
154
|
# @param seq2 [Array<SimpleSequence or String>]
|
155
155
|
# @return [Array<Array<SimpleSequence or String>>]
|
156
|
-
def subweave(seq1, seq2
|
156
|
+
def subweave(seq1, seq2)
|
157
157
|
return [seq2] if seq1.empty?
|
158
158
|
return [seq1] if seq2.empty?
|
159
159
|
|
160
|
+
return unless init = merge_initial_ops(seq1, seq2)
|
160
161
|
seq1 = group_selectors(seq1)
|
161
162
|
seq2 = group_selectors(seq2)
|
162
163
|
lcs = Sass::Util.lcs(seq2, seq1) do |s1, s2|
|
@@ -166,7 +167,7 @@ module Sass
|
|
166
167
|
next s1 if subweave_superselector?(s2, s1)
|
167
168
|
end
|
168
169
|
|
169
|
-
diff = []
|
170
|
+
diff = [[init]]
|
170
171
|
until lcs.empty?
|
171
172
|
diff << chunks(seq1, seq2) {|s| subweave_superselector?(s.first, lcs.first)} << [lcs.shift]
|
172
173
|
seq1.shift
|
@@ -178,6 +179,50 @@ module Sass
|
|
178
179
|
Sass::Util.paths(diff).map {|p| p.flatten}
|
179
180
|
end
|
180
181
|
|
182
|
+
# Extracts initial selector operators (`"+"`, `">"`, `"~"`, and `"\n"`)
|
183
|
+
# from two sequences and merges them together into a single array of
|
184
|
+
# selector operators.
|
185
|
+
#
|
186
|
+
# @param seq1 [Array<SimpleSequence or String>]
|
187
|
+
# @param seq2 [Array<SimpleSequence or String>]
|
188
|
+
# @return [Array<String>, nil] If there are no operators in the merged
|
189
|
+
# sequence, this will be the empty array. If the operators cannot be
|
190
|
+
# merged, this will be nil.
|
191
|
+
def merge_initial_ops(seq1, seq2)
|
192
|
+
ops1, ops2 = [], []
|
193
|
+
ops1 << seq1.shift while seq1.first.is_a?(String)
|
194
|
+
ops2 << seq2.shift while seq2.first.is_a?(String)
|
195
|
+
|
196
|
+
newline = false
|
197
|
+
newline ||= !!ops1.shift if ops1.first == "\n"
|
198
|
+
newline ||= !!ops2.shift if ops2.first == "\n"
|
199
|
+
|
200
|
+
# If neither sequence is a subsequence of the other, they cannot be
|
201
|
+
# merged successfully
|
202
|
+
lcs = Sass::Util.lcs(ops1, ops2)
|
203
|
+
return unless lcs == ops1 || lcs == ops2
|
204
|
+
return (newline ? ["\n"] : []) + (ops1.size > ops2.size ? ops1 : ops2)
|
205
|
+
end
|
206
|
+
|
207
|
+
# Takes initial subsequences of `seq1` and `seq2` and returns all
|
208
|
+
# orderings of those subsequences. The initial subsequences are determined
|
209
|
+
# by a block.
|
210
|
+
#
|
211
|
+
# Destructively removes the initial subsequences of `seq1` and `seq2`.
|
212
|
+
#
|
213
|
+
# For example, given `(A B C | D E)` and `(1 2 | 3 4 5)` (with `|`
|
214
|
+
# denoting the boundary of the initial subsequence), this would return
|
215
|
+
# `[(A B C 1 2), (1 2 A B C)]`. The sequences would then be `(D E)` and
|
216
|
+
# `(3 4 5)`.
|
217
|
+
#
|
218
|
+
# @param seq1 [Array]
|
219
|
+
# @param seq2 [Array]
|
220
|
+
# @yield [a] Used to determine when to cut off the initial subsequences.
|
221
|
+
# Called repeatedly for each sequence until it returns true.
|
222
|
+
# @yieldparam a [Array] A final subsequence of one input sequence after
|
223
|
+
# cutting off some initial subsequence.
|
224
|
+
# @yieldreturn [Boolean] Whether or not to cut off the initial subsequence
|
225
|
+
# here.
|
181
226
|
def chunks(seq1, seq2)
|
182
227
|
chunk1 = []
|
183
228
|
chunk1 << seq1.shift until yield seq1
|
@@ -189,6 +234,15 @@ module Sass
|
|
189
234
|
[chunk1 + chunk2, chunk2 + chunk1]
|
190
235
|
end
|
191
236
|
|
237
|
+
# Groups a sequence into subsequences. The subsequences are determined by
|
238
|
+
# strings; adjacent non-string elements will be put into separate groups,
|
239
|
+
# but any element adjacent to a string will be grouped with that string.
|
240
|
+
#
|
241
|
+
# For example, `(A B "C" D E "F" G "H" "I" J)` will become `[(A) (B "C" D)
|
242
|
+
# (E "F" G "H" "I" J)]`.
|
243
|
+
#
|
244
|
+
# @param seq [Array]
|
245
|
+
# @return [Array<Array>]
|
192
246
|
def group_selectors(seq)
|
193
247
|
newseq = []
|
194
248
|
tail = seq.dup
|
@@ -202,6 +256,12 @@ module Sass
|
|
202
256
|
return newseq
|
203
257
|
end
|
204
258
|
|
259
|
+
# Given two sequences of simple selectors, returns whether `sseq1` is a
|
260
|
+
# superselector of `sseq2`.
|
261
|
+
#
|
262
|
+
# @param sseq1 [Array<SimpleSelector or String>]
|
263
|
+
# @param sseq2 [Array<SimpleSelector or String>]
|
264
|
+
# @return [Boolean]
|
205
265
|
def subweave_superselector?(sseq1, sseq2)
|
206
266
|
if sseq1.size > 1
|
207
267
|
# More complex selectors are never superselectors of less complex ones
|
data/test/sass/extend_test.rb
CHANGED
@@ -1413,6 +1413,78 @@ $foo: foo;
|
|
1413
1413
|
SCSS
|
1414
1414
|
end
|
1415
1415
|
|
1416
|
+
# Regression Tests
|
1417
|
+
|
1418
|
+
def test_duplicated_selector_with_newlines
|
1419
|
+
assert_equal(<<CSS, render(<<SCSS))
|
1420
|
+
.example-1-1,
|
1421
|
+
.example-1-2,
|
1422
|
+
.my-page-1 .my-module-1-1,
|
1423
|
+
.example-1-3 {
|
1424
|
+
a: b; }
|
1425
|
+
CSS
|
1426
|
+
.example-1-1,
|
1427
|
+
.example-1-2,
|
1428
|
+
.example-1-3 {
|
1429
|
+
a: b;
|
1430
|
+
}
|
1431
|
+
|
1432
|
+
.my-page-1 .my-module-1-1 {@extend .example-1-2}
|
1433
|
+
SCSS
|
1434
|
+
end
|
1435
|
+
|
1436
|
+
def test_nested_selector_with_child_selector_hack_extendee
|
1437
|
+
assert_equal <<CSS, render(<<SCSS)
|
1438
|
+
> .foo, > foo bar {
|
1439
|
+
a: b; }
|
1440
|
+
CSS
|
1441
|
+
> .foo {a: b}
|
1442
|
+
foo bar {@extend .foo}
|
1443
|
+
SCSS
|
1444
|
+
end
|
1445
|
+
|
1446
|
+
def test_nested_selector_with_child_selector_hack_extender
|
1447
|
+
assert_equal <<CSS, render(<<SCSS)
|
1448
|
+
.foo .bar, > .foo foo bar, > foo .foo bar {
|
1449
|
+
a: b; }
|
1450
|
+
CSS
|
1451
|
+
.foo .bar {a: b}
|
1452
|
+
> foo bar {@extend .bar}
|
1453
|
+
SCSS
|
1454
|
+
end
|
1455
|
+
|
1456
|
+
def test_nested_selector_with_child_selector_hack_extender_and_extendee
|
1457
|
+
assert_equal <<CSS, render(<<SCSS)
|
1458
|
+
> .foo, > foo bar {
|
1459
|
+
a: b; }
|
1460
|
+
CSS
|
1461
|
+
> .foo {a: b}
|
1462
|
+
> foo bar {@extend .foo}
|
1463
|
+
SCSS
|
1464
|
+
end
|
1465
|
+
|
1466
|
+
def test_nested_selector_with_child_selector_hack_extender_and_sibling_selector_extendee
|
1467
|
+
assert_equal <<CSS, render(<<SCSS)
|
1468
|
+
~ .foo {
|
1469
|
+
a: b; }
|
1470
|
+
CSS
|
1471
|
+
~ .foo {a: b}
|
1472
|
+
> foo bar {@extend .foo}
|
1473
|
+
SCSS
|
1474
|
+
end
|
1475
|
+
|
1476
|
+
def test_nested_selector_with_child_selector_hack_extender_and_extendee_and_newline
|
1477
|
+
assert_equal <<CSS, render(<<SCSS)
|
1478
|
+
> .foo, > flip,
|
1479
|
+
> foo bar {
|
1480
|
+
a: b; }
|
1481
|
+
CSS
|
1482
|
+
> .foo {a: b}
|
1483
|
+
flip,
|
1484
|
+
> foo bar {@extend .foo}
|
1485
|
+
SCSS
|
1486
|
+
end
|
1487
|
+
|
1416
1488
|
private
|
1417
1489
|
|
1418
1490
|
def render(sass, options = {})
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 592302957
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 2
|
9
9
|
- 0
|
10
10
|
- alpha
|
11
|
-
-
|
12
|
-
version: 3.2.0.alpha.
|
11
|
+
- 56
|
12
|
+
version: 3.2.0.alpha.56
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Nathan Weizenbaum
|
@@ -19,7 +19,7 @@ autorequire:
|
|
19
19
|
bindir: bin
|
20
20
|
cert_chain: []
|
21
21
|
|
22
|
-
date: 2012-01-
|
22
|
+
date: 2012-01-13 00:00:00 -05:00
|
23
23
|
default_executable:
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|
@@ -150,6 +150,7 @@ files:
|
|
150
150
|
- lib/sass/tree/root_node.rb
|
151
151
|
- lib/sass/tree/rule_node.rb
|
152
152
|
- lib/sass/tree/content_node.rb
|
153
|
+
- lib/sass/tree/trace_node.rb
|
153
154
|
- lib/sass/tree/variable_node.rb
|
154
155
|
- lib/sass/tree/visitors/base.rb
|
155
156
|
- lib/sass/tree/visitors/check_nesting.rb
|
@@ -161,7 +162,6 @@ files:
|
|
161
162
|
- lib/sass/tree/visitors/to_css.rb
|
162
163
|
- lib/sass/tree/warn_node.rb
|
163
164
|
- lib/sass/tree/while_node.rb
|
164
|
-
- lib/sass/tree/trace_node.rb
|
165
165
|
- lib/sass/util.rb
|
166
166
|
- lib/sass/util/multibyte_string_scanner.rb
|
167
167
|
- lib/sass/util/subset_map.rb
|