Using constant rather than plain :host and ::content, also create regexp object only once

This commit is contained in:
Nazar Mokrynskyi 2015-11-02 04:32:39 +01:00
parent d9f3dda973
commit c6c28f5197

View File

@ -159,7 +159,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
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);
@ -255,7 +255,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
// 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';
@ -265,6 +265,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var CSS_ATTR_SUFFIX = ']';
var PSEUDO_PREFIX = ':';
var CLASS = 'class';
var CONTENT_START = new RegExp('^(' + CONTENT + ')');
// exports
return api;