Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes issue #199 - adds support for resetStyleInheritance on prototype #200

Merged
merged 3 commits into from
Jul 8, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -13,5 +13,6 @@ htmlSuite('styling', function() {
htmlTest('html/styling/polyfill-directive.html?shadow');
htmlTest('html/styling/pseudo-scoping.html?shadow');
htmlTest('html/styling/sheet-main-doc.html');
htmlTest('html/styling/apply-reset-styles.html');
});