This repository has been archived by the owner on Mar 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
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
159 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
<!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>Psuedo scoped styling</title> | ||
<script src="../../../platform.js"></script> | ||
<script src="register.js"></script> | ||
<script src="../../../../tools/test/htmltest.js"></script> | ||
<script src="../../../../tools/test/chai/chai.js"></script> | ||
<script> | ||
if (window.ShadowDOMPolyfill) { | ||
Platform.ShadowCSS.strictStyling = true; | ||
} | ||
</script> | ||
<style> | ||
div { | ||
font-size: 10px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<x-foo></x-foo> | ||
<button is="x-button"></button> | ||
<div id="outerScopeDiv">10px</div> | ||
|
||
<template id="x-inner"> | ||
<div>Not green</div> | ||
</template> | ||
|
||
<template id="x-foo"> | ||
<style> | ||
@host { | ||
* { | ||
display: block; | ||
border: 1px solid black; | ||
} | ||
} | ||
|
||
div { | ||
font-size: 20px; | ||
background: green; | ||
} | ||
|
||
div::before { | ||
background: blue; | ||
content: 'zonk'; | ||
} | ||
|
||
@media screen and (max-width: 800px) { | ||
div { | ||
font-size: 50px; | ||
} | ||
} | ||
</style> | ||
<div>20px / 50px</div> | ||
<x-inner></x-inner> | ||
</template> | ||
|
||
<template id="x-button"> | ||
<style> | ||
div { | ||
background: red; | ||
} | ||
|
||
@media screen and (min-width: 50px) { | ||
div { | ||
font-size: 50px; | ||
} | ||
} | ||
</style> | ||
<div>button</div> | ||
</template> | ||
|
||
<script> | ||
register('x-inner', '', HTMLElement.prototype); | ||
register('x-foo', '', HTMLElement.prototype); | ||
register('x-button', 'button', HTMLButtonElement.prototype, ['x-button']); | ||
|
||
document.addEventListener('WebComponentsReady', function() { | ||
setTimeout(function() { | ||
var foo = document.querySelector('x-foo'); | ||
var fooDiv = foo.shadowRoot.querySelector('div'); | ||
var innerDiv = foo.shadowRoot.querySelector('x-inner') | ||
.shadowRoot.querySelector('div'); | ||
var fooDivStyle = getComputedStyle(fooDiv); | ||
chai.assert.equal(fooDivStyle.fontSize, window.innerWidth < 800 ? '50px' : '20px', | ||
'shadowDOM styles are applied'); | ||
var fooDivBeforeStyle = getComputedStyle(fooDiv, ':before'); | ||
chai.assert.equal(fooDivBeforeStyle.backgroundColor, 'rgb(0, 0, 255)', | ||
':before styles are applied'); | ||
var div = document.querySelector('#outerScopeDiv'); | ||
chai.assert.equal(getComputedStyle(div).fontSize, '10px', | ||
'shadowDOM styles are applied only in the correct scope'); | ||
var bgColor = getComputedStyle(innerDiv).backgroundColor; | ||
chai.assert.isTrue(bgColor == 'rgba(0, 0, 0, 0)'|| bgColor == 'transparent', | ||
'upper bound encapsulation is enforced'); | ||
|
||
|
||
var xButtonDiv = document.querySelector('[is=x-button]') | ||
.shadowRoot.querySelector('div'); | ||
var xButtonDivStyle = getComputedStyle(xButtonDiv); | ||
chai.assert.equal(xButtonDivStyle.backgroundColor, 'rgb(255, 0, 0)', | ||
'type extension is properly shimmed'); | ||
chai.assert.equal(xButtonDivStyle.fontSize, '50px', | ||
'media query for type extension is properly shimmed'); | ||
|
||
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
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