Skip to content

Commit

Permalink
Eliminate the need to write :host ::content instead of just `::cont…
Browse files Browse the repository at this point in the history
…ent`, while keeping the same processing under the hood
  • Loading branch information
nazar-pc committed Feb 1, 2016
1 parent 4a9ef8e commit d9f3dda
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/lib/style-transformer.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
* :host(...) -> scopeName...
* ::content -> ' ' NOTE: requires use of scoping selector and selectors
cannot otherwise be scoped:
e.g. :host ::content > .bar -> x-foo > .bar
* ::content -> ' '
* ::shadow, /deep/: processed similar to ::content
Expand Down Expand Up @@ -161,6 +159,7 @@
var stop = false;
var hostContext = false;
var self = this;
selector = selector.replace(/^(::content)/, ':host $1');
selector = selector.replace(SIMPLE_SELECTOR_SEP, function(m, c, s) {
if (!stop) {
var info = self._transformCompoundSelector(s, c, scope, hostScope);
Expand Down
6 changes: 3 additions & 3 deletions test/unit/polymer-dom-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
box-sizing: border-box;
}

:host ::content .add3 {
::content .add3 {
box-sizing: border-box;
height: 20px;
background: #333;
Expand Down Expand Up @@ -240,7 +240,7 @@
padding: 4px;
}

:host ::content .add2 {
::content .add2 {
box-sizing: border-box;
height: 20px;
background: gray;
Expand Down Expand Up @@ -281,7 +281,7 @@
padding: 4px;
}

:host ::content .add1 {
::content .add1 {
box-sizing: border-box;
height: 20px;
background: lightgray;
Expand Down

4 comments on commit d9f3dda

@arturparkhisenko
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nazar-pc i don't understand why styles is shared to global if i don't set them :host before ::content, only in a case of dynamically added content in elements. Or i have to fix it by adding style-scope name-of-element.. but it'll be bad 😞 (i'm using 1.4.0).
Example with comments and etc.. maybe i'm wrong and it's must work like now.. but it's currently very strange behavior.. http://plnkr.co/edit/FwIceGcTBhpwZaJLWhx7?p=preview (i'm used rawgit from master there's a link to source view-source:https://rawgit.com/Polymer/polymer/master/src/lib/style-transformer.html , not sure that its 1.4.0 but you can test it locally).
Do i have to open issue for it? @azakus

@dfreedm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please open an issue.
However, please put the styles of your elements into the template, and use Polymer.dom(this).appendChild when you file the issue.

@arturparkhisenko
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@azakus I hope you mean Polymer.dom(this).node.appendChild(newElement);, because Polymer.dom(this) doesn't have appendChild method)
Issue here: #3555

@arthurevans
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented on the other issue, but Polymer.dom(this).appendChild is correct. If Polymer.dom(someNode) doesn't have an appendChild method, that would be a big problem.

Polymer.dom(this).node === this... So calling Polymer.dom(this).node.appendChild(newElement) is the same as calling this.appendChild ... which does not do the right thing.

Please sign in to comment.