Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
simple test for combinators (^ and ^^)
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Oct 21, 2013
1 parent 8d0f24e commit d6cf73f
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions test/html/styling/combinators.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<!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>
<meta name="viewport" content="initial-scale=1.0">
<title>Using combinators styling</title>
<script src="../../../platform.js"></script>
<script src="register.js"></script>
<script src="../../../../tools/test/htmltest.js"></script>
<script src="../../../node_modules/chai/chai.js"></script>
</head>
<body>

<template id="x-foo">
<style>
x-bar ^ .bar {
background: red;
}

x-bar ^^ .zot {
color: white;
}
</style>
<x-bar></x-bar>
</template>
<template id="x-bar">
<style>
x-zot ^ .zot {
background: green;
}
</style>
<div class="bar">Bar</div>
<x-zot></x-zot>
</template>

<template id="x-zot">
<div class="zot">Zot</div>
</template>


<script>
XZot = register('x-zot', '', HTMLElement.prototype, ['x-zot']);
XBar = register('x-bar', '', HTMLElement.prototype, ['x-bar']);
XFoo = register('x-foo', '', HTMLElement.prototype, ['x-foo']);
</script>

<x-foo></x-foo>

<script>
document.addEventListener('WebComponentsReady', function() {
var foo = document.querySelector('x-foo');
var bar = foo.shadowRoot.querySelector('x-bar').shadowRoot
.querySelector('.bar');

chai.assert.equal(getComputedStyle(bar).backgroundColor, 'rgb(255, 0, 0)',
'^ styles are applied (backgroundColor)');

var zot = foo.shadowRoot.querySelector('x-bar').shadowRoot
.querySelector('x-zot').shadowRoot.querySelector('.zot');

chai.assert.equal(getComputedStyle(zot).backgroundColor, 'rgb(0, 128, 0)',
'^ styles are applied (backgroundColor)');
chai.assert.equal(getComputedStyle(zot).color, 'rgb(255, 255, 255)',
'^^ styles are applied (color)');
done();


});
</script>
</body>
</html>

0 comments on commit d6cf73f

Please sign in to comment.