polymer-rails 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d172b9731e66e8ede28d16419e23ed0f333e1a38
4
- data.tar.gz: cf721f1ab30458b086ec02a04ca5ad5ed8d16b22
3
+ metadata.gz: e40e30b7007b492a4b32e84754661b1441b7af1a
4
+ data.tar.gz: 1999c495dddebfa76d167862a416e06119be8278
5
5
  SHA512:
6
- metadata.gz: 8dff092d07bb8de17f252e9351208c1705cbd9fb68902099cc959e071e64b4b4394b4c8dfee710d6e8f6d8a7b082f95e8f25c1f3a9fdffa113a8142c0b59a22b
7
- data.tar.gz: 69eae6d64d6518cab48f65463746c7b04223a998a16811442cdd994e1d995bc2d260a57c73a384bbab6e70b1e6a3e6075b892c0a35e06749fe7ff0e4d812dab1
6
+ metadata.gz: 08f7e97bcac7c8b53ffae4a644f1c6be4784a0b05b175a5dd0686cbe5ec2ed838369e451893ae3e56e221c4a7fa5fb1cd421b210f0c89683916bd595ce7cc679
7
+ data.tar.gz: e93d4fe5e29818b0f6473319fa5e83b62db7f5f7671c64afd41b0907bf5eb89e9f7591b5a39ce4c119fed07850b723f8be904e2c27a3ec48045138a04fb0167b
@@ -125,6 +125,12 @@ this.copyOwnProperty(n, api, prototype);
125
125
  }
126
126
  return prototype || api;
127
127
  },
128
+ mixin: function (target, source) {
129
+ for (var i in source) {
130
+ target[i] = source[i];
131
+ }
132
+ return target;
133
+ },
128
134
  copyOwnProperty: function (name, source, target) {
129
135
  var pd = Object.getOwnPropertyDescriptor(source, name);
130
136
  if (pd) {
@@ -500,7 +506,7 @@ debouncer.stop();
500
506
  }
501
507
  }
502
508
  });
503
- Polymer.version = '1.0.4';
509
+ Polymer.version = '1.0.5';
504
510
  Polymer.Base._addFeature({
505
511
  _registerFeatures: function () {
506
512
  this._prepIs();
@@ -535,8 +535,8 @@ node._ownerShadyRoot = root;
535
535
  return node._ownerShadyRoot;
536
536
  },
537
537
  _maybeDistribute: function (node, parent) {
538
- var fragContent = node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && node.querySelector(CONTENT);
539
- var wrappedContent = fragContent && fragContent.parentNode.nodeType !== Node.DOCUMENT_FRAGMENT_NODE;
538
+ var fragContent = node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && !node.__noContent && Polymer.dom(node).querySelector(CONTENT);
539
+ var wrappedContent = fragContent && Polymer.dom(fragContent).parentNode.nodeType !== Node.DOCUMENT_FRAGMENT_NODE;
540
540
  var hasContent = fragContent || node.localName === CONTENT;
541
541
  if (hasContent) {
542
542
  var root = this._ownerShadyRootForNode(parent);
@@ -598,7 +598,7 @@ if (this._contains(container, content)) {
598
598
  var dc$ = factory(content).getDistributedNodes();
599
599
  for (var j = 0; j < dc$.length; j++) {
600
600
  hostNeedsDist = true;
601
- var node = dc$[i];
601
+ var node = dc$[j];
602
602
  var parent = node.parentNode;
603
603
  if (parent) {
604
604
  removeFromComposedParent(parent, node);
@@ -764,6 +764,9 @@ this.domApi._distributeParent();
764
764
  toggle: function () {
765
765
  this.node.classList.toggle.apply(this.node.classList, arguments);
766
766
  this.domApi._distributeParent();
767
+ },
768
+ contains: function () {
769
+ return this.node.classList.contains.apply(this.node.classList, arguments);
767
770
  }
768
771
  };
769
772
  if (!Settings.useShadow) {
@@ -1050,9 +1053,6 @@ factory: factory
1050
1053
  Polymer.Base._addFeature({
1051
1054
  _prepShady: function () {
1052
1055
  this._useContent = this._useContent || Boolean(this._template);
1053
- if (this._useContent) {
1054
- this._template._hasInsertionPoint = this._template.content.querySelector('content');
1055
- }
1056
1056
  },
1057
1057
  _poolContent: function () {
1058
1058
  if (this._useContent) {
@@ -1072,7 +1072,7 @@ this.shadyRoot = this.root;
1072
1072
  this.shadyRoot._distributionClean = false;
1073
1073
  this.shadyRoot._isShadyRoot = true;
1074
1074
  this.shadyRoot._dirtyRoots = [];
1075
- this.shadyRoot._insertionPoints = this._template._hasInsertionPoint ? this.shadyRoot.querySelectorAll('content') : [];
1075
+ this.shadyRoot._insertionPoints = !this._notes || this._notes._hasContent ? this.shadyRoot.querySelectorAll('content') : [];
1076
1076
  saveLightChildrenIfNeeded(this.shadyRoot);
1077
1077
  this.shadyRoot.host = this;
1078
1078
  },
@@ -54,6 +54,9 @@ var annote = {
54
54
  bindings: [],
55
55
  events: []
56
56
  };
57
+ if (element.localName === 'content') {
58
+ list._hasContent = true;
59
+ }
57
60
  this._parseChildNodesAnnotations(element, annote, list);
58
61
  if (element.attributes) {
59
62
  this._parseNodeAttributeAnnotations(element, annote, list);
@@ -889,50 +892,55 @@ Gestures.setTouchAction(node, DIRECTION_MAP[direction] || 'auto');
889
892
  });
890
893
  Polymer.Gestures = Gestures;
891
894
  }());
892
- Polymer.Async = function () {
893
- var currVal = 0;
894
- var lastVal = 0;
895
- var callbacks = [];
896
- var twiddle = document.createTextNode('');
897
- function runAsync(callback, waitTime) {
895
+ Polymer.Async = {
896
+ _currVal: 0,
897
+ _lastVal: 0,
898
+ _callbacks: [],
899
+ _twiddleContent: 0,
900
+ _twiddle: document.createTextNode(''),
901
+ run: function (callback, waitTime) {
898
902
  if (waitTime > 0) {
899
903
  return ~setTimeout(callback, waitTime);
900
904
  } else {
901
- twiddle.textContent = currVal++;
902
- callbacks.push(callback);
903
- return currVal - 1;
904
- }
905
+ this._twiddle.textContent = this._twiddleContent++;
906
+ this._callbacks.push(callback);
907
+ return this._currVal++;
905
908
  }
906
- function cancelAsync(handle) {
909
+ },
910
+ cancel: function (handle) {
907
911
  if (handle < 0) {
908
912
  clearTimeout(~handle);
909
913
  } else {
910
- var idx = handle - lastVal;
914
+ var idx = handle - this._lastVal;
911
915
  if (idx >= 0) {
912
- if (!callbacks[idx]) {
916
+ if (!this._callbacks[idx]) {
913
917
  throw 'invalid async handle: ' + handle;
914
918
  }
915
- callbacks[idx] = null;
916
- }
919
+ this._callbacks[idx] = null;
917
920
  }
918
921
  }
919
- function atEndOfMicrotask() {
920
- var len = callbacks.length;
922
+ },
923
+ _atEndOfMicrotask: function () {
924
+ var len = this._callbacks.length;
921
925
  for (var i = 0; i < len; i++) {
922
- var cb = callbacks[i];
926
+ var cb = this._callbacks[i];
923
927
  if (cb) {
928
+ try {
924
929
  cb();
930
+ } catch (e) {
931
+ i++;
932
+ this._callbacks.splice(0, i);
933
+ this._lastVal += i;
934
+ this._twiddle.textContent = this._twiddleContent++;
935
+ throw e;
925
936
  }
926
937
  }
927
- callbacks.splice(0, len);
928
- lastVal += len;
929
938
  }
930
- new (window.MutationObserver || JsMutationObserver)(atEndOfMicrotask).observe(twiddle, { characterData: true });
931
- return {
932
- run: runAsync,
933
- cancel: cancelAsync
939
+ this._callbacks.splice(0, len);
940
+ this._lastVal += len;
941
+ }
934
942
  };
935
- }();
943
+ new (window.MutationObserver || JsMutationObserver)(Polymer.Async._atEndOfMicrotask.bind(Polymer.Async)).observe(Polymer.Async._twiddle, { characterData: true });
936
944
  Polymer.Debounce = function () {
937
945
  var Async = Polymer.Async;
938
946
  var Debouncer = function (context) {
@@ -1087,11 +1095,6 @@ elt[n] = props[n];
1087
1095
  }
1088
1096
  }
1089
1097
  return elt;
1090
- },
1091
- mixin: function (target, source) {
1092
- for (var i in source) {
1093
- target[i] = source[i];
1094
- }
1095
1098
  }
1096
1099
  });
1097
1100
  Polymer.Bind = {
@@ -1108,7 +1111,7 @@ _notifyChange: function (property) {
1108
1111
  var eventName = Polymer.CaseMap.camelToDashCase(property) + '-changed';
1109
1112
  this.fire(eventName, { value: this[property] }, { bubbles: false });
1110
1113
  },
1111
- _propertySet: function (property, value, effects) {
1114
+ _propertySetter: function (property, value, effects, fromAbove) {
1112
1115
  var old = this.__data__[property];
1113
1116
  if (old !== value && (old === old || value === value)) {
1114
1117
  this.__data__[property] = value;
@@ -1119,16 +1122,25 @@ if (this._propertyChanged) {
1119
1122
  this._propertyChanged(property, value, old);
1120
1123
  }
1121
1124
  if (effects) {
1122
- this._effectEffects(property, value, effects, old);
1125
+ this._effectEffects(property, value, effects, old, fromAbove);
1123
1126
  }
1124
1127
  }
1125
1128
  return old;
1126
1129
  },
1127
- _effectEffects: function (property, value, effects, old) {
1130
+ __setProperty: function (property, value, quiet, node) {
1131
+ node = node || this;
1132
+ var effects = node._propertyEffects && node._propertyEffects[property];
1133
+ if (effects) {
1134
+ node._propertySetter(property, value, effects, quiet);
1135
+ } else {
1136
+ node[property] = value;
1137
+ }
1138
+ },
1139
+ _effectEffects: function (property, value, effects, old, fromAbove) {
1128
1140
  effects.forEach(function (fx) {
1129
1141
  var fn = Polymer.Bind['_' + fx.kind + 'Effect'];
1130
1142
  if (fn) {
1131
- fn.call(this, property, value, fx.effect, old);
1143
+ fn.call(this, property, value, fx.effect, old, fromAbove);
1132
1144
  }
1133
1145
  }, this);
1134
1146
  },
@@ -1186,7 +1198,7 @@ return this.__data__[property];
1186
1198
  }
1187
1199
  };
1188
1200
  var setter = function (value) {
1189
- this._propertySet(property, value, effects);
1201
+ this._propertySetter(property, value, effects);
1190
1202
  };
1191
1203
  if (model.getPropertyInfo && model.getPropertyInfo(property).readOnly) {
1192
1204
  model['_set' + this.upper(property)] = setter;
@@ -1260,11 +1272,13 @@ return this._applyEffectValue(calc, effect);
1260
1272
  _reflectEffect: function (source) {
1261
1273
  this.reflectPropertyToAttribute(source);
1262
1274
  },
1263
- _notifyEffect: function (source) {
1275
+ _notifyEffect: function (source, value, effect, old, fromAbove) {
1276
+ if (!fromAbove) {
1264
1277
  this._notifyChange(source);
1278
+ }
1265
1279
  },
1266
- _functionEffect: function (source, value, fn, old) {
1267
- fn.call(this, source, value, old);
1280
+ _functionEffect: function (source, value, fn, old, fromAbove) {
1281
+ fn.call(this, source, value, old, fromAbove);
1268
1282
  },
1269
1283
  _observerEffect: function (source, value, effect, old) {
1270
1284
  var fn = this[effect.method];
@@ -1290,7 +1304,7 @@ var args = Polymer.Bind._marshalArgs(this.__data__, effect, source, value);
1290
1304
  if (args) {
1291
1305
  var fn = this[effect.method];
1292
1306
  if (fn) {
1293
- this[effect.property] = fn.apply(this, args);
1307
+ this.__setProperty(effect.property, fn.apply(this, args));
1294
1308
  } else {
1295
1309
  this._warn(this._logf('_computeEffect', 'compute method `' + effect.method + '` not defined'));
1296
1310
  }
@@ -1363,6 +1377,7 @@ if (prop.observer) {
1363
1377
  this._addObserverEffect(p, prop.observer);
1364
1378
  }
1365
1379
  if (prop.computed) {
1380
+ prop.readOnly = true;
1366
1381
  this._addComputedEffect(p, prop.computed);
1367
1382
  }
1368
1383
  if (prop.notify) {
@@ -1553,12 +1568,13 @@ this._configure();
1553
1568
  },
1554
1569
  _configure: function () {
1555
1570
  this._configureAnnotationReferences();
1571
+ this._aboveConfig = this.mixin({}, this._config);
1556
1572
  var config = {};
1557
1573
  this.behaviors.forEach(function (b) {
1558
1574
  this._configureProperties(b.properties, config);
1559
1575
  }, this);
1560
1576
  this._configureProperties(this.properties, config);
1561
- this._mixinConfigure(config, this._config);
1577
+ this._mixinConfigure(config, this._aboveConfig);
1562
1578
  this._config = config;
1563
1579
  this._distributeConfig(this._config);
1564
1580
  },
@@ -1602,18 +1618,13 @@ node._configValue(x.effect.name, value);
1602
1618
  },
1603
1619
  _afterClientsReady: function () {
1604
1620
  this._executeStaticEffects();
1605
- this._applyConfig(this._config);
1621
+ this._applyConfig(this._config, this._aboveConfig);
1606
1622
  this._flushHandlers();
1607
1623
  },
1608
- _applyConfig: function (config) {
1624
+ _applyConfig: function (config, aboveConfig) {
1609
1625
  for (var n in config) {
1610
1626
  if (this[n] === undefined) {
1611
- var effects = this._propertyEffects[n];
1612
- if (effects) {
1613
- this._propertySet(n, config[n], effects);
1614
- } else {
1615
- this[n] = config[n];
1616
- }
1627
+ this.__setProperty(n, config[n], n in aboveConfig);
1617
1628
  }
1618
1629
  }
1619
1630
  },
@@ -1642,7 +1653,7 @@ h[0].call(this, h[1], h[2]);
1642
1653
  'use strict';
1643
1654
  Polymer.Base._addFeature({
1644
1655
  notifyPath: function (path, value, fromAbove) {
1645
- var old = this._propertySet(path, value);
1656
+ var old = this._propertySetter(path, value);
1646
1657
  if (old !== value && (old === old || value === value)) {
1647
1658
  this._pathEffector(path, value);
1648
1659
  if (!fromAbove) {
@@ -1680,6 +1691,15 @@ return;
1680
1691
  }
1681
1692
  array = Array.isArray(prop) ? prop : null;
1682
1693
  }
1694
+ if (array) {
1695
+ var coll = Polymer.Collection.get(array);
1696
+ var old = prop[last];
1697
+ var key = coll.getKey(old);
1698
+ if (key) {
1699
+ parts[i] = key;
1700
+ coll.setItem(key, value);
1701
+ }
1702
+ }
1683
1703
  prop[last] = value;
1684
1704
  if (!root) {
1685
1705
  this.notifyPath(parts.join('.'), value);
@@ -1833,9 +1853,8 @@ return ret;
1833
1853
  splice: function (path, start, deleteCount) {
1834
1854
  var array = this.get(path);
1835
1855
  var args = Array.prototype.slice.call(arguments, 1);
1836
- var rem = array.slice(start, start + deleteCount);
1837
1856
  var ret = array.splice.apply(array, args);
1838
- this._notifySplice(array, path, start, args.length - 2, rem);
1857
+ this._notifySplice(array, path, start, args.length - 2, ret);
1839
1858
  return ret;
1840
1859
  },
1841
1860
  shift: function (path) {
@@ -1983,10 +2002,10 @@ var AT_START = '@';
1983
2002
  var rx = {
1984
2003
  comments: /\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim,
1985
2004
  port: /@import[^;]*;/gim,
1986
- customProp: /(?:^|[\s;])--[^;{]*?:[^{};]*?;/gim,
1987
- mixinProp: /(?:^|[\s;])--[^;{]*?:[^{;]*?{[^}]*?};?/gim,
1988
- mixinApply: /@apply[\s]*\([^)]*?\)[\s]*;/gim,
1989
- varApply: /[^;:]*?:[^;]*var[^;]*;/gim,
2005
+ customProp: /(?:^|[\s;])--[^;{]*?:[^{};]*?(?:[;\n]|$)/gim,
2006
+ mixinProp: /(?:^|[\s;])--[^;{]*?:[^{;]*?{[^}]*?}(?:[;\n]|$)?/gim,
2007
+ mixinApply: /@apply[\s]*\([^)]*?\)[\s]*(?:[;\n]|$)?/gim,
2008
+ varApply: /[^;:]*?:[^;]*var[^;]*(?:[;\n]|$)?/gim,
1990
2009
  keyframesRule: /^@[^\s]*keyframes/
1991
2010
  };
1992
2011
  return api;
@@ -2162,25 +2181,33 @@ rule.selector = p$.join(COMPLEX_SELECTOR_SEP);
2162
2181
  },
2163
2182
  _transformComplexSelector: function (selector, scope, hostScope) {
2164
2183
  var stop = false;
2184
+ var hostContext = false;
2165
2185
  var self = this;
2166
2186
  selector = selector.replace(SIMPLE_SELECTOR_SEP, function (m, c, s) {
2167
2187
  if (!stop) {
2168
- var o = self._transformCompoundSelector(s, c, scope, hostScope);
2169
- if (o.stop) {
2170
- stop = true;
2171
- }
2172
- c = o.combinator;
2173
- s = o.value;
2188
+ var info = self._transformCompoundSelector(s, c, scope, hostScope);
2189
+ stop = stop || info.stop;
2190
+ hostContext = hostContext || info.hostContext;
2191
+ c = info.combinator;
2192
+ s = info.value;
2174
2193
  } else {
2175
2194
  s = s.replace(SCOPE_JUMP, ' ');
2176
2195
  }
2177
2196
  return c + s;
2178
2197
  });
2198
+ if (hostContext) {
2199
+ selector = selector.replace(HOST_CONTEXT_PAREN, function (m, pre, paren, post) {
2200
+ return pre + paren + ' ' + hostScope + post + COMPLEX_SELECTOR_SEP + ' ' + pre + hostScope + paren + post;
2201
+ });
2202
+ }
2179
2203
  return selector;
2180
2204
  },
2181
2205
  _transformCompoundSelector: function (selector, combinator, scope, hostScope) {
2182
2206
  var jumpIndex = selector.search(SCOPE_JUMP);
2183
- if (selector.indexOf(HOST) >= 0) {
2207
+ var hostContext = false;
2208
+ if (selector.indexOf(HOST_CONTEXT) >= 0) {
2209
+ hostContext = true;
2210
+ } else if (selector.indexOf(HOST) >= 0) {
2184
2211
  selector = selector.replace(HOST_PAREN, function (m, host, paren) {
2185
2212
  return hostScope + paren;
2186
2213
  });
@@ -2199,7 +2226,8 @@ stop = true;
2199
2226
  return {
2200
2227
  value: selector,
2201
2228
  combinator: combinator,
2202
- stop: stop
2229
+ stop: stop,
2230
+ hostContext: hostContext
2203
2231
  };
2204
2232
  },
2205
2233
  _transformSimpleSelector: function (selector, scope) {
@@ -2231,6 +2259,8 @@ var SIMPLE_SELECTOR_SEP = /(^|[\s>+~]+)([^\s>+~]+)/g;
2231
2259
  var HOST = ':host';
2232
2260
  var ROOT = ':root';
2233
2261
  var HOST_PAREN = /(\:host)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))/g;
2262
+ var HOST_CONTEXT = ':host-context';
2263
+ var HOST_CONTEXT_PAREN = /(.*)(?:\:host-context)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))(.*)/;
2234
2264
  var CONTENT = '::content';
2235
2265
  var SCOPE_JUMP = /\:\:content|\:\:shadow|\/deep\//;
2236
2266
  var CSS_CLASS_PREFIX = '.';
@@ -2611,7 +2641,7 @@ var cssText = style ? style.textContent || '' : this.transformStyles(element, pr
2611
2641
  var s = element._customStyle;
2612
2642
  if (s && !nativeShadow && s !== style) {
2613
2643
  s._useCount--;
2614
- if (s._useCount <= 0) {
2644
+ if (s._useCount <= 0 && s.parentNode) {
2615
2645
  s.parentNode.removeChild(s);
2616
2646
  }
2617
2647
  }
@@ -2632,14 +2662,23 @@ element._customStyle = style;
2632
2662
  }
2633
2663
  return style;
2634
2664
  },
2665
+ mixinCustomStyle: function (props, customStyle) {
2666
+ var v;
2667
+ for (var i in customStyle) {
2668
+ v = customStyle[i];
2669
+ if (v || v === 0) {
2670
+ props[i] = v;
2671
+ }
2672
+ }
2673
+ },
2635
2674
  rx: {
2636
- VAR_ASSIGN: /(?:^|;\s*)(--[^\:;]*?):\s*?(?:([^;{]*?)|{([^}]*)})(?=;)/gim,
2637
- MIXIN_MATCH: /(?:^|\W+)@apply[\s]*\(([^)]*)\);?/im,
2675
+ VAR_ASSIGN: /(?:^|[;\n]\s*)(--[\w-]*?):\s*?(?:([^;{]*?)|{([^}]*)})(?:(?=[;\n])|$)/gim,
2676
+ MIXIN_MATCH: /(?:^|\W+)@apply[\s]*\(([^)]*)\)/im,
2638
2677
  VAR_MATCH: /(^|\W+)var\([\s]*([^,)]*)[\s]*,?[\s]*((?:[^,)]*)|(?:[^;]*\([^;)]*\)))[\s]*?\)/gim,
2639
2678
  VAR_CAPTURE: /\([\s]*(--[^,\s)]*)(?:,[\s]*(--[^,\s)]*))?(?:\)|,)/gim,
2640
2679
  IS_VAR: /^--/,
2641
2680
  BRACKETED: /\{[^}]*\}/g,
2642
- HOST_PREFIX: '(?:^|[^.])',
2681
+ HOST_PREFIX: '(?:^|[^.#[:])',
2643
2682
  HOST_SUFFIX: '($|[.:[\\s>+~])'
2644
2683
  },
2645
2684
  HOST_SELECTORS: [':host'],
@@ -2652,41 +2691,6 @@ var v = 1 << n % 32;
2652
2691
  bits[o] = (bits[o] || 0) | v;
2653
2692
  }
2654
2693
  }();
2655
- Polymer.StyleDefaults = function () {
2656
- var styleProperties = Polymer.StyleProperties;
2657
- var styleUtil = Polymer.StyleUtil;
2658
- var api = {
2659
- _styles: [],
2660
- _properties: null,
2661
- addStyle: function (style) {
2662
- this._styles.push(style);
2663
- this._properties = null;
2664
- },
2665
- get _styleProperties() {
2666
- if (!this._properties) {
2667
- styleProperties.decorateStyles(this._styles);
2668
- this._styles._scopeStyleProperties = null;
2669
- this._properties = styleProperties.scopePropertiesFromStyles(this._styles);
2670
- styleProperties.reify(this._properties);
2671
- }
2672
- return this._properties;
2673
- },
2674
- _needsStyleProperties: function () {
2675
- },
2676
- _computeStyleProperties: function () {
2677
- return this._styleProperties;
2678
- },
2679
- updateStyles: function () {
2680
- this._styleCache.clear();
2681
- for (var i = 0, s; i < this._styles.length; i++) {
2682
- s = this._styles[i];
2683
- s = s.__importElement || s;
2684
- s._apply();
2685
- }
2686
- }
2687
- };
2688
- return api;
2689
- }();
2690
2694
  (function () {
2691
2695
  Polymer.StyleCache = function () {
2692
2696
  this.cache = {};
@@ -2717,8 +2721,10 @@ clear: function () {
2717
2721
  this.cache = {};
2718
2722
  },
2719
2723
  _objectsEqual: function (target, source) {
2724
+ var t, s;
2720
2725
  for (var i in target) {
2721
- if (target[i] !== source[i]) {
2726
+ t = target[i], s = source[i];
2727
+ if (!(typeof t === 'object' && t ? this._objectsStrictlyEqual(t, s) : t === s)) {
2722
2728
  return false;
2723
2729
  }
2724
2730
  }
@@ -2726,9 +2732,55 @@ if (Array.isArray(target)) {
2726
2732
  return target.length === source.length;
2727
2733
  }
2728
2734
  return true;
2735
+ },
2736
+ _objectsStrictlyEqual: function (target, source) {
2737
+ return this._objectsEqual(target, source) && this._objectsEqual(source, target);
2729
2738
  }
2730
2739
  };
2731
2740
  }());
2741
+ Polymer.StyleDefaults = function () {
2742
+ var styleProperties = Polymer.StyleProperties;
2743
+ var styleUtil = Polymer.StyleUtil;
2744
+ var StyleCache = Polymer.StyleCache;
2745
+ var api = {
2746
+ _styles: [],
2747
+ _properties: null,
2748
+ customStyle: {},
2749
+ _styleCache: new StyleCache(),
2750
+ addStyle: function (style) {
2751
+ this._styles.push(style);
2752
+ this._properties = null;
2753
+ },
2754
+ get _styleProperties() {
2755
+ if (!this._properties) {
2756
+ styleProperties.decorateStyles(this._styles);
2757
+ this._styles._scopeStyleProperties = null;
2758
+ this._properties = styleProperties.scopePropertiesFromStyles(this._styles);
2759
+ styleProperties.mixinCustomStyle(this._properties, this.customStyle);
2760
+ styleProperties.reify(this._properties);
2761
+ }
2762
+ return this._properties;
2763
+ },
2764
+ _needsStyleProperties: function () {
2765
+ },
2766
+ _computeStyleProperties: function () {
2767
+ return this._styleProperties;
2768
+ },
2769
+ updateStyles: function (properties) {
2770
+ this._properties = null;
2771
+ if (properties) {
2772
+ Polymer.Base.mixin(this.customStyle, properties);
2773
+ }
2774
+ this._styleCache.clear();
2775
+ for (var i = 0, s; i < this._styles.length; i++) {
2776
+ s = this._styles[i];
2777
+ s = s.__importElement || s;
2778
+ s._apply();
2779
+ }
2780
+ }
2781
+ };
2782
+ return api;
2783
+ }();
2732
2784
  (function () {
2733
2785
  'use strict';
2734
2786
  var serializeValueToAttribute = Polymer.Base.serializeValueToAttribute;
@@ -2758,6 +2810,7 @@ if (!scope._styleCache) {
2758
2810
  scope._styleCache = new Polymer.StyleCache();
2759
2811
  }
2760
2812
  var scopeData = propertyUtils.propertyDataFromStyles(scope._styles, this);
2813
+ scopeData.key.customStyle = this.customStyle;
2761
2814
  info = scope._styleCache.retrieve(this.is, scopeData.key, this._styles);
2762
2815
  var scopeCached = Boolean(info);
2763
2816
  if (scopeCached) {
@@ -2772,15 +2825,14 @@ info = styleCache.retrieve(this.is, this._ownStyleProperties, this._styles);
2772
2825
  var globalCached = Boolean(info) && !scopeCached;
2773
2826
  var style = this._applyStyleProperties(info);
2774
2827
  if (!scopeCached) {
2775
- var cacheableStyle = style;
2776
- if (nativeShadow) {
2777
- cacheableStyle = style.cloneNode ? style.cloneNode(true) : Object.create(style || null);
2778
- }
2828
+ style = style && nativeShadow ? style.cloneNode(true) : style;
2779
2829
  info = {
2780
- style: cacheableStyle,
2830
+ style: style,
2781
2831
  _scopeSelector: this._scopeSelector,
2782
2832
  _styleProperties: this._styleProperties
2783
2833
  };
2834
+ scopeData.key.customStyle = {};
2835
+ this.mixin(scopeData.key.customStyle, this.customStyle);
2784
2836
  scope._styleCache.store(this.is, info, scopeData.key, this._styles);
2785
2837
  if (!globalCached) {
2786
2838
  styleCache.store(this.is, Object.create(info), this._ownStyleProperties, this._styles);
@@ -2797,7 +2849,7 @@ this.mixin(props, propertyUtils.hostPropertiesFromStyles(this._styles));
2797
2849
  scopeProps = scopeProps || propertyUtils.propertyDataFromStyles(scope._styles, this).properties;
2798
2850
  this.mixin(props, scopeProps);
2799
2851
  this.mixin(props, propertyUtils.scopePropertiesFromStyles(this._styles));
2800
- this.mixin(props, this.customStyle);
2852
+ propertyUtils.mixinCustomStyle(props, this.customStyle);
2801
2853
  propertyUtils.reify(props);
2802
2854
  this._styleProperties = props;
2803
2855
  },
@@ -2814,10 +2866,10 @@ _applyStyleProperties: function (info) {
2814
2866
  var oldScopeSelector = this._scopeSelector;
2815
2867
  this._scopeSelector = info ? info._scopeSelector : this.is + '-' + this.__proto__._scopeCount++;
2816
2868
  var style = propertyUtils.applyElementStyle(this, this._styleProperties, this._scopeSelector, info && info.style);
2817
- if ((style || oldScopeSelector) && !nativeShadow) {
2869
+ if (!nativeShadow) {
2818
2870
  propertyUtils.applyElementScopeSelector(this, this._scopeSelector, oldScopeSelector, this._scopeCssViaAttr);
2819
2871
  }
2820
- return style || {};
2872
+ return style;
2821
2873
  },
2822
2874
  serializeValueToAttribute: function (value, attribute, node) {
2823
2875
  node = node || this;
@@ -2836,8 +2888,11 @@ selector += (selector ? ' ' : '') + SCOPE_NAME + ' ' + this.is + (element._scope
2836
2888
  }
2837
2889
  return selector;
2838
2890
  },
2839
- updateStyles: function () {
2891
+ updateStyles: function (properties) {
2840
2892
  if (this.isAttached) {
2893
+ if (properties) {
2894
+ this.mixin(this.customStyle, properties);
2895
+ }
2841
2896
  if (this._needsStyleProperties()) {
2842
2897
  this._updateStyleProperties();
2843
2898
  } else {
@@ -2861,8 +2916,8 @@ c.updateStyles();
2861
2916
  }
2862
2917
  }
2863
2918
  });
2864
- Polymer.updateStyles = function () {
2865
- styleDefaults.updateStyles();
2919
+ Polymer.updateStyles = function (properties) {
2920
+ styleDefaults.updateStyles(properties);
2866
2921
  Polymer.Base._updateRootStyles(document);
2867
2922
  };
2868
2923
  var styleCache = new Polymer.StyleCache();
@@ -3023,6 +3078,9 @@ var parentProps = archetype._parentProps;
3023
3078
  for (var prop in parentProps) {
3024
3079
  archetype._addPropertyEffect(prop, 'function', this._createHostPropEffector(prop));
3025
3080
  }
3081
+ for (var prop in this._instanceProps) {
3082
+ archetype._addPropertyEffect(prop, 'function', this._createInstancePropEffector(prop));
3083
+ }
3026
3084
  },
3027
3085
  _customPrepAnnotations: function (archetype, template) {
3028
3086
  archetype._template = template;
@@ -3081,18 +3139,27 @@ return function (source, value) {
3081
3139
  this.dataHost['_parent_' + prop] = value;
3082
3140
  };
3083
3141
  },
3142
+ _createInstancePropEffector: function (prop) {
3143
+ return function (source, value, old, fromAbove) {
3144
+ if (!fromAbove) {
3145
+ this.dataHost._forwardInstanceProp(this, prop, value);
3146
+ }
3147
+ };
3148
+ },
3084
3149
  _extendTemplate: function (template, proto) {
3085
3150
  Object.getOwnPropertyNames(proto).forEach(function (n) {
3086
3151
  var val = template[n];
3087
3152
  var pd = Object.getOwnPropertyDescriptor(proto, n);
3088
3153
  Object.defineProperty(template, n, pd);
3089
3154
  if (val !== undefined) {
3090
- template._propertySet(n, val);
3155
+ template._propertySetter(n, val);
3091
3156
  }
3092
3157
  });
3093
3158
  },
3094
3159
  _forwardInstancePath: function (inst, path, value) {
3095
3160
  },
3161
+ _forwardInstanceProp: function (inst, prop, value) {
3162
+ },
3096
3163
  _notifyPathImpl: function (path, value) {
3097
3164
  var dataHost = this.dataHost;
3098
3165
  var dot = path.indexOf('.');
@@ -3115,6 +3182,7 @@ this._rootDataHost = host._getRootDataHost();
3115
3182
  this._setupConfigure(model);
3116
3183
  this._pushHost(host);
3117
3184
  this.root = this.instanceTemplate(this._template);
3185
+ this.root.__noContent = !this._notes._hasContent;
3118
3186
  this.root.__styleScoped = true;
3119
3187
  this._popHost();
3120
3188
  this._marshalAnnotatedNodes();
@@ -3219,8 +3287,17 @@ return this.pmap[item];
3219
3287
  getKeys: function () {
3220
3288
  return Object.keys(this.store);
3221
3289
  },
3222
- setItem: function (key, value) {
3223
- this.store[key] = value;
3290
+ setItem: function (key, item) {
3291
+ var old = this.store[key];
3292
+ if (old) {
3293
+ this._removeFromMap(old);
3294
+ }
3295
+ if (item && typeof item == 'object') {
3296
+ this.omap.set(item, key);
3297
+ } else {
3298
+ this.pmap[item] = key;
3299
+ }
3300
+ this.store[key] = item;
3224
3301
  },
3225
3302
  getItem: function (key) {
3226
3303
  return this.store[key];
@@ -3382,7 +3459,7 @@ return;
3382
3459
  },
3383
3460
  render: function () {
3384
3461
  this._fullRefresh = true;
3385
- this.debounce('render', this._render);
3462
+ this._debounceTemplate(this._render);
3386
3463
  this._flushTemplates();
3387
3464
  },
3388
3465
  _render: function () {
@@ -3414,9 +3491,9 @@ rowForKey[key] = i;
3414
3491
  if (!row) {
3415
3492
  this.rows.push(row = this._insertRow(i, null, item));
3416
3493
  }
3417
- row[this.as] = item;
3418
- row.__key__ = key;
3419
- row[this.indexAs] = i;
3494
+ row.__setProperty(this.as, item, true);
3495
+ row.__setProperty('__key__', key, true);
3496
+ row.__setProperty(this.indexAs, i, true);
3420
3497
  }
3421
3498
  for (; i < this.rows.length; i++) {
3422
3499
  this._detachRow(i);
@@ -3581,16 +3658,26 @@ c._hideTemplateChildren = hidden;
3581
3658
  }
3582
3659
  }
3583
3660
  },
3661
+ _forwardInstanceProp: function (row, prop, value) {
3662
+ if (prop == this.as) {
3663
+ var idx;
3664
+ if (this._sortFn || this._filterFn) {
3665
+ idx = this.items.indexOf(this.collection.getItem(row.__key__));
3666
+ } else {
3667
+ idx = row[this.indexAs];
3668
+ }
3669
+ this.set('items.' + idx, value);
3670
+ }
3671
+ },
3584
3672
  _forwardInstancePath: function (row, path, value) {
3585
3673
  if (path.indexOf(this.as + '.') === 0) {
3586
3674
  this.notifyPath('items.' + row.__key__ + '.' + path.slice(this.as.length + 1), value);
3587
- return true;
3588
3675
  }
3589
3676
  },
3590
3677
  _forwardParentProp: function (prop, value) {
3591
3678
  if (this.rows) {
3592
3679
  this.rows.forEach(function (row) {
3593
- row[prop] = value;
3680
+ row.__setProperty(prop, value, true);
3594
3681
  }, this);
3595
3682
  }
3596
3683
  },
@@ -3612,7 +3699,7 @@ if (dot >= 0) {
3612
3699
  path = this.as + '.' + path.substring(dot + 1);
3613
3700
  row.notifyPath(path, value, true);
3614
3701
  } else {
3615
- row[this.as] = value;
3702
+ row.__setProperty(this.as, value, true);
3616
3703
  }
3617
3704
  }
3618
3705
  }
@@ -3720,15 +3807,16 @@ extends: 'template',
3720
3807
  properties: {
3721
3808
  'if': {
3722
3809
  type: Boolean,
3723
- value: false
3810
+ value: false,
3811
+ observer: '_queueRender'
3724
3812
  },
3725
3813
  restamp: {
3726
3814
  type: Boolean,
3727
- value: false
3815
+ value: false,
3816
+ observer: '_queueRender'
3728
3817
  }
3729
3818
  },
3730
3819
  behaviors: [Polymer.Templatizer],
3731
- observers: ['_queueRender(if, restamp)'],
3732
3820
  _queueRender: function () {
3733
3821
  this._debounceTemplate(this._render);
3734
3822
  },
@@ -1,5 +1,5 @@
1
1
  module Polymer
2
2
  module Rails
3
- VERSION = "1.0.4"
3
+ VERSION = "1.0.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polymer-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Chaplinsky