Don't store a RuleFeatureSet on ScopedStyleResolver.
Instead lets just iterate the list of sheets and ask each one questions. This shouldn't be much slower since most widgets only have one sheet anyway. I also moved the media query matching to the sheet collection. We weren't correctly matching them since we only guarded the feature set, not the addition to the list of active sheets. R=abarth@chromium.org, ojan@chromium.org Review URL: https://codereview.chromium.org/858423002
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
Running 2 tests
|
||||
ok 1 Media queries should allow sheets to apply when they match
|
||||
ok 2 Media queries should cause sheets to be skipped when they do not match
|
||||
2 tests
|
||||
2 pass
|
||||
0 fail
|
||||
29
engine/src/flutter/tests/styles/media-queries.sky
Normal file
29
engine/src/flutter/tests/styles/media-queries.sky
Normal file
@@ -0,0 +1,29 @@
|
||||
<html>
|
||||
<import src="../resources/chai.sky" />
|
||||
<import src="../resources/mocha.sky" />
|
||||
|
||||
<style media="(max-width: 0px)">
|
||||
#test { color: rgb(255, 0, 0); }
|
||||
</style>
|
||||
<div id="does-not-match">Should not be red.</div>
|
||||
|
||||
<style media="(max-width: 10000px)">
|
||||
#matches { color: rgb(255, 0, 0); }
|
||||
</style>
|
||||
|
||||
<div id="matches">Should be red.</div>
|
||||
|
||||
<script>
|
||||
describe('Media queries', function() {
|
||||
it('should allow sheets to apply when they match', function() {
|
||||
var element = document.getElementById('matches');
|
||||
assert.equal(getComputedStyle(element).color, "rgb(255, 0, 0)");
|
||||
});
|
||||
|
||||
it('should cause sheets to be skipped when they do not match', function() {
|
||||
var element = document.getElementById('does-not-match');
|
||||
assert.equal(getComputedStyle(element).color, "rgb(0, 0, 0)");
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</html>
|
||||
Reference in New Issue
Block a user