-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Data-binding to native DOM element inside of auto-binding template invokes style scoping #1542
Labels
Comments
I'm thinking we special case binding to the |
Nice catch, thanks for the bug report. We'll look into the fix. |
sorvell
pushed a commit
that referenced
this issue
May 23, 2015
kevinpschaaf
added a commit
that referenced
this issue
May 23, 2015
Make `dom-bind` not scope element classes. Fixes #1542
Hi I'm not sure this still have a problem or it should to be? In my case I found a style-scope added when I use with innerHTML. <dom-element id='element1'>
<div>
<template is='dom-bind'>
<span class='red'>Content</span>
</template>
</div>
</dom-element>
<dom-element id='element2'>
<div>
<template is='dom-bind'>
<span class='red'>Content</span>
</template>
</div>
</dom-element>
<script>
window.addEventListener('WebComponentsReady', function () {
element1.change("<div><template is='dom-bind'><span class='red'>Content</span></template></div>");
element2.change("<div><span class='red'>Content</span></div>");
});
</script> and <dom-module id='dom-element'>
<template>
<div id='container'>
<content></content>
</div>
</template>
<script>
Polymer({
is: 'dom-element',
change: function (html) {
this.$.container.innerHTML = html;
}
});
</script>
</dom-module> Thank you. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This was an interesting one. So it seems that Polymer will append the
style-scoped
class to a native element that is being databound when inside of an auto-binding template.I first encountered this at http://www.plastikit.org/0.9/components/plastik-option-list/demo/ (source).
The native element in this case is
<span class$="[[selectionStyle1]]">...</span>
. I have two bits of CSS which target this element:p span { color: rgba(0, 0, 0, .87); }
as well as.nothing { color: rgba(0, 0, 0, .54); }
. (The default color for text on the page isrgba(0, 0, 0, .54)
.)When I set
selectionStyle1
to a value other than "nothing", the expected result is that the text will turn a richer black. But it seems not to be the case because neither of the above snippets of CSS affect the element at all.As soon as I tack on databinding
$="[[...]]"
to the<span>
tag, it getsstyle-scope
added to its list of CSS classes. This causes the CSS defined in the page to no longer have any effect on the element, as the document styles are shimmed withcustom-style
, thus generatingspan:not(.style-scope)
and preventing the CSS from affecting the<span>
tag.As I understand it, the
<span>
tag shouldn't havestyle-scope
applied to it at all in this case.The text was updated successfully, but these errors were encountered: