Skip to content

Commit

Permalink
Using constant rather than plain :host and ::content, also create…
Browse files Browse the repository at this point in the history
… regexp object only once
  • Loading branch information
nazar-pc committed Feb 1, 2016
1 parent d9f3dda commit c6c28f5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib/style-transformer.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
var stop = false;
var hostContext = false;
var self = this;
selector = selector.replace(/^(::content)/, ':host $1');
selector = selector.replace(CONTENT_START, HOST + ' $1');
selector = selector.replace(SIMPLE_SELECTOR_SEP, function(m, c, s) {
if (!stop) {
var info = self._transformCompoundSelector(s, c, scope, hostScope);
Expand Down Expand Up @@ -255,7 +255,7 @@
// NOTE: this supports 1 nested () pair for things like
// :host(:not([selected]), more general support requires
// parsing which seems like overkill
var HOST_PAREN = /(\:host)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))/g;
var HOST_PAREN = /(:host)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))/g;
var HOST_CONTEXT = ':host-context';
var HOST_CONTEXT_PAREN = /(.*)(?::host-context)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))(.*)/;
var CONTENT = '::content';
Expand All @@ -265,6 +265,7 @@
var CSS_ATTR_SUFFIX = ']';
var PSEUDO_PREFIX = ':';
var CLASS = 'class';
var CONTENT_START = new RegExp('^(' + CONTENT + ')');

// exports
return api;
Expand Down

0 comments on commit c6c28f5

Please sign in to comment.