Skip to content

Commit

Permalink
Merge pull request #200 from ebidel/resetStyleInheritance-feature
Browse files Browse the repository at this point in the history
Fixes issue #199 - adds support for resetStyleInheritance on prototype
  • Loading branch information
frankiefu committed Jul 8, 2013
2 parents e9ef557 + ef2c3d3 commit 411d53c
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/instance/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
root.olderShadowRoot = elderRoot;
// migrate flag(s)
root.applyAuthorStyles = this.applyAuthorStyles;
root.resetStyleInheritance = this.resetStyleInheritance;
// TODO(sorvell): host not set per spec; we set it for convenience
// so we can traverse from root to host.
root.host = this;
Expand Down
55 changes: 55 additions & 0 deletions test/html/styling/apply-reset-styles.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!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>applyAuthorStyles / resetStyleInheirtance</title>
<script src="../../../polymer.js"></script>
<script src="../../../tools/test/htmltest.js"></script>
<script src="../../../node_modules/chai/chai.js"></script>
<style>
body {
color: rgb(255, 0, 0);
font-size: 100px;
}
div {
color: rgb(0, 255, 0);
}
</style>
</head>
<body>
<x-test></x-test>

<polymer-element name="x-test">
<template><div id="div">I should be small and green</div></template>
<script>
Polymer('x-test', {
applyAuthorStyles: true,
resetStyleInheritance: true,
ready: function() {
this.appliedAuthorStyles = this.shadowRoot.applyAuthorStyles;
this.appliedResetStyles = this.shadowRoot.resetStyleInheritance;
}
});
</script>
</polymer-element>

<script>
document.addEventListener('WebComponentsReady', function() {
var test = document.querySelector('x-test');
chai.assert.isTrue(test.appliedAuthorStyles, 'applyAuthorStyles applied');
chai.assert.isTrue(test.appliedResetStyles, 'resetStyleInheritance applied');
chai.assert.equal(getComputedStyle(test).color, 'rgb(255, 0, 0)',
'author styles applied correctly');
chai.assert.equal(getComputedStyle(test.$.div).color, 'rgb(0, 255, 0)',
'styles reset correctly');
chai.assert.notEqual(parseInt(getComputedStyle(test.$.div).fontSize), 100,
'styles reset correctly');
done();
});
</script>
</body>
</html>
1 change: 1 addition & 0 deletions test/js/styling.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ htmlSuite('styling', function() {
htmlTest('html/styling/sheet-order.html');
htmlTest('html/styling/sheet-order.html?shadow');
htmlTest('html/styling/sheet-main-doc.html');
htmlTest('html/styling/apply-reset-styles.html');
});

0 comments on commit 411d53c

Please sign in to comment.