-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
102 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<!DOCTYPE html> | ||
<!-- | ||
Copyright 2013 The Polymer Authors. All rights reserved. | ||
Use of this source code is governed by a BSD-style | ||
license that can be found in the LICENSE file. | ||
--> | ||
<html> | ||
<head> | ||
<title>Sheet scope</title> | ||
<script src="../../../polymer.js"></script> | ||
<script src="../../../tools/test/htmltest.js"></script> | ||
<script src="../../../node_modules/chai/chai.js"></script> | ||
<style> | ||
</style> | ||
</head> | ||
<body> | ||
<x-stylish></x-stylish> | ||
<div id="node1" class="global-stylish controller-stylish2">1</div> | ||
<div id="node2" class="controller-stylish controller-stylish2">2</div> | ||
<div id="node3" class="yellow12">3</div> | ||
<div id="node4" class="red1">4</div> | ||
|
||
<x-other></x-other> | ||
|
||
<polymer-element name="x-stylish"> | ||
<template> | ||
<link rel="stylesheet" href="sheet1.css" polymer-scope="global"> | ||
<link rel="stylesheet" href="sheet2.css" polymer-scope="controller"> | ||
<style polymer-scope="global"> | ||
.global-stylish { | ||
background: red; | ||
} | ||
</style> | ||
<style polymer-scope="controller"> | ||
.controller-stylish { | ||
background: blue; | ||
} | ||
</style> | ||
<style polymer-scope="controller"> | ||
.controller-stylish2 { | ||
font-style: italic; | ||
} | ||
</style> | ||
stylish | ||
</template> | ||
<script> | ||
Polymer('x-stylish', { | ||
created: function() { | ||
this.installControllerStyles(); | ||
} | ||
}); | ||
</script> | ||
</polymer-element> | ||
|
||
<polymer-element name="x-other" noscript> | ||
<template> | ||
<x-stylish></x-stylish> | ||
<div id="inner1" class="controller-stylish controller-stylish2">stylish</div> | ||
<div id="inner2" class="yellow12"></div> | ||
</template> | ||
</polymer-element> | ||
|
||
<script> | ||
document.addEventListener('WebComponentsReady', function() { | ||
|
||
var xother = document.querySelector('x-other'); | ||
|
||
function test(node, propertyName, value) { | ||
var computed = getComputedStyle(node)[propertyName]; | ||
chai.assert.equal(computed, value, 'computed ' + propertyName + | ||
' matches expected.'); | ||
} | ||
var node1 = document.querySelector('#node1'); | ||
var node2 = document.querySelector('#node2') | ||
var node3 = document.querySelector('#node3') | ||
|
||
test(node1, 'backgroundColor', 'rgb(255, 0, 0)'); | ||
test(node1, 'fontStyle', 'italic'); | ||
test(node2, 'backgroundColor', 'rgb(0, 0, 255)'); | ||
test(node2, 'fontStyle', 'italic'); | ||
test(node3, 'backgroundColor', 'rgb(255, 255, 0)'); | ||
test(node4, 'backgroundColor', 'rgb(255, 0, 0)'); | ||
test(xother.$.inner1, 'backgroundColor', 'rgb(0, 0, 255)'); | ||
test(xother.$.inner1, 'fontStyle', 'italic'); | ||
test(xother.$.inner2, 'backgroundColor', 'rgb(255, 255, 0)'); | ||
done(); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters