gobstones-board 1.8.4 → 1.8.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,12 +14,14 @@ The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
14
14
  The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
15
15
  Code distributed by Google as part of the polymer project is also
16
16
  subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
17
- --><link rel="import" href="polymer-mini.html"><script>Polymer.nar = [];
17
+ --><link rel="import" href="polymer-mini.html"><script>(function () {
18
+ Polymer.nar = [];
19
+ var disableUpgradeEnabled = Polymer.Settings.disableUpgradeEnabled;
18
20
  Polymer.Annotations = {
19
- parseAnnotations: function (template) {
21
+ parseAnnotations: function (template, stripWhiteSpace) {
20
22
  var list = [];
21
23
  var content = template._content || template.content;
22
- this._parseNodeAnnotations(content, list, template.hasAttribute('strip-whitespace'));
24
+ this._parseNodeAnnotations(content, list, stripWhiteSpace || template.hasAttribute('strip-whitespace'));
23
25
  return list;
24
26
  },
25
27
  _parseNodeAnnotations: function (node, list, stripWhiteSpace) {
@@ -130,7 +132,7 @@ var i = 0;
130
132
  while (node) {
131
133
  var next = node.nextSibling;
132
134
  if (node.localName === 'template' && !node.hasAttribute('preserve-content')) {
133
- this._parseTemplate(node, i, list, annote);
135
+ this._parseTemplate(node, i, list, annote, stripWhiteSpace);
134
136
  }
135
137
  if (node.localName == 'slot') {
136
138
  node = this._replaceSlotWithContent(node);
@@ -177,9 +179,9 @@ content.setAttribute('select', '[slot=\'' + name + '\']');
177
179
  slot.parentNode.replaceChild(content, slot);
178
180
  return content;
179
181
  },
180
- _parseTemplate: function (node, index, list, parent) {
182
+ _parseTemplate: function (node, index, list, parent, stripWhiteSpace) {
181
183
  var content = document.createDocumentFragment();
182
- content._notes = this.parseAnnotations(node);
184
+ content._notes = this.parseAnnotations(node, stripWhiteSpace);
183
185
  content.appendChild(node.content);
184
186
  list.push({
185
187
  bindings: Polymer.nar,
@@ -224,6 +226,9 @@ node.setAttribute(name, literal);
224
226
  if (node.localName === 'input' && origName === 'value') {
225
227
  node.setAttribute(origName, '');
226
228
  }
229
+ if (disableUpgradeEnabled && origName === 'disable-upgrade$') {
230
+ node.setAttribute(name, '');
231
+ }
227
232
  node.removeAttribute(origName);
228
233
  var propertyName = Polymer.CaseMap.dashToCamelCase(name);
229
234
  if (kind === 'property') {
@@ -251,64 +256,6 @@ return n;
251
256
  return root;
252
257
  }
253
258
  }
254
- };(function () {
255
- function resolveCss(cssText, ownerDocument) {
256
- return cssText.replace(CSS_URL_RX, function (m, pre, url, post) {
257
- return pre + '\'' + resolve(url.replace(/["']/g, ''), ownerDocument) + '\'' + post;
258
- });
259
- }
260
- function resolveAttrs(element, ownerDocument) {
261
- for (var name in URL_ATTRS) {
262
- var a$ = URL_ATTRS[name];
263
- for (var i = 0, l = a$.length, a, at, v; i < l && (a = a$[i]); i++) {
264
- if (name === '*' || element.localName === name) {
265
- at = element.attributes[a];
266
- v = at && at.value;
267
- if (v && v.search(BINDING_RX) < 0) {
268
- at.value = a === 'style' ? resolveCss(v, ownerDocument) : resolve(v, ownerDocument);
269
- }
270
- }
271
- }
272
- }
273
- }
274
- function resolve(url, ownerDocument) {
275
- if (url && ABS_URL.test(url)) {
276
- return url;
277
- }
278
- var resolver = getUrlResolver(ownerDocument);
279
- resolver.href = url;
280
- return resolver.href || url;
281
- }
282
- var tempDoc;
283
- var tempDocBase;
284
- function resolveUrl(url, baseUri) {
285
- if (!tempDoc) {
286
- tempDoc = document.implementation.createHTMLDocument('temp');
287
- tempDocBase = tempDoc.createElement('base');
288
- tempDoc.head.appendChild(tempDocBase);
289
- }
290
- tempDocBase.href = baseUri;
291
- return resolve(url, tempDoc);
292
- }
293
- function getUrlResolver(ownerDocument) {
294
- return ownerDocument.body.__urlResolver || (ownerDocument.body.__urlResolver = ownerDocument.createElement('a'));
295
- }
296
- var CSS_URL_RX = /(url\()([^)]*)(\))/g;
297
- var URL_ATTRS = {
298
- '*': [
299
- 'href',
300
- 'src',
301
- 'style',
302
- 'url'
303
- ],
304
- form: ['action']
305
- };
306
- var ABS_URL = /(^\/)|(^#)|(^[\w-\d]*:)/;
307
- var BINDING_RX = /\{\{|\[\[/;
308
- Polymer.ResolveUrl = {
309
- resolveCss: resolveCss,
310
- resolveAttrs: resolveAttrs,
311
- resolveUrl: resolveUrl
312
259
  };
313
260
  }());Polymer.Path = {
314
261
  root: function (path) {
@@ -609,6 +556,9 @@ return new MouseEvent('test', { buttons: 1 }).buttons === 1;
609
556
  return false;
610
557
  }
611
558
  }();
559
+ function isMouseEvent(name) {
560
+ return MOUSE_EVENTS.indexOf(name) > -1;
561
+ }
612
562
  var SUPPORTS_PASSIVE = false;
613
563
  (function () {
614
564
  try {
@@ -622,6 +572,14 @@ window.removeEventListener('test', null, opts);
622
572
  } catch (e) {
623
573
  }
624
574
  }());
575
+ function PASSIVE_TOUCH(eventName) {
576
+ if (isMouseEvent(eventName) || eventName === 'touchend') {
577
+ return;
578
+ }
579
+ if (HAS_NATIVE_TA && SUPPORTS_PASSIVE && Polymer.Settings.passiveTouchGestures) {
580
+ return { passive: true };
581
+ }
582
+ }
625
583
  var IS_TOUCH_ONLY = navigator.userAgent.match(/iP(?:[oa]d|hone)|Android/);
626
584
  var mouseCanceller = function (mouseEvent) {
627
585
  var sc = mouseEvent.sourceCapabilities;
@@ -665,7 +623,7 @@ POINTERSTATE.mouse.mouseIgnoreJob = Polymer.Debounce(POINTERSTATE.mouse.mouseIgn
665
623
  }
666
624
  function hasLeftMouseButton(ev) {
667
625
  var type = ev.type;
668
- if (MOUSE_EVENTS.indexOf(type) === -1) {
626
+ if (!isMouseEvent(type)) {
669
627
  return false;
670
628
  }
671
629
  if (type === 'mousemove') {
@@ -842,7 +800,7 @@ node[GESTURE_KEY] = gobj = {};
842
800
  }
843
801
  for (var i = 0, dep, gd; i < deps.length; i++) {
844
802
  dep = deps[i];
845
- if (IS_TOUCH_ONLY && MOUSE_EVENTS.indexOf(dep) > -1 && dep !== 'click') {
803
+ if (IS_TOUCH_ONLY && isMouseEvent(dep) && dep !== 'click') {
846
804
  continue;
847
805
  }
848
806
  gd = gobj[dep];
@@ -850,7 +808,7 @@ if (!gd) {
850
808
  gobj[dep] = gd = { _count: 0 };
851
809
  }
852
810
  if (gd._count === 0) {
853
- node.addEventListener(dep, this.handleNative);
811
+ node.addEventListener(dep, this.handleNative, PASSIVE_TOUCH(dep));
854
812
  }
855
813
  gd[name] = (gd[name] || 0) + 1;
856
814
  gd._count = (gd._count || 0) + 1;
@@ -874,7 +832,7 @@ if (gd && gd[name]) {
874
832
  gd[name] = (gd[name] || 1) - 1;
875
833
  gd._count = (gd._count || 1) - 1;
876
834
  if (gd._count === 0) {
877
- node.removeEventListener(dep, this.handleNative);
835
+ node.removeEventListener(dep, this.handleNative, PASSIVE_TOUCH(dep));
878
836
  }
879
837
  }
880
838
  }
@@ -1628,7 +1586,7 @@ element.addEventListener(event, function (e) {
1628
1586
  return context._notifyListener(changedFn, e);
1629
1587
  });
1630
1588
  }
1631
- };Polymer.Base.extend(Polymer.Bind, {
1589
+ };Polymer.Base.mixin(Polymer.Bind, {
1632
1590
  _shouldAddListener: function (effect) {
1633
1591
  return effect.name && effect.kind != 'attribute' && effect.kind != 'text' && !effect.isCompound && effect.parts[0].mode === '{';
1634
1592
  },
@@ -1974,7 +1932,7 @@ var pinfo = node._propertyInfo && node._propertyInfo[property];
1974
1932
  if (pinfo && pinfo.readOnly) {
1975
1933
  return;
1976
1934
  }
1977
- this.__setProperty(property, value, false, node);
1935
+ this.__setProperty(property, value, Polymer.Settings.suppressBindingNotifications, node);
1978
1936
  }
1979
1937
  },
1980
1938
  _computeFinalAnnotationValue: function (node, property, value, info) {
@@ -2003,6 +1961,7 @@ this._effectEffects('__static__', null, this._propertyEffects.__static__);
2003
1961
  }
2004
1962
  });(function () {
2005
1963
  var usePolyfillProto = Polymer.Settings.usePolyfillProto;
1964
+ var avoidInstanceProperties = Boolean(Object.getOwnPropertyDescriptor(document.documentElement, 'properties'));
2006
1965
  Polymer.Base._addFeature({
2007
1966
  _setupConfigure: function (initialConfig) {
2008
1967
  this._config = {};
@@ -2040,7 +1999,7 @@ var config = {};
2040
1999
  for (var i = 0; i < this.behaviors.length; i++) {
2041
2000
  this._configureProperties(this.behaviors[i].properties, config);
2042
2001
  }
2043
- this._configureProperties(this.properties, config);
2002
+ this._configureProperties(avoidInstanceProperties ? this.__proto__.properties : this.properties, config);
2044
2003
  this.mixin(config, this._aboveConfig);
2045
2004
  this._config = config;
2046
2005
  if (this._clients && this._clients.length) {
@@ -2094,6 +2053,8 @@ node._configValue(name, value);
2094
2053
  }
2095
2054
  },
2096
2055
  _afterClientsReady: function () {
2056
+ this.importPath = this._importPath;
2057
+ this.rootPath = Polymer.rootPath;
2097
2058
  this._executeStaticEffects();
2098
2059
  this._applyConfig(this._config, this._aboveConfig);
2099
2060
  this._flushHandlers();
@@ -2432,13 +2393,7 @@ _getPathParts: Polymer.Base._getPathParts
2432
2393
  });
2433
2394
  }());Polymer.Base._addFeature({
2434
2395
  resolveUrl: function (url) {
2435
- var module = Polymer.DomModule.import(this.is);
2436
- var root = '';
2437
- if (module) {
2438
- var assetPath = module.getAttribute('assetpath') || '';
2439
- root = Polymer.ResolveUrl.resolveUrl(assetPath, module.ownerDocument.baseURI);
2440
- }
2441
- return Polymer.ResolveUrl.resolveUrl(url, root);
2396
+ return Polymer.ResolveUrl.resolveUrl(url, this._importPath);
2442
2397
  }
2443
2398
  });Polymer.CssParse = function () {
2444
2399
  return {
@@ -2587,6 +2542,8 @@ AT_START: '@'
2587
2542
  }();Polymer.StyleUtil = function () {
2588
2543
  var settings = Polymer.Settings;
2589
2544
  return {
2545
+ unscopedStyleImports: new WeakMap(),
2546
+ SHADY_UNSCOPED_ATTR: 'shady-unscoped',
2590
2547
  NATIVE_VARIABLES: Polymer.Settings.useNativeCSSProperties,
2591
2548
  MODULE_STYLES_SELECTOR: 'style, link[rel=import][type~=css], template',
2592
2549
  INCLUDE_ATTR: 'include',
@@ -2694,7 +2651,7 @@ this.__lastHeadApplyNode = placeHolder;
2694
2651
  return placeHolder;
2695
2652
  },
2696
2653
  cssFromModules: function (moduleIds, warnIfNotFound) {
2697
- var modules = moduleIds.trim().split(' ');
2654
+ var modules = moduleIds.trim().split(/\s+/);
2698
2655
  var cssText = '';
2699
2656
  for (var i = 0; i < modules.length; i++) {
2700
2657
  cssText += this.cssFromModule(modules[i], warnIfNotFound);
@@ -2729,14 +2686,62 @@ cssText += this.cssFromModules(include, true);
2729
2686
  }
2730
2687
  e = e.__appliedElement || e;
2731
2688
  e.parentNode.removeChild(e);
2732
- cssText += this.resolveCss(e.textContent, element.ownerDocument);
2689
+ var css = this.resolveCss(e.textContent, element.ownerDocument);
2690
+ if (!settings.useNativeShadow && e.hasAttribute(this.SHADY_UNSCOPED_ATTR)) {
2691
+ e.textContent = css;
2692
+ document.head.insertBefore(e, document.head.firstChild);
2693
+ } else {
2694
+ cssText += css;
2695
+ }
2733
2696
  } else if (e.import && e.import.body) {
2734
- cssText += this.resolveCss(e.import.body.textContent, e.import);
2697
+ var importCss = this.resolveCss(e.import.body.textContent, e.import);
2698
+ if (!settings.useNativeShadow && e.hasAttribute(this.SHADY_UNSCOPED_ATTR)) {
2699
+ if (!this.unscopedStyleImports.has(e.import)) {
2700
+ this.unscopedStyleImports.set(e.import, true);
2701
+ var importStyle = document.createElement('style');
2702
+ importStyle.setAttribute(this.SHADY_UNSCOPED_ATTR, '');
2703
+ importStyle.textContent = importCss;
2704
+ document.head.insertBefore(importStyle, document.head.firstChild);
2705
+ }
2706
+ } else {
2707
+ cssText += importCss;
2708
+ }
2735
2709
  }
2736
2710
  }
2737
2711
  }
2738
2712
  return cssText;
2739
2713
  },
2714
+ styleIncludesToTemplate: function (targetTemplate) {
2715
+ var styles = targetTemplate.content.querySelectorAll('style[include]');
2716
+ for (var i = 0, s; i < styles.length; i++) {
2717
+ s = styles[i];
2718
+ s.parentNode.insertBefore(this._includesToFragment(s.getAttribute('include')), s);
2719
+ }
2720
+ },
2721
+ _includesToFragment: function (styleIncludes) {
2722
+ var includeArray = styleIncludes.trim().split(' ');
2723
+ var frag = document.createDocumentFragment();
2724
+ for (var i = 0; i < includeArray.length; i++) {
2725
+ var t = Polymer.DomModule.import(includeArray[i], 'template');
2726
+ if (t) {
2727
+ this._addStylesToFragment(frag, t.content);
2728
+ }
2729
+ }
2730
+ return frag;
2731
+ },
2732
+ _addStylesToFragment: function (frag, source) {
2733
+ var s$ = source.querySelectorAll('style');
2734
+ for (var i = 0, s; i < s$.length; i++) {
2735
+ s = s$[i];
2736
+ var include = s.getAttribute('include');
2737
+ if (include) {
2738
+ frag.appendChild(this._includesToFragment(include));
2739
+ }
2740
+ if (s.textContent) {
2741
+ frag.appendChild(s.cloneNode(true));
2742
+ }
2743
+ }
2744
+ },
2740
2745
  isTargetedBuild: function (buildType) {
2741
2746
  return settings.useNativeShadow ? buildType === 'shadow' : buildType === 'shady';
2742
2747
  },
@@ -2854,6 +2859,7 @@ var self = this;
2854
2859
  cb = function (rule) {
2855
2860
  rule.selector = self._slottedToContent(rule.selector);
2856
2861
  rule.selector = rule.selector.replace(ROOT, ':host > *');
2862
+ rule.selector = self._dirShadowTransform(rule.selector);
2857
2863
  if (callback) {
2858
2864
  callback(rule);
2859
2865
  }
@@ -2895,8 +2901,31 @@ this._transformRule(rule, this._transformComplexSelector, scope, hostScope);
2895
2901
  _transformRule: function (rule, transformer, scope, hostScope) {
2896
2902
  rule.selector = rule.transformedSelector = this._transformRuleCss(rule, transformer, scope, hostScope);
2897
2903
  },
2904
+ _splitSelectorList: function (selector) {
2905
+ var parts = [];
2906
+ var part = '';
2907
+ for (var i = 0; i >= 0 && i < selector.length; i++) {
2908
+ if (selector[i] === '(') {
2909
+ var end = styleUtil._findMatchingParen(selector, i);
2910
+ part += selector.slice(i, end + 1);
2911
+ i = end;
2912
+ } else if (selector[i] === COMPLEX_SELECTOR_SEP) {
2913
+ parts.push(part);
2914
+ part = '';
2915
+ } else {
2916
+ part += selector[i];
2917
+ }
2918
+ }
2919
+ if (part) {
2920
+ parts.push(part);
2921
+ }
2922
+ if (parts.length === 0) {
2923
+ parts.push(selector);
2924
+ }
2925
+ return parts;
2926
+ },
2898
2927
  _transformRuleCss: function (rule, transformer, scope, hostScope) {
2899
- var p$ = rule.selector.split(COMPLEX_SELECTOR_SEP);
2928
+ var p$ = this._splitSelectorList(rule.selector);
2900
2929
  if (!styleUtil.isKeyframesSelector(rule)) {
2901
2930
  for (var i = 0, l = p$.length, p; i < l && (p = p$[i]); i++) {
2902
2931
  p$[i] = transformer.call(this, p, scope, hostScope);
@@ -2904,19 +2933,36 @@ p$[i] = transformer.call(this, p, scope, hostScope);
2904
2933
  }
2905
2934
  return p$.join(COMPLEX_SELECTOR_SEP);
2906
2935
  },
2936
+ _ensureScopedDir: function (s) {
2937
+ var m = s.match(DIR_PAREN);
2938
+ if (m && m[1] === '' && m[0].length === s.length) {
2939
+ s = '*' + s;
2940
+ }
2941
+ return s;
2942
+ },
2943
+ _additionalDirSelectors: function (dir, after, prefix) {
2944
+ if (!dir || !after) {
2945
+ return '';
2946
+ }
2947
+ prefix = prefix || '';
2948
+ return COMPLEX_SELECTOR_SEP + prefix + ' ' + dir + ' ' + after;
2949
+ },
2907
2950
  _transformComplexSelector: function (selector, scope, hostScope) {
2908
2951
  var stop = false;
2909
2952
  var hostContext = false;
2953
+ var dir = false;
2910
2954
  var self = this;
2911
2955
  selector = selector.trim();
2912
2956
  selector = this._slottedToContent(selector);
2913
2957
  selector = selector.replace(ROOT, ':host > *');
2914
2958
  selector = selector.replace(CONTENT_START, HOST + ' $1');
2959
+ selector = this._ensureScopedDir(selector);
2915
2960
  selector = selector.replace(SIMPLE_SELECTOR_SEP, function (m, c, s) {
2916
2961
  if (!stop) {
2917
2962
  var info = self._transformCompoundSelector(s, c, scope, hostScope);
2918
2963
  stop = stop || info.stop;
2919
2964
  hostContext = hostContext || info.hostContext;
2965
+ dir = dir || info.dir;
2920
2966
  c = info.combinator;
2921
2967
  s = info.value;
2922
2968
  } else {
@@ -2926,14 +2972,28 @@ return c + s;
2926
2972
  });
2927
2973
  if (hostContext) {
2928
2974
  selector = selector.replace(HOST_CONTEXT_PAREN, function (m, pre, paren, post) {
2929
- return pre + paren + ' ' + hostScope + post + COMPLEX_SELECTOR_SEP + ' ' + pre + hostScope + paren + post;
2975
+ var replacement = pre + paren + ' ' + hostScope + post + COMPLEX_SELECTOR_SEP + ' ' + pre + hostScope + paren + post;
2976
+ if (dir) {
2977
+ replacement += self._additionalDirSelectors(paren, post, hostScope);
2978
+ }
2979
+ return replacement;
2930
2980
  });
2931
2981
  }
2932
2982
  return selector;
2933
2983
  },
2984
+ _transformDir: function (s) {
2985
+ s = s.replace(HOST_DIR, HOST_DIR_REPLACE);
2986
+ s = s.replace(DIR_PAREN, DIR_REPLACE);
2987
+ return s;
2988
+ },
2934
2989
  _transformCompoundSelector: function (selector, combinator, scope, hostScope) {
2935
2990
  var jumpIndex = selector.search(SCOPE_JUMP);
2936
2991
  var hostContext = false;
2992
+ var dir = false;
2993
+ if (selector.match(DIR_PAREN)) {
2994
+ selector = this._transformDir(selector);
2995
+ dir = true;
2996
+ }
2937
2997
  if (selector.indexOf(HOST_CONTEXT) >= 0) {
2938
2998
  hostContext = true;
2939
2999
  } else if (selector.indexOf(HOST) >= 0) {
@@ -2953,7 +3013,8 @@ return {
2953
3013
  value: selector,
2954
3014
  combinator: combinator,
2955
3015
  stop: stop,
2956
- hostContext: hostContext
3016
+ hostContext: hostContext,
3017
+ dir: dir
2957
3018
  };
2958
3019
  },
2959
3020
  _transformSimpleSelector: function (selector, scope) {
@@ -2990,13 +3051,32 @@ this._transformRule(rule, this._transformDocumentSelector);
2990
3051
  },
2991
3052
  normalizeRootSelector: function (rule) {
2992
3053
  rule.selector = rule.selector.replace(ROOT, 'html');
3054
+ var parts = this._splitSelectorList(rule.selector);
3055
+ parts = parts.filter(function (part) {
3056
+ return !part.match(HOST_OR_HOST_GT_STAR);
3057
+ });
3058
+ rule.selector = parts.join(COMPLEX_SELECTOR_SEP);
2993
3059
  },
2994
3060
  _transformDocumentSelector: function (selector) {
2995
- return selector.match(SCOPE_JUMP) ? this._transformComplexSelector(selector, SCOPE_DOC_SELECTOR) : this._transformSimpleSelector(selector.trim(), SCOPE_DOC_SELECTOR);
3061
+ return this._transformComplexSelector(selector, SCOPE_DOC_SELECTOR);
2996
3062
  },
2997
3063
  _slottedToContent: function (cssText) {
2998
3064
  return cssText.replace(SLOTTED_PAREN, CONTENT + '> $1');
2999
3065
  },
3066
+ _dirShadowTransform: function (selector) {
3067
+ if (!selector.match(/:dir\(/)) {
3068
+ return selector;
3069
+ }
3070
+ return this._splitSelectorList(selector).map(function (s) {
3071
+ s = this._ensureScopedDir(s);
3072
+ s = this._transformDir(s);
3073
+ var m = HOST_CONTEXT_PAREN.exec(s);
3074
+ if (m) {
3075
+ s += this._additionalDirSelectors(m[2], m[3], '');
3076
+ }
3077
+ return s;
3078
+ }, this).join(COMPLEX_SELECTOR_SEP);
3079
+ },
3000
3080
  SCOPE_NAME: 'style-scope'
3001
3081
  };
3002
3082
  var SCOPE_NAME = api.SCOPE_NAME;
@@ -3019,6 +3099,11 @@ var CLASS = 'class';
3019
3099
  var CONTENT_START = new RegExp('^(' + CONTENT + ')');
3020
3100
  var SELECTOR_NO_MATCH = 'should_not_match';
3021
3101
  var SLOTTED_PAREN = /(?:::slotted)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))/g;
3102
+ var HOST_OR_HOST_GT_STAR = /:host(?:\s*>\s*\*)?/;
3103
+ var DIR_PAREN = /(.*):dir\((ltr|rtl)\)/;
3104
+ var DIR_REPLACE = ':host-context([dir="$2"]) $1';
3105
+ var HOST_DIR = /:host\(:dir\((rtl|ltr)\)\)/g;
3106
+ var HOST_DIR_REPLACE = ':host-context([dir="$1"])';
3022
3107
  return api;
3023
3108
  }();Polymer.StyleExtends = function () {
3024
3109
  var styleUtil = Polymer.StyleUtil;
@@ -3321,6 +3406,9 @@ _prepShimStyles: function () {
3321
3406
  if (this._template) {
3322
3407
  var hasTargetedCssBuild = styleUtil.isTargetedBuild(this.__cssBuild);
3323
3408
  if (settings.useNativeCSSProperties && this.__cssBuild === 'shadow' && hasTargetedCssBuild) {
3409
+ if (settings.preserveStyleIncludes) {
3410
+ styleUtil.styleIncludesToTemplate(this._template);
3411
+ }
3324
3412
  return;
3325
3413
  }
3326
3414
  this._styles = this._styles || this._collectStyles();
@@ -3696,13 +3784,18 @@ rule.transformedKeyframesName = rule.keyframesName + '-' + scopeId;
3696
3784
  rule.transformedSelector = rule.transformedSelector || rule.selector;
3697
3785
  rule.selector = rule.transformedSelector.replace(rule.keyframesName, rule.transformedKeyframesName);
3698
3786
  },
3787
+ _hasDirOrHostContext: function (parsedSelector) {
3788
+ return /:host-context|:dir/.test(parsedSelector);
3789
+ },
3699
3790
  _scopeSelector: function (rule, hostRx, hostSelector, viaAttr, scopeId) {
3700
3791
  rule.transformedSelector = rule.transformedSelector || rule.selector;
3701
3792
  var selector = rule.transformedSelector;
3702
- var scope = viaAttr ? '[' + styleTransformer.SCOPE_NAME + '~=' + scopeId + ']' : '.' + scopeId;
3793
+ var scope = styleTransformer._calcElementScope(scopeId, viaAttr);
3794
+ var hostScope = styleTransformer._calcElementScope(hostSelector, viaAttr);
3703
3795
  var parts = selector.split(',');
3796
+ var isDirOrHostContextSelector = this._hasDirOrHostContext(rule.parsedSelector);
3704
3797
  for (var i = 0, l = parts.length, p; i < l && (p = parts[i]); i++) {
3705
- parts[i] = p.match(hostRx) ? p.replace(hostSelector, scope) : scope + ' ' + p;
3798
+ parts[i] = p.match(hostRx) ? p.replace(hostSelector, scope) : isDirOrHostContextSelector ? p.replace(hostScope, scope + ' ' + hostScope) : scope + ' ' + p;
3706
3799
  }
3707
3800
  rule.selector = parts.join(',');
3708
3801
  },
@@ -4085,7 +4178,9 @@ var XSCOPE_NAME = propertyUtils.XSCOPE_NAME;
4085
4178
  }());Polymer.Base._addFeature({
4086
4179
  _registerFeatures: function () {
4087
4180
  this._prepIs();
4181
+ if (this.factoryImpl) {
4088
4182
  this._prepConstructor();
4183
+ }
4089
4184
  this._prepStyles();
4090
4185
  },
4091
4186
  _finishRegisterFeatures: function () {
@@ -4105,7 +4200,7 @@ this._addHostAttributes(b.hostAttributes);
4105
4200
  },
4106
4201
  _initFeatures: function () {
4107
4202
  this._setupGestures();
4108
- this._setupConfigure();
4203
+ this._setupConfigure(this.__data__);
4109
4204
  this._setupStyleProperties();
4110
4205
  this._setupDebouncers();
4111
4206
  this._setupShady();
@@ -4150,6 +4245,9 @@ this.__cssBuild = styleUtil.getCssBuildType(this);
4150
4245
  if (this.__appliedElement !== this) {
4151
4246
  this.__appliedElement.__cssBuild = this.__cssBuild;
4152
4247
  }
4248
+ if (this.ownerDocument !== window.document && this.__appliedElement === this) {
4249
+ document.head.appendChild(this);
4250
+ }
4153
4251
  this._tryApply();
4154
4252
  },
4155
4253
  attached: function () {
@@ -4371,6 +4469,8 @@ fn: Polymer.Bind._notifyEffect,
4371
4469
  effect: { event: Polymer.CaseMap.camelToDashCase(parentProp) + '-changed' }
4372
4470
  }
4373
4471
  ];
4472
+ proto._propertyEffects = proto._propertyEffects || {};
4473
+ proto._propertyEffects[parentProp] = effects;
4374
4474
  Polymer.Bind._createAccessors(proto, parentProp, effects);
4375
4475
  }
4376
4476
  }
@@ -4412,12 +4512,17 @@ template._propertySetter = proto._propertySetter;
4412
4512
  }
4413
4513
  for (var i = 0, n; i < n$.length && (n = n$[i]); i++) {
4414
4514
  var val = template[n];
4515
+ if (val && n == '_propertyEffects') {
4516
+ var pe = Polymer.Base.mixin({}, val);
4517
+ template._propertyEffects = Polymer.Base.mixin(pe, proto._propertyEffects);
4518
+ } else {
4415
4519
  var pd = Object.getOwnPropertyDescriptor(proto, n);
4416
4520
  Object.defineProperty(template, n, pd);
4417
4521
  if (val !== undefined) {
4418
4522
  template._propertySetter(n, val);
4419
4523
  }
4420
4524
  }
4525
+ }
4421
4526
  },
4422
4527
  _showHideChildren: function (hidden) {
4423
4528
  },
@@ -4683,7 +4788,7 @@ observer: '_observeChanged'
4683
4788
  delay: Number,
4684
4789
  renderedItemCount: {
4685
4790
  type: Number,
4686
- notify: true,
4791
+ notify: !Polymer.Settings.suppressTemplateNotifications,
4687
4792
  readOnly: true
4688
4793
  },
4689
4794
  initialCount: {
@@ -4694,6 +4799,7 @@ targetFramerate: {
4694
4799
  type: Number,
4695
4800
  value: 20
4696
4801
  },
4802
+ notifyDomChange: { type: Boolean },
4697
4803
  _targetFrameTime: {
4698
4804
  type: Number,
4699
4805
  computed: '_computeFrameTime(targetFramerate)'
@@ -4719,9 +4825,17 @@ this._detachInstance(i);
4719
4825
  attached: function () {
4720
4826
  if (this.__isDetached) {
4721
4827
  this.__isDetached = false;
4722
- var parent = Polymer.dom(Polymer.dom(this).parentNode);
4828
+ var refNode;
4829
+ var parentNode = Polymer.dom(this).parentNode;
4830
+ if (parentNode.localName == this.is) {
4831
+ refNode = parentNode;
4832
+ parentNode = Polymer.dom(parentNode).parentNode;
4833
+ } else {
4834
+ refNode = this;
4835
+ }
4836
+ var parent = Polymer.dom(parentNode);
4723
4837
  for (var i = 0; i < this._instances.length; i++) {
4724
- this._attachInstance(i, parent);
4838
+ this._attachInstance(i, parent, refNode);
4725
4839
  }
4726
4840
  }
4727
4841
  },
@@ -4861,7 +4975,9 @@ inst.__setProperty(this.indexAs, i, true);
4861
4975
  }
4862
4976
  this._pool.length = 0;
4863
4977
  this._setRenderedItemCount(this._instances.length);
4978
+ if (!Polymer.Settings.suppressTemplateNotifications || this.notifyDomChange) {
4864
4979
  this.fire('dom-change');
4980
+ }
4865
4981
  this._tryRenderChunk();
4866
4982
  },
4867
4983
  _applyFullRefresh: function () {
@@ -5003,10 +5119,10 @@ Polymer.dom(inst.root).appendChild(el);
5003
5119
  return inst;
5004
5120
  }
5005
5121
  },
5006
- _attachInstance: function (idx, parent) {
5122
+ _attachInstance: function (idx, parent, refNode) {
5007
5123
  var inst = this._instances[idx];
5008
5124
  if (!inst.isPlaceholder) {
5009
- parent.insertBefore(inst.root, this);
5125
+ parent.insertBefore(inst.root, refNode);
5010
5126
  }
5011
5127
  },
5012
5128
  _detachAndRemoveInstance: function (idx) {
@@ -5039,6 +5155,12 @@ inst = this._stampInstance(idx, key);
5039
5155
  var beforeRow = this._instances[idx + 1];
5040
5156
  var beforeNode = beforeRow && !beforeRow.isPlaceholder ? beforeRow._children[0] : this;
5041
5157
  var parentNode = Polymer.dom(this).parentNode;
5158
+ if (parentNode.localName == this.is) {
5159
+ if (beforeNode == this) {
5160
+ beforeNode = parentNode;
5161
+ }
5162
+ parentNode = Polymer.dom(parentNode).parentNode;
5163
+ }
5042
5164
  Polymer.dom(parentNode).insertBefore(inst.root, beforeNode);
5043
5165
  this._instances[idx] = inst;
5044
5166
  return inst;
@@ -5226,14 +5348,19 @@ restamp: {
5226
5348
  type: Boolean,
5227
5349
  value: false,
5228
5350
  observer: '_queueRender'
5229
- }
5351
+ },
5352
+ notifyDomChange: { type: Boolean }
5230
5353
  },
5231
5354
  behaviors: [Polymer.Templatizer],
5232
5355
  _queueRender: function () {
5233
5356
  this._debounceTemplate(this._render);
5234
5357
  },
5235
5358
  detached: function () {
5236
- if (!this.parentNode || this.parentNode.nodeType == Node.DOCUMENT_FRAGMENT_NODE && (!Polymer.Settings.hasShadow || !(this.parentNode instanceof ShadowRoot))) {
5359
+ var parentNode = this.parentNode;
5360
+ if (parentNode && parentNode.localName == this.is) {
5361
+ parentNode = Polymer.dom(parentNode).parentNode;
5362
+ }
5363
+ if (!parentNode || parentNode.nodeType == Node.DOCUMENT_FRAGMENT_NODE && (!Polymer.Settings.hasShadow || !(parentNode instanceof ShadowRoot))) {
5237
5364
  this._teardownInstance();
5238
5365
  }
5239
5366
  },
@@ -5259,25 +5386,33 @@ if (!this.restamp && this._instance) {
5259
5386
  this._showHideChildren();
5260
5387
  }
5261
5388
  if (this.if != this._lastIf) {
5389
+ if (!Polymer.Settings.suppressTemplateNotifications || this.notifyDomChange) {
5262
5390
  this.fire('dom-change');
5391
+ }
5263
5392
  this._lastIf = this.if;
5264
5393
  }
5265
5394
  },
5266
5395
  _ensureInstance: function () {
5396
+ var refNode;
5267
5397
  var parentNode = Polymer.dom(this).parentNode;
5398
+ if (parentNode && parentNode.localName == this.is) {
5399
+ refNode = parentNode;
5400
+ parentNode = Polymer.dom(parentNode).parentNode;
5401
+ } else {
5402
+ refNode = this;
5403
+ }
5268
5404
  if (parentNode) {
5269
- var parent = Polymer.dom(parentNode);
5270
5405
  if (!this._instance) {
5271
5406
  this._instance = this.stamp();
5272
5407
  var root = this._instance.root;
5273
- parent.insertBefore(root, this);
5408
+ Polymer.dom(parentNode).insertBefore(root, refNode);
5274
5409
  } else {
5275
5410
  var c$ = this._instance._children;
5276
5411
  if (c$ && c$.length) {
5277
- var lastChild = Polymer.dom(this).previousSibling;
5412
+ var lastChild = Polymer.dom(refNode).previousSibling;
5278
5413
  if (lastChild !== c$[c$.length - 1]) {
5279
5414
  for (var i = 0, n; i < c$.length && (n = c$[i]); i++) {
5280
- parent.insertBefore(n, this);
5415
+ Polymer.dom(parentNode).insertBefore(n, refNode);
5281
5416
  }
5282
5417
  }
5283
5418
  }
@@ -5314,6 +5449,7 @@ this._instance._notifyPath(path, value, true);
5314
5449
  }
5315
5450
  });Polymer({
5316
5451
  is: 'dom-bind',
5452
+ properties: { notifyDomChange: { type: Boolean } },
5317
5453
  extends: 'template',
5318
5454
  _template: null,
5319
5455
  created: function () {
@@ -5341,8 +5477,15 @@ _registerFeatures: function () {
5341
5477
  this._prepConstructor();
5342
5478
  },
5343
5479
  _insertChildren: function () {
5344
- var parentDom = Polymer.dom(Polymer.dom(this).parentNode);
5345
- parentDom.insertBefore(this.root, this);
5480
+ var refNode;
5481
+ var parentNode = Polymer.dom(this).parentNode;
5482
+ if (parentNode.localName == this.is) {
5483
+ refNode = parentNode;
5484
+ parentNode = Polymer.dom(parentNode).parentNode;
5485
+ } else {
5486
+ refNode = this;
5487
+ }
5488
+ Polymer.dom(parentNode).insertBefore(this.root, refNode);
5346
5489
  },
5347
5490
  _removeChildren: function () {
5348
5491
  if (this._children) {
@@ -5394,8 +5537,10 @@ Polymer.Base._initFeatures.call(this);
5394
5537
  this._children = Polymer.TreeApi.arrayCopyChildNodes(this.root);
5395
5538
  }
5396
5539
  this._insertChildren();
5540
+ if (!Polymer.Settings.suppressTemplateNotifications || this.notifyDomChange) {
5397
5541
  this.fire('dom-change');
5398
5542
  }
5543
+ }
5399
5544
  });</script>
5400
5545
 
5401
5546
 
@@ -5406,4 +5551,3 @@ this.fire('dom-change');
5406
5551
 
5407
5552
 
5408
5553
 
5409
-