Skip to content

Commit

Permalink
Based on feedback, change module to include in custom-style and d…
Browse files Browse the repository at this point in the history
…om-module style marshaling.
  • Loading branch information
Steven Orvell committed Aug 6, 2015
1 parent 398d9f7 commit f469129
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
18 changes: 9 additions & 9 deletions src/lib/custom-style.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
browsers without non-native Shadow DOM.
* Custom properties used by Polymer's shim for cross-scope styling
may be defined in an `custom-style`.
* A module attribute may be specified to pull in style data from a `dom-module`
matching the module attribute. By using `module`, style data
* An `include` attribute may be specified to pull in style data from a
`dom-module` matching the include attribute. By using `include`, style data
can be shared between multiple `custom-style` elements.
Example:
Expand Down Expand Up @@ -84,13 +84,13 @@
extends: 'style',

properties: {
// module is a property so that it deserializes
// include is a property so that it deserializes
/**
* Specify module to identify a `dom-module` containing style data which
* should be used within the `custom-style`. By using `module` style data
* Specify `include` to identify a `dom-module` containing style data which
* should be used within the `custom-style`. By using `include` style data
* may be shared between multiple different `custom-style` elements.
*/
module: String
include: String
},

ready: function() {
Expand All @@ -114,7 +114,7 @@
styleDefaults.addStyle(e);
// we may not have any textContent yet due to parser yielding
// if so, wait until we do...
if (e.textContent || this.module) {
if (e.textContent || this.include) {
this._apply();
} else {
var observer = new MutationObserver(function() {
Expand All @@ -136,8 +136,8 @@
if (!this.__appliedElement) {
e.textContent = styleUtil.resolveCss(e.textContent, e.ownerDocument);
}
if (this.module) {
e.textContent += styleUtil.cssFromModules(this.module);
if (this.include) {
e.textContent += styleUtil.cssFromModules(this.include);
}
this._computeStyleProperties();
var props = this._styleProperties;
Expand Down
3 changes: 2 additions & 1 deletion src/lib/style-util.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
return {

MODULE_STYLES_SELECTOR: 'style, link[rel=import][type~=css], template',
INCLUDE_ATTR: 'include',

toCssText: function(rules, callback, preserveProperties) {
if (typeof rules === 'string') {
Expand Down Expand Up @@ -115,7 +116,7 @@
// style elements inside dom-modules will apply to the main document
// we don't want this, so we remove them here.
if (e.localName === 'style') {
addModule = e.getAttribute('module');
addModule = e.getAttribute(this.INCLUDE_ATTR);
// get style element applied to main doc via HTMLImports polyfill
e = e.__appliedElement || e;
e.parentNode.removeChild(e);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/custom-style-import.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</template>
</dom-module>

<style is="custom-style" module="shared-style">
<style is="custom-style" include="shared-style">
:root {

--import-mixin: {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/styling-remote-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
</style>
<template>
<!-- style in template using module! -->
<style module="remote-styles"></style>
<style include="remote-styles"></style>
<content select=".blank"></content>
<div id="simple">simple</div>
<div id="complex1" class="scoped">complex1</div>
Expand Down

0 comments on commit f469129

Please sign in to comment.