Files
polymer/test/html/styling/pseudo-scoping.html
T
2013-05-13 18:07:25 -07:00

60 lines
1.5 KiB
HTML

<!DOCTYPE html>
<!--
Copyright 2013 The Polymer-Project 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>
<meta name="viewport" content="initial-scale=1.0">
<title>Psuedo scoped styling</title>
<script src="../../../polymer.js"></script>
<script src="../../../tools/test/htmltest.js"></script>
<script src="../../../node_modules/chai/chai.js"></script>
<style>
div {
font-size: 10px;
}
</style>
</head>
<body>
<x-foo></x-foo>
<div id="outerScopeDiv">10px</div>
<element name="x-foo">
<template>
<style>
div {
font-size: 20px;
}
@media screen and (max-width: 800px) {
div {
font-size: 50px;
}
}
</style>
<div>20px / 50px</div>
</template>
<script>Polymer.register(this)</script>
</element>
<script>
document.addEventListener('WebComponentsReady', function() {
setTimeout(function() {
var foo = document.querySelector('x-foo');
fooDiv = foo.webkitShadowRoot.querySelector('div');
chai.assert.equal(getComputedStyle(fooDiv).fontSize, window.innerWidth < 800 ? '50px' : '20px',
'shadowDOM styles are applied');
var div = document.querySelector('#outerScopeDiv');
chai.assert.equal(getComputedStyle(div).fontSize, '10px',
'shadowDOM styles are applied only in the correct scope');
done();
});
});
</script>
</body>
</html>