tao_on_rails 0.5.3 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b26d706bce178808560079b9a49cf74f9d02edda
4
- data.tar.gz: f4a587651da8c33d9f91d6d4bce10716e2033f65
3
+ metadata.gz: de9e1c635c69c821689bd1fa77d5a10c09488d7b
4
+ data.tar.gz: 87d215ee8c1b4ddfddae9dbd945e65fa45d4a303
5
5
  SHA512:
6
- metadata.gz: 377902a5aa7a3e1a4cfafe8018068ef8d6a1a677fceb2f72bd52c75aec744f90e990a63242cb2e9c7f748473668d1854296dce5fd57c0da5a2ce9ec50f3961e6
7
- data.tar.gz: 77544f7194501a644404642de1c6ddbb4d74f5a120af18e46821f74814fcd95f23e11b314a454ebbc01d33899834b0c6e432bea15fc7f6bfc857a1a96ebf8e23
6
+ metadata.gz: a35b1d83c05900ea8b717d87a0cad18cfb2f4e3278a48d04d3fdabf6758b92d79751bc36fa3eadd0b61e46c990bb4cc5d97db68db817c7c87b4fabb8f4f6feeb
7
+ data.tar.gz: 1dec9b9db604fad8bbf1838acfbb0de072c8a5e2618c31ad8d1e5d1fffd3cebbc07ca76b745c1513a9336e9e74b3db6000f16f0a524945858e11f947972d4d6a
data/.DS_Store ADDED
Binary file
data/dist/tao.js CHANGED
@@ -27924,8 +27924,8 @@ return jQuery;
27924
27924
  var ref;
27925
27925
  _this.trigger('before-page-cache', [_this.currentPage]);
27926
27926
  if ((ref = _this.currentPage) != null) {
27927
- if (typeof ref.prepareCache === "function") {
27928
- ref.prepareCache();
27927
+ if (typeof ref.beforeCache === "function") {
27928
+ ref.beforeCache();
27929
27929
  }
27930
27930
  }
27931
27931
  return window.currentPage = _this.currentPage = null;
@@ -29974,17 +29974,15 @@ var Deferred = void 0;
29974
29974
  (function () {
29975
29975
  'use strict';
29976
29976
 
29977
- var doc = document;
29978
- var win = window;
29979
-
29980
29977
  /**
29981
29978
  * Gets 'customElement' from window so that it could be modified after
29982
29979
  * the polyfill loads.
29983
29980
  * @function
29984
29981
  * @return {CustomElementRegistry}
29985
29982
  */
29983
+
29986
29984
  var _customElements = function _customElements() {
29987
- return win['customElements'];
29985
+ return window['customElements'];
29988
29986
  };
29989
29987
 
29990
29988
  var _observerProp = '__$CE_observer';
@@ -30025,7 +30023,7 @@ var Deferred = void 0;
30025
30023
  // IE 11 requires the third and fourth arguments be present. If the third
30026
30024
  // arg is null, it applies the default behaviour. However IE also requires
30027
30025
  // the fourth argument be present even though the other browsers ignore it.
30028
- return doc.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, null, false);
30026
+ return document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, null, false);
30029
30027
  }
30030
30028
 
30031
30029
  /**
@@ -30303,9 +30301,9 @@ var Deferred = void 0;
30303
30301
  var onReady = function onReady() {
30304
30302
  _this2._upgradeScheduled = false;
30305
30303
  if (!_this2._mainDocumentObserver) {
30306
- _this2._mainDocumentObserver = _this2._observeRoot(doc);
30304
+ _this2._mainDocumentObserver = _this2._observeRoot(document);
30307
30305
  }
30308
- _this2._addNodes(doc.childNodes);
30306
+ _this2._addNodes(document.childNodes);
30309
30307
  };
30310
30308
  if (window['HTMLImports']) {
30311
30309
  window['HTMLImports']['whenReady'](onReady);
@@ -30641,7 +30639,7 @@ var Deferred = void 0;
30641
30639
  // patch window.HTMLElement
30642
30640
 
30643
30641
  /** @const */
30644
- var origHTMLElement = win.HTMLElement;
30642
+ var origHTMLElement = window.HTMLElement;
30645
30643
  CustomElementRegistry.prototype['nativeHTMLElement'] = origHTMLElement;
30646
30644
  /**
30647
30645
  * @type {function(new: HTMLElement)}
@@ -30658,21 +30656,24 @@ var Deferred = void 0;
30658
30656
  if (this.constructor) {
30659
30657
  // Find the tagname of the constructor and create a new element with it
30660
30658
  var tagName = customElements._constructors.get(this.constructor);
30661
- return _createElement(doc, tagName, undefined, false);
30659
+ return _createElement(document, tagName, undefined, false);
30662
30660
  }
30663
30661
  throw new Error('Unknown constructor. Did you call customElements.define()?');
30664
30662
  };
30665
- win.HTMLElement = newHTMLElement;
30666
- win.HTMLElement.prototype = Object.create(origHTMLElement.prototype, {
30667
- constructor: { value: win.HTMLElement, configurable: true, writable: true }
30668
- });
30663
+ window.HTMLElement = newHTMLElement;
30664
+ // By setting the patched HTMLElement's prototype property to the native
30665
+ // HTMLElement's prototype we make sure that:
30666
+ // document.createElement('a') instanceof HTMLElement
30667
+ // works because instanceof uses HTMLElement.prototype, which is on the
30668
+ // ptototype chain of built-in elements.
30669
+ window.HTMLElement.prototype = origHTMLElement.prototype;
30669
30670
 
30670
30671
  // patch doc.createElement
30671
30672
  // TODO(justinfagnani): why is the cast neccessary?
30672
30673
  // Can we fix the Closure DOM externs?
30673
- var _origCreateElement =
30674
+ var _nativeCreateElement =
30674
30675
  /** @type {function(this:Document, string, (Object|undefined)=): !HTMLElement}}*/
30675
- doc.createElement;
30676
+ document.createElement;
30676
30677
 
30677
30678
  /**
30678
30679
  * Creates a new element and upgrades it if it's a custom element.
@@ -30686,7 +30687,7 @@ var Deferred = void 0;
30686
30687
  */
30687
30688
  function _createElement(doc, tagName, options, callConstructor) {
30688
30689
  var customElements = _customElements();
30689
- var element = options ? _origCreateElement.call(doc, tagName, options) : _origCreateElement.call(doc, tagName);
30690
+ var element = options ? _nativeCreateElement.call(doc, tagName, options) : _nativeCreateElement.call(doc, tagName);
30690
30691
  var definition = customElements._definitions.get(tagName.toLowerCase());
30691
30692
  if (definition) {
30692
30693
  customElements._upgradeElement(element, definition, callConstructor);
@@ -30694,35 +30695,35 @@ var Deferred = void 0;
30694
30695
  customElements._observeRoot(element);
30695
30696
  return element;
30696
30697
  };
30697
- doc.createElement = function (tagName, options) {
30698
- return _createElement(doc, tagName, options, true);
30698
+ document.createElement = function (tagName, options) {
30699
+ return _createElement(document, tagName, options, true);
30699
30700
  };
30700
30701
 
30701
- // patch doc.createElementNS
30702
+ // patch document.createElementNS
30702
30703
 
30703
30704
  var HTMLNS = 'http://www.w3.org/1999/xhtml';
30704
30705
 
30705
30706
  /** @type {function(this:Document,string,string):Element} */
30706
- var _origCreateElementNS = doc.createElementNS;
30707
- doc.createElementNS =
30707
+ var _nativeCreateElementNS = document.createElementNS;
30708
+ document.createElementNS =
30708
30709
  /** @type {function(this:Document,(string|null),string):!Element} */
30709
30710
  function (namespaceURI, qualifiedName) {
30710
- if (namespaceURI === 'http://www.w3.org/1999/xhtml') {
30711
- return doc.createElement(qualifiedName);
30711
+ if (namespaceURI === HTMLNS) {
30712
+ return document.createElement(qualifiedName);
30712
30713
  } else {
30713
- return _origCreateElementNS.call(doc, namespaceURI, qualifiedName);
30714
+ return _nativeCreateElementNS.call(document, namespaceURI, qualifiedName);
30714
30715
  }
30715
30716
  };
30716
30717
 
30717
30718
  // patch Element.attachShadow
30718
30719
 
30719
30720
  /** @type {function({closed: boolean})} */
30720
- var _origAttachShadow = Element.prototype['attachShadow'];
30721
- if (_origAttachShadow) {
30721
+ var _nativeAttachShadow = Element.prototype['attachShadow'];
30722
+ if (_nativeAttachShadow) {
30722
30723
  Object.defineProperty(Element.prototype, 'attachShadow', {
30723
30724
  value: function value(options) {
30724
30725
  /** @type {!Node} */
30725
- var root = _origAttachShadow.call(this, options);
30726
+ var root = _nativeAttachShadow.call(this, options);
30726
30727
  /** @type {CustomElementRegistry} */
30727
30728
  var customElements = _customElements();
30728
30729
  customElements._observeRoot(root);
@@ -30731,11 +30732,11 @@ var Deferred = void 0;
30731
30732
  });
30732
30733
  }
30733
30734
 
30734
- // patch doc.importNode
30735
+ // patch document.importNode
30735
30736
 
30736
- var rawImportNode = doc.importNode;
30737
- doc.importNode = function (node, deep) {
30738
- var clone = /** @type{!Node} */rawImportNode.call(doc, node, deep);
30737
+ var _nativeImportNode = document.importNode;
30738
+ document.importNode = function (node, deep) {
30739
+ var clone = /** @type{!Node} */_nativeImportNode.call(document, node, deep);
30739
30740
  var customElements = _customElements();
30740
30741
  var nodes = isElement(clone) ? [clone] : clone.childNodes;
30741
30742
  /** @type {CustomElementRegistry} */_customElements()._addNodes(nodes);
@@ -30744,13 +30745,13 @@ var Deferred = void 0;
30744
30745
 
30745
30746
  // patch Element.setAttribute & removeAttribute
30746
30747
 
30747
- var _origSetAttribute = Element.prototype.setAttribute;
30748
+ var _nativeSetAttribute = Element.prototype.setAttribute;
30748
30749
  Element.prototype['setAttribute'] = function (name, value) {
30749
- changeAttribute(this, name, value, _origSetAttribute);
30750
+ changeAttribute(this, name, value, _nativeSetAttribute);
30750
30751
  };
30751
- var _origRemoveAttribute = Element.prototype.removeAttribute;
30752
+ var _nativeRemoveAttribute = Element.prototype.removeAttribute;
30752
30753
  Element.prototype['removeAttribute'] = function (name) {
30753
- changeAttribute(this, name, null, _origRemoveAttribute);
30754
+ changeAttribute(this, name, null, _nativeRemoveAttribute);
30754
30755
  };
30755
30756
 
30756
30757
  function changeAttribute(element, name, value, operation) {
@@ -30787,102 +30788,10 @@ var Deferred = void 0;
30787
30788
  })();
30788
30789
  (function() {
30789
30790
  if (window.customElements && !customElements.polyfilled) {
30790
- eval('(() => {\n \'use strict\';\n\n const NativeHTMLElement = window.HTMLElement;\n const nativeDefine = window.customElements.define;\n const nativeGet = window.customElements.get;\n\n /**\n * Map of user-provided constructors to tag names.\n *\n * @type {Map<Function, string>}\n */\n const tagnameByConstructor = new Map();\n\n /**\n * Map of tag anmes to user-provided constructors.\n *\n * @type {Map<string, Function>}\n */\n const constructorByTagname = new Map();\n\n\n /**\n * Whether the constructors are being called by a browser process, ie parsing\n * or createElement.\n */\n let browserConstruction = false;\n\n /**\n * Whether the constructors are being called by a user-space process, ie\n * calling an element constructor.\n */\n let userConstruction = false;\n\n window.HTMLElement = function() {\n if (!browserConstruction) {\n const tagname = tagnameByConstructor.get(this.constructor);\n const fakeClass = nativeGet.call(window.customElements, tagname);\n\n // Make sure that the fake constructor doesn\'t call back to this constructor\n userConstruction = true;\n const instance = new (fakeClass)();\n return instance;\n }\n // Else do nothing. This will be reached by ES5-style classes doing\n // HTMLElement.call() during initialization\n browserConstruction = false;\n };\n\n window.HTMLElement.prototype = Object.create(NativeHTMLElement.prototype);\n window.HTMLElement.prototype.constructor = window.HTMLElement;\n\n window.customElements.define = (tagname, elementClass) => {\n const elementProto = elementClass.prototype;\n const StandInElement = class extends NativeHTMLElement {\n constructor() {\n // Call the native HTMLElement constructor, this gives us the\n // under-construction instance as `this`:\n super();\n\n // The prototype will be wrong up because the browser used our fake\n // class, so fix it:\n Object.setPrototypeOf(this, elementProto);\n\n if (!userConstruction) {\n // Make sure that user-defined constructor bottom\'s out to a do-nothing\n // HTMLElement() call\n browserConstruction = true;\n // Call the user-defined constructor on our instance:\n elementClass.call(this);\n }\n userConstruction = false;\n }\n };\n const standInProto = StandInElement.prototype;\n StandInElement.observedAttributes = elementClass.observedAttributes;\n standInProto.connectedCallback = elementProto.connectedCallback;\n standInProto.disconnectedCallback = elementProto.disconnectedCallback;\n standInProto.attributeChangedCallback = elementProto.attributeChangedCallback;\n standInProto.adoptedCallback = elementProto.adoptedCallback;\n\n tagnameByConstructor.set(elementClass, tagname);\n constructorByTagname.set(tagname, elementClass);\n nativeDefine.call(window.customElements, tagname, StandInElement);\n };\n\n window.customElements.get = (tagname) => constructorByTagname.get(tagname);\n\n})();');
30791
+ eval('(() => {\n \'use strict\';\n\n const NativeHTMLElement = window.HTMLElement;\n const nativeDefine = window.customElements.define;\n const nativeGet = window.customElements.get;\n\n /**\n * Map of user-provided constructors to tag names.\n *\n * @type {Map<Function, string>}\n */\n const tagnameByConstructor = new Map();\n\n /**\n * Map of tag names to user-provided constructors.\n *\n * @type {Map<string, Function>}\n */\n const constructorByTagname = new Map();\n\n\n /**\n * Whether the constructors are being called by a browser process, ie parsing\n * or createElement.\n */\n let browserConstruction = false;\n\n /**\n * Whether the constructors are being called by a user-space process, ie\n * calling an element constructor.\n */\n let userConstruction = false;\n\n window.HTMLElement = function() {\n if (!browserConstruction) {\n const tagname = tagnameByConstructor.get(this.constructor);\n const fakeClass = nativeGet.call(window.customElements, tagname);\n\n // Make sure that the fake constructor doesn\'t call back to this constructor\n userConstruction = true;\n const instance = new (fakeClass)();\n return instance;\n }\n // Else do nothing. This will be reached by ES5-style classes doing\n // HTMLElement.call() during initialization\n browserConstruction = false;\n };\n // By setting the patched HTMLElement\'s prototype property to the native\n // HTMLElement\'s prototype we make sure that:\n // document.createElement(\'a\') instanceof HTMLElement\n // works because instanceof uses HTMLElement.prototype, which is on the\n // ptototype chain of built-in elements.\n window.HTMLElement.prototype = NativeHTMLElement.prototype;\n\n window.customElements.define = (tagname, elementClass) => {\n const elementProto = elementClass.prototype;\n const StandInElement = class extends NativeHTMLElement {\n constructor() {\n // Call the native HTMLElement constructor, this gives us the\n // under-construction instance as `this`:\n super();\n\n // The prototype will be wrong up because the browser used our fake\n // class, so fix it:\n Object.setPrototypeOf(this, elementProto);\n\n if (!userConstruction) {\n // Make sure that user-defined constructor bottom\'s out to a do-nothing\n // HTMLElement() call\n browserConstruction = true;\n // Call the user-defined constructor on our instance:\n elementClass.call(this);\n }\n userConstruction = false;\n }\n };\n const standInProto = StandInElement.prototype;\n StandInElement.observedAttributes = elementClass.observedAttributes;\n standInProto.connectedCallback = elementProto.connectedCallback;\n standInProto.disconnectedCallback = elementProto.disconnectedCallback;\n standInProto.attributeChangedCallback = elementProto.attributeChangedCallback;\n standInProto.adoptedCallback = elementProto.adoptedCallback;\n\n tagnameByConstructor.set(elementClass, tagname);\n constructorByTagname.set(tagname, elementClass);\n nativeDefine.call(window.customElements, tagname, StandInElement);\n };\n\n window.customElements.get = (tagname) => constructorByTagname.get(tagname);\n\n})();');
30791
30792
  }
30792
30793
 
30793
30794
  }).call(this);
30794
- /**
30795
- * @license
30796
- * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
30797
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
30798
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
30799
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
30800
- * Code distributed by Google as part of the polymer project is also
30801
- * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
30802
- */
30803
-
30804
- (function() {
30805
- 'use strict';
30806
-
30807
- // patch all built-in subclasses of HTMLElement to inherit from the new HTMLElement
30808
- // See https://html.spec.whatwg.org/multipage/indices.html#element-interfaces
30809
-
30810
- /** @const */
30811
- var htmlElementSubclasses = [
30812
- 'Button',
30813
- 'Canvas',
30814
- 'Data',
30815
- 'Head',
30816
- 'Mod',
30817
- 'TableCell',
30818
- 'TableCol',
30819
- 'Anchor',
30820
- 'Area',
30821
- 'Base',
30822
- 'Body',
30823
- 'BR',
30824
- 'DataList',
30825
- 'Details',
30826
- 'Dialog',
30827
- 'Div',
30828
- 'DList',
30829
- 'Embed',
30830
- 'FieldSet',
30831
- 'Form',
30832
- 'Heading',
30833
- 'HR',
30834
- 'Html',
30835
- 'IFrame',
30836
- 'Image',
30837
- 'Input',
30838
- 'Keygen',
30839
- 'Label',
30840
- 'Legend',
30841
- 'LI',
30842
- 'Link',
30843
- 'Map',
30844
- 'Media',
30845
- 'Menu',
30846
- 'MenuItem',
30847
- 'Meta',
30848
- 'Meter',
30849
- 'Object',
30850
- 'OList',
30851
- 'OptGroup',
30852
- 'Option',
30853
- 'Output',
30854
- 'Paragraph',
30855
- 'Param',
30856
- 'Picture',
30857
- 'Pre',
30858
- 'Progress',
30859
- 'Quote',
30860
- 'Script',
30861
- 'Select',
30862
- 'Slot',
30863
- 'Source',
30864
- 'Span',
30865
- 'Style',
30866
- 'TableCaption',
30867
- 'Table',
30868
- 'TableRow',
30869
- 'TableSection',
30870
- 'Template',
30871
- 'TextArea',
30872
- 'Time',
30873
- 'Title',
30874
- 'Track',
30875
- 'UList',
30876
- 'Unknown',
30877
- ];
30878
-
30879
- for (var i = 0; i < htmlElementSubclasses.length; i++) {
30880
- var ctor = window['HTML' + htmlElementSubclasses[i] + 'Element'];
30881
- if (ctor) {
30882
- ctor.prototype.__proto__ = window.HTMLElement.prototype;
30883
- }
30884
- }
30885
- })();
30886
30795
  (function() {
30887
30796
 
30888
30797
 
@@ -30903,11 +30812,11 @@ var Deferred = void 0;
30903
30812
  return components[superClass];
30904
30813
  }
30905
30814
  return components[superClass] = (function(superClass1) {
30815
+ var count;
30816
+
30906
30817
  extend(_Class, superClass1);
30907
30818
 
30908
- function _Class() {
30909
- return _Class.__super__.constructor.apply(this, arguments);
30910
- }
30819
+ count = 0;
30911
30820
 
30912
30821
  _Class.extend = function(obj) {
30913
30822
  var key, ref, val;
@@ -31019,26 +30928,57 @@ var Deferred = void 0;
31019
30928
  return $(this);
31020
30929
  });
31021
30930
 
30931
+ _Class.attribute('taoId');
30932
+
30933
+ function _Class() {
30934
+ var instance;
30935
+ instance = window[superClass].apply(this, arguments);
30936
+ this._created();
30937
+ instance;
30938
+ }
30939
+
31022
30940
  _Class.prototype.connectedCallback = function() {
31023
- if (!this.initialized) {
31024
- this.classList.add('tao-component');
31025
- this._init();
31026
- this.initialized = true;
31027
- }
31028
- this.connected = true;
31029
- return this._connect();
30941
+ return $((function(_this) {
30942
+ return function() {
30943
+ if (!_this.initialized) {
30944
+ _this.taoId = ++count;
30945
+ _this._init();
30946
+ _this.initialized = true;
30947
+ }
30948
+ _this.connected = true;
30949
+ return _this._connected();
30950
+ };
30951
+ })(this));
31030
30952
  };
31031
30953
 
31032
30954
  _Class.prototype.disconnectedCallback = function() {
31033
- this.connected = false;
31034
- return this._disconnect();
30955
+ return $((function(_this) {
30956
+ return function() {
30957
+ _this.connected = false;
30958
+ return _this._disconnected();
30959
+ };
30960
+ })(this));
30961
+ };
30962
+
30963
+ _Class.prototype.attributeChangedCallback = function(name) {
30964
+ return this._attributeChanged(name);
31035
30965
  };
31036
30966
 
31037
- _Class.prototype.attributeChangedCallback = function(attrName) {
30967
+ _Class.prototype._created = function() {};
30968
+
30969
+ _Class.prototype._init = function() {};
30970
+
30971
+ _Class.prototype._connected = function() {};
30972
+
30973
+ _Class.prototype._disconnected = function() {};
30974
+
30975
+ _Class.prototype._attributeChanged = function(name) {
31038
30976
  var name1;
31039
- return typeof this[name1 = "_" + (_.camelCase(attrName)) + "Changed"] === "function" ? this[name1]() : void 0;
30977
+ return typeof this[name1 = "_" + (_.camelCase(name)) + "Changed"] === "function" ? this[name1]() : void 0;
31040
30978
  };
31041
30979
 
30980
+ _Class.prototype.beforeCache = function() {};
30981
+
31042
30982
  _Class.prototype.on = function() {
31043
30983
  var args, ref;
31044
30984
  args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
@@ -31063,14 +31003,6 @@ var Deferred = void 0;
31063
31003
  return (ref = this.jq).one.apply(ref, args);
31064
31004
  };
31065
31005
 
31066
- _Class.prototype._init = function() {};
31067
-
31068
- _Class.prototype._connect = function() {};
31069
-
31070
- _Class.prototype._disconnect = function() {};
31071
-
31072
- _Class.prototype.prepareCache = function() {};
31073
-
31074
31006
  return _Class;
31075
31007
 
31076
31008
  })(window[superClass]);
@@ -31095,11 +31027,11 @@ var Deferred = void 0;
31095
31027
 
31096
31028
  TaoPage.attribute('layout');
31097
31029
 
31098
- TaoPage.prototype.prepareCache = function() {
31099
- return $(this).find('.tao-component').each((function(_this) {
31030
+ TaoPage.prototype.beforeCache = function() {
31031
+ return this.jp.find('[tao-id]').each((function(_this) {
31100
31032
  return function(i, el) {
31101
- if (typeof el.prepareCache === "function") {
31102
- el.prepareCache();
31033
+ if (typeof el.beforeCache === "function") {
31034
+ el.beforeCache();
31103
31035
  }
31104
31036
  return null;
31105
31037
  };
@@ -48,7 +48,7 @@ class TaoApplication extends TaoModule
48
48
 
49
49
  .on 'turbolinks:before-cache', (e) =>
50
50
  @trigger 'before-page-cache', [@currentPage]
51
- @currentPage?.prepareCache?()
51
+ @currentPage?.beforeCache?()
52
52
  window.currentPage = @currentPage = null
53
53
 
54
54
  .on 'turbolinks:request-end', (e) =>
@@ -8,6 +8,8 @@ TaoComponentBasedOn = (superClass = 'HTMLElement') ->
8
8
 
9
9
  class components[superClass] extends window[superClass]
10
10
 
11
+ count = 0
12
+
11
13
  @extend: (obj) ->
12
14
  unless obj and typeof obj == 'object'
13
15
  throw new Error('TaoComponent.extend: param should be an object')
@@ -75,21 +77,48 @@ TaoComponentBasedOn = (superClass = 'HTMLElement') ->
75
77
  @get 'jq', ->
76
78
  $(@)
77
79
 
80
+ @attribute 'taoId'
81
+
82
+ constructor: ->
83
+ instance = window[superClass].apply(@, arguments)
84
+ @_created()
85
+ instance
86
+
78
87
  connectedCallback: ->
79
- unless @initialized
80
- @classList.add 'tao-component'
81
- @_init()
82
- @initialized = true
88
+ $ =>
89
+ unless @initialized
90
+ @taoId = ++count
91
+ @_init()
92
+ @initialized = true
83
93
 
84
- @connected = true
85
- @_connect()
94
+ @connected = true
95
+ @_connected()
86
96
 
87
97
  disconnectedCallback: ->
88
- @connected = false
89
- @_disconnect()
98
+ $ =>
99
+ @connected = false
100
+ @_disconnected()
101
+
102
+ attributeChangedCallback: (name) ->
103
+ @_attributeChanged name
104
+
105
+ _created: ->
106
+ # called when the element was created
107
+
108
+ _init: ->
109
+ # called when the element was connected to dom for the first time
110
+
111
+ _connected: ->
112
+ # called when the element was connected to dom
90
113
 
91
- attributeChangedCallback: (attrName) ->
92
- @["_#{_.camelCase attrName}Changed"]?()
114
+ _disconnected: ->
115
+ # called when the element was disconnected from dom
116
+
117
+ _attributeChanged: (name) ->
118
+ @["_#{_.camelCase name}Changed"]?()
119
+
120
+ beforeCache: ->
121
+ # called before turbolinks cache pages
93
122
 
94
123
  on: (args...) ->
95
124
  @jq.on args...
@@ -103,17 +132,6 @@ TaoComponentBasedOn = (superClass = 'HTMLElement') ->
103
132
  one: (args...) ->
104
133
  @jq.one args...
105
134
 
106
- _init: ->
107
- # to be implemented
108
-
109
- _connect: ->
110
- # to be implemented
111
-
112
- _disconnect: ->
113
- # to be implemented
114
-
115
- prepareCache: ->
116
- # called before turbolinks cache pages
117
135
 
118
136
  window.TaoComponentBasedOn = TaoComponentBasedOn
119
137
  window.TaoComponent = TaoComponentBasedOn 'HTMLElement'
@@ -4,9 +4,9 @@ class TaoPage extends TaoComponent
4
4
 
5
5
  @attribute 'layout'
6
6
 
7
- prepareCache: ->
8
- $(@).find('.tao-component').each (i, el) =>
9
- el.prepareCache?()
7
+ beforeCache: ->
8
+ @jp.find('[tao-id]').each (i, el) =>
9
+ el.beforeCache?()
10
10
  null
11
11
 
12
12
  window.TaoPage = TaoPage
@@ -1,5 +1,5 @@
1
1
  module TaoOnRails
2
2
  module Rails
3
- VERSION = "0.5.3"
3
+ VERSION = "0.6.0"
4
4
  end
5
5
  end
Binary file
@@ -42,17 +42,15 @@ var Deferred = void 0;
42
42
  (function () {
43
43
  'use strict';
44
44
 
45
- var doc = document;
46
- var win = window;
47
-
48
45
  /**
49
46
  * Gets 'customElement' from window so that it could be modified after
50
47
  * the polyfill loads.
51
48
  * @function
52
49
  * @return {CustomElementRegistry}
53
50
  */
51
+
54
52
  var _customElements = function _customElements() {
55
- return win['customElements'];
53
+ return window['customElements'];
56
54
  };
57
55
 
58
56
  var _observerProp = '__$CE_observer';
@@ -93,7 +91,7 @@ var Deferred = void 0;
93
91
  // IE 11 requires the third and fourth arguments be present. If the third
94
92
  // arg is null, it applies the default behaviour. However IE also requires
95
93
  // the fourth argument be present even though the other browsers ignore it.
96
- return doc.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, null, false);
94
+ return document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, null, false);
97
95
  }
98
96
 
99
97
  /**
@@ -371,9 +369,9 @@ var Deferred = void 0;
371
369
  var onReady = function onReady() {
372
370
  _this2._upgradeScheduled = false;
373
371
  if (!_this2._mainDocumentObserver) {
374
- _this2._mainDocumentObserver = _this2._observeRoot(doc);
372
+ _this2._mainDocumentObserver = _this2._observeRoot(document);
375
373
  }
376
- _this2._addNodes(doc.childNodes);
374
+ _this2._addNodes(document.childNodes);
377
375
  };
378
376
  if (window['HTMLImports']) {
379
377
  window['HTMLImports']['whenReady'](onReady);
@@ -709,7 +707,7 @@ var Deferred = void 0;
709
707
  // patch window.HTMLElement
710
708
 
711
709
  /** @const */
712
- var origHTMLElement = win.HTMLElement;
710
+ var origHTMLElement = window.HTMLElement;
713
711
  CustomElementRegistry.prototype['nativeHTMLElement'] = origHTMLElement;
714
712
  /**
715
713
  * @type {function(new: HTMLElement)}
@@ -726,21 +724,24 @@ var Deferred = void 0;
726
724
  if (this.constructor) {
727
725
  // Find the tagname of the constructor and create a new element with it
728
726
  var tagName = customElements._constructors.get(this.constructor);
729
- return _createElement(doc, tagName, undefined, false);
727
+ return _createElement(document, tagName, undefined, false);
730
728
  }
731
729
  throw new Error('Unknown constructor. Did you call customElements.define()?');
732
730
  };
733
- win.HTMLElement = newHTMLElement;
734
- win.HTMLElement.prototype = Object.create(origHTMLElement.prototype, {
735
- constructor: { value: win.HTMLElement, configurable: true, writable: true }
736
- });
731
+ window.HTMLElement = newHTMLElement;
732
+ // By setting the patched HTMLElement's prototype property to the native
733
+ // HTMLElement's prototype we make sure that:
734
+ // document.createElement('a') instanceof HTMLElement
735
+ // works because instanceof uses HTMLElement.prototype, which is on the
736
+ // ptototype chain of built-in elements.
737
+ window.HTMLElement.prototype = origHTMLElement.prototype;
737
738
 
738
739
  // patch doc.createElement
739
740
  // TODO(justinfagnani): why is the cast neccessary?
740
741
  // Can we fix the Closure DOM externs?
741
- var _origCreateElement =
742
+ var _nativeCreateElement =
742
743
  /** @type {function(this:Document, string, (Object|undefined)=): !HTMLElement}}*/
743
- doc.createElement;
744
+ document.createElement;
744
745
 
745
746
  /**
746
747
  * Creates a new element and upgrades it if it's a custom element.
@@ -754,7 +755,7 @@ var Deferred = void 0;
754
755
  */
755
756
  function _createElement(doc, tagName, options, callConstructor) {
756
757
  var customElements = _customElements();
757
- var element = options ? _origCreateElement.call(doc, tagName, options) : _origCreateElement.call(doc, tagName);
758
+ var element = options ? _nativeCreateElement.call(doc, tagName, options) : _nativeCreateElement.call(doc, tagName);
758
759
  var definition = customElements._definitions.get(tagName.toLowerCase());
759
760
  if (definition) {
760
761
  customElements._upgradeElement(element, definition, callConstructor);
@@ -762,35 +763,35 @@ var Deferred = void 0;
762
763
  customElements._observeRoot(element);
763
764
  return element;
764
765
  };
765
- doc.createElement = function (tagName, options) {
766
- return _createElement(doc, tagName, options, true);
766
+ document.createElement = function (tagName, options) {
767
+ return _createElement(document, tagName, options, true);
767
768
  };
768
769
 
769
- // patch doc.createElementNS
770
+ // patch document.createElementNS
770
771
 
771
772
  var HTMLNS = 'http://www.w3.org/1999/xhtml';
772
773
 
773
774
  /** @type {function(this:Document,string,string):Element} */
774
- var _origCreateElementNS = doc.createElementNS;
775
- doc.createElementNS =
775
+ var _nativeCreateElementNS = document.createElementNS;
776
+ document.createElementNS =
776
777
  /** @type {function(this:Document,(string|null),string):!Element} */
777
778
  function (namespaceURI, qualifiedName) {
778
- if (namespaceURI === 'http://www.w3.org/1999/xhtml') {
779
- return doc.createElement(qualifiedName);
779
+ if (namespaceURI === HTMLNS) {
780
+ return document.createElement(qualifiedName);
780
781
  } else {
781
- return _origCreateElementNS.call(doc, namespaceURI, qualifiedName);
782
+ return _nativeCreateElementNS.call(document, namespaceURI, qualifiedName);
782
783
  }
783
784
  };
784
785
 
785
786
  // patch Element.attachShadow
786
787
 
787
788
  /** @type {function({closed: boolean})} */
788
- var _origAttachShadow = Element.prototype['attachShadow'];
789
- if (_origAttachShadow) {
789
+ var _nativeAttachShadow = Element.prototype['attachShadow'];
790
+ if (_nativeAttachShadow) {
790
791
  Object.defineProperty(Element.prototype, 'attachShadow', {
791
792
  value: function value(options) {
792
793
  /** @type {!Node} */
793
- var root = _origAttachShadow.call(this, options);
794
+ var root = _nativeAttachShadow.call(this, options);
794
795
  /** @type {CustomElementRegistry} */
795
796
  var customElements = _customElements();
796
797
  customElements._observeRoot(root);
@@ -799,11 +800,11 @@ var Deferred = void 0;
799
800
  });
800
801
  }
801
802
 
802
- // patch doc.importNode
803
+ // patch document.importNode
803
804
 
804
- var rawImportNode = doc.importNode;
805
- doc.importNode = function (node, deep) {
806
- var clone = /** @type{!Node} */rawImportNode.call(doc, node, deep);
805
+ var _nativeImportNode = document.importNode;
806
+ document.importNode = function (node, deep) {
807
+ var clone = /** @type{!Node} */_nativeImportNode.call(document, node, deep);
807
808
  var customElements = _customElements();
808
809
  var nodes = isElement(clone) ? [clone] : clone.childNodes;
809
810
  /** @type {CustomElementRegistry} */_customElements()._addNodes(nodes);
@@ -812,13 +813,13 @@ var Deferred = void 0;
812
813
 
813
814
  // patch Element.setAttribute & removeAttribute
814
815
 
815
- var _origSetAttribute = Element.prototype.setAttribute;
816
+ var _nativeSetAttribute = Element.prototype.setAttribute;
816
817
  Element.prototype['setAttribute'] = function (name, value) {
817
- changeAttribute(this, name, value, _origSetAttribute);
818
+ changeAttribute(this, name, value, _nativeSetAttribute);
818
819
  };
819
- var _origRemoveAttribute = Element.prototype.removeAttribute;
820
+ var _nativeRemoveAttribute = Element.prototype.removeAttribute;
820
821
  Element.prototype['removeAttribute'] = function (name) {
821
- changeAttribute(this, name, null, _origRemoveAttribute);
822
+ changeAttribute(this, name, null, _nativeRemoveAttribute);
822
823
  };
823
824
 
824
825
  function changeAttribute(element, name, value, operation) {
@@ -16,7 +16,7 @@ if window.customElements && !customElements.polyfilled
16
16
  const tagnameByConstructor = new Map();
17
17
 
18
18
  /**
19
- * Map of tag anmes to user-provided constructors.
19
+ * Map of tag names to user-provided constructors.
20
20
  *
21
21
  * @type {Map<string, Function>}
22
22
  */
@@ -49,9 +49,12 @@ if window.customElements && !customElements.polyfilled
49
49
  // HTMLElement.call() during initialization
50
50
  browserConstruction = false;
51
51
  };
52
-
53
- window.HTMLElement.prototype = Object.create(NativeHTMLElement.prototype);
54
- window.HTMLElement.prototype.constructor = window.HTMLElement;
52
+ // By setting the patched HTMLElement's prototype property to the native
53
+ // HTMLElement's prototype we make sure that:
54
+ // document.createElement('a') instanceof HTMLElement
55
+ // works because instanceof uses HTMLElement.prototype, which is on the
56
+ // ptototype chain of built-in elements.
57
+ window.HTMLElement.prototype = NativeHTMLElement.prototype;
55
58
 
56
59
  window.customElements.define = (tagname, elementClass) => {
57
60
  const elementProto = elementClass.prototype;
@@ -1,4 +1,3 @@
1
1
  #= require ./es6
2
2
  #= require ./custom-elements
3
3
  #= require ./native-shim
4
- #= require ./htmlelement-instanceof
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tao_on_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Siyuan Liu
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-01-03 00:00:00.000000000 Z
12
+ date: 2017-01-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: turbolinks
@@ -147,6 +147,7 @@ executables: []
147
147
  extensions: []
148
148
  extra_rdoc_files: []
149
149
  files:
150
+ - ".DS_Store"
150
151
  - ".blade.yml"
151
152
  - ".gitignore"
152
153
  - ".travis.yml"
@@ -176,9 +177,10 @@ files:
176
177
  - lib/tao_on_rails/rails/version.rb
177
178
  - lib/tasks/tao_icons.rake
178
179
  - tao_on_rails.gemspec
180
+ - vendor/assets/javascripts/.DS_Store
181
+ - vendor/assets/javascripts/polyfills/.DS_Store
179
182
  - vendor/assets/javascripts/polyfills/custom-elements.js
180
183
  - vendor/assets/javascripts/polyfills/es6.js
181
- - vendor/assets/javascripts/polyfills/htmlelement-instanceof.js
182
184
  - vendor/assets/javascripts/polyfills/native-shim.coffee
183
185
  - vendor/assets/javascripts/polyfills/polyfills.coffee
184
186
  - vendor/assets/stylesheets/normalize.css
@@ -1,91 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
4
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7
- * Code distributed by Google as part of the polymer project is also
8
- * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9
- */
10
- (function() {
11
- 'use strict';
12
-
13
- // patch all built-in subclasses of HTMLElement to inherit from the new HTMLElement
14
- // See https://html.spec.whatwg.org/multipage/indices.html#element-interfaces
15
-
16
- /** @const */
17
- var htmlElementSubclasses = [
18
- 'Button',
19
- 'Canvas',
20
- 'Data',
21
- 'Head',
22
- 'Mod',
23
- 'TableCell',
24
- 'TableCol',
25
- 'Anchor',
26
- 'Area',
27
- 'Base',
28
- 'Body',
29
- 'BR',
30
- 'DataList',
31
- 'Details',
32
- 'Dialog',
33
- 'Div',
34
- 'DList',
35
- 'Embed',
36
- 'FieldSet',
37
- 'Form',
38
- 'Heading',
39
- 'HR',
40
- 'Html',
41
- 'IFrame',
42
- 'Image',
43
- 'Input',
44
- 'Keygen',
45
- 'Label',
46
- 'Legend',
47
- 'LI',
48
- 'Link',
49
- 'Map',
50
- 'Media',
51
- 'Menu',
52
- 'MenuItem',
53
- 'Meta',
54
- 'Meter',
55
- 'Object',
56
- 'OList',
57
- 'OptGroup',
58
- 'Option',
59
- 'Output',
60
- 'Paragraph',
61
- 'Param',
62
- 'Picture',
63
- 'Pre',
64
- 'Progress',
65
- 'Quote',
66
- 'Script',
67
- 'Select',
68
- 'Slot',
69
- 'Source',
70
- 'Span',
71
- 'Style',
72
- 'TableCaption',
73
- 'Table',
74
- 'TableRow',
75
- 'TableSection',
76
- 'Template',
77
- 'TextArea',
78
- 'Time',
79
- 'Title',
80
- 'Track',
81
- 'UList',
82
- 'Unknown',
83
- ];
84
-
85
- for (var i = 0; i < htmlElementSubclasses.length; i++) {
86
- var ctor = window['HTML' + htmlElementSubclasses[i] + 'Element'];
87
- if (ctor) {
88
- ctor.prototype.__proto__ = window.HTMLElement.prototype;
89
- }
90
- }
91
- })();