cable_ready 2.0.8 → 3.0.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
  SHA256:
3
- metadata.gz: 5879babcb8bff931f4bc405e747ee3b0826c3c41fb8fddb20886d78acbb6c5b0
4
- data.tar.gz: e4eb1f5e7f73fe52030ba31dc20ead20f27977c69af75853fce3396bae8ee234
3
+ metadata.gz: 0337ef159a8b062c4dbf3032bcffef132589ce54af9812948976572d7e109b15
4
+ data.tar.gz: 0c0abb0e5feafecd817781ed8716e010070304742dd4dda129673d0464767642
5
5
  SHA512:
6
- metadata.gz: 2a7542d699fb4d616d0ba3ea237c9cf9262a2ee51e6b6b3794805314c17894b6ca92524fb9252d862ae9e49511ab389c99bfa1d35c8aaaac6d4c7b2e6ec8f24a
7
- data.tar.gz: f3734598ed4d353fed052b46ac2cbe974b66ab8d396dd4b16064ac1979038a94bc979da44bccce959177297b777825f20085cda2b43a31d45b1b6c538a5b17d7
6
+ metadata.gz: af077429f0950101e2119994c9c58abf5d4129e9fa6fee2e263aefe1ea5f68429d4abe79a52396c43e97eea57383c8187e082b7b1a16e468aa4bd7932aeeb703
7
+ data.tar.gz: c5c5029f1bcb1777ea041d65ce6ba6ad2f1bd5c776fa62bcae6eb65e766a049219958f175e06773e7fb8e3114cffcc4e7244e52d6bb887207646b0538763fed0
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in cable_ready.gemspec
4
4
  gemspec
data/Gemfile.lock CHANGED
@@ -1,32 +1,81 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cable_ready (2.0.8)
4
+ cable_ready (3.0.0)
5
5
  activesupport (>= 5.0.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (5.2.1)
10
+ activesupport (5.2.2.1)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
12
  i18n (>= 0.7, < 2)
13
13
  minitest (~> 5.1)
14
14
  tzinfo (~> 1.1)
15
- concurrent-ruby (1.1.3)
16
- i18n (1.1.1)
15
+ ast (2.4.0)
16
+ binding_of_caller (0.8.0)
17
+ debug_inspector (>= 0.0.1)
18
+ byebug (11.0.1)
19
+ coderay (1.1.2)
20
+ concurrent-ruby (1.1.5)
21
+ debug_inspector (0.0.3)
22
+ i18n (1.6.0)
17
23
  concurrent-ruby (~> 1.0)
24
+ interception (0.5)
25
+ jaro_winkler (1.5.2)
26
+ method_source (0.9.2)
18
27
  minitest (5.11.3)
19
- rake (12.3.1)
28
+ os (1.0.0)
29
+ parallel (1.15.0)
30
+ parser (2.6.2.0)
31
+ ast (~> 2.4.0)
32
+ pry (0.12.2)
33
+ coderay (~> 1.1.0)
34
+ method_source (~> 0.9.0)
35
+ pry-byebug (3.7.0)
36
+ byebug (~> 11.0)
37
+ pry (~> 0.10)
38
+ pry-rescue (1.5.0)
39
+ interception (>= 0.5)
40
+ pry (>= 0.12.0)
41
+ pry-stack_explorer (0.4.9.3)
42
+ binding_of_caller (>= 0.7)
43
+ pry (>= 0.9.11)
44
+ pry-test (0.6.5)
45
+ os
46
+ pry
47
+ pry-byebug
48
+ pry-rescue
49
+ pry-stack_explorer
50
+ psych (3.1.0)
51
+ rainbow (3.0.0)
52
+ rake (12.3.2)
53
+ rubocop (0.66.0)
54
+ jaro_winkler (~> 1.5.1)
55
+ parallel (~> 1.10)
56
+ parser (>= 2.5, != 2.5.1.1)
57
+ psych (>= 3.1.0)
58
+ rainbow (>= 2.2.2, < 4.0)
59
+ ruby-progressbar (~> 1.7)
60
+ unicode-display_width (>= 1.4.0, < 1.6)
61
+ ruby-progressbar (1.10.0)
62
+ standard (0.0.36)
63
+ rubocop (>= 0.63)
64
+ standardrb (1.0.0)
65
+ standard
20
66
  thread_safe (0.3.6)
21
67
  tzinfo (1.2.5)
22
68
  thread_safe (~> 0.1)
69
+ unicode-display_width (1.5.0)
23
70
 
24
71
  PLATFORMS
25
72
  ruby
26
73
 
27
74
  DEPENDENCIES
28
75
  cable_ready!
76
+ pry-test
29
77
  rake
78
+ standardrb
30
79
 
31
80
  BUNDLED WITH
32
- 1.16.6
81
+ 1.17.3
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Lines of Code](http://img.shields.io/badge/lines_of_code-239-brightgreen.svg?style=flat)](http://blog.codinghorror.com/the-best-code-is-no-code-at-all/)
1
+ [![Lines of Code](http://img.shields.io/badge/lines_of_code-238-brightgreen.svg?style=flat)](http://blog.codinghorror.com/the-best-code-is-no-code-at-all/)
2
2
  [![Code Status](https://img.shields.io/codeclimate/maintainability/hopsoft/cable_ready.svg?style=flat)](https://codeclimate.com/github/hopsoft/cable_ready)
3
3
 
4
4
  # CableReady
@@ -54,10 +54,10 @@ for a more complete reference implementation.
54
54
  - [dispatchEvent](#dispatchevent)
55
55
  - [morph](#morph)
56
56
  - [innerHTML](#innerhtml)
57
+ - [outerHTML](#outerhtml)
57
58
  - [insertAdjacentHTML](#insertAdjacentHTML)
58
59
  - [insertAdjacentText](#insertadjacenttext)
59
60
  - [remove](#remove)
60
- - [replace](#replace)
61
61
  - [setValue](#setvalue)
62
62
  - [setAttribute](#setattribute)
63
63
  - [removeAttribute](#removeattribute)
@@ -117,14 +117,14 @@ import { Controller } from "stimulus"
117
117
  export default class extends Controller {
118
118
  connect() {
119
119
  this.name = this.element.dataset.controller;
120
- document.addEventListener(
121
- 'cable-ready:after-morph',
122
- (() => {
123
- setTimeout(() => this.element.setAttribute('data-controller', this.name), 1);
124
- this.element.setAttribute('data-controller', '');
125
- }).bind(this)
120
+ document.addEventListener('cable-ready:after-morph', this.reconnect.bind(this));
126
121
  );
127
122
  }
123
+
124
+ reconnect() {
125
+ setTimeout(() => this.element.setAttribute('data-controller', this.name), 1);
126
+ this.element.setAttribute('data-controller', '');
127
+ }
128
128
  }
129
129
  ```
130
130
 
@@ -145,6 +145,23 @@ cable_ready["MyChannel"].inner_html(
145
145
  - `cable-ready:before-inner-html`
146
146
  - `cable-ready:after-inner-html`
147
147
 
148
+ #### [outerHTML](https://developer.mozilla.org/en-US/docs/Web/API/Element/outerHTML)
149
+
150
+ Replaces a DOM element with new HTML.
151
+
152
+ ```ruby
153
+ cable_ready["MyChannel"].outerHTML(
154
+ selector: "string", # required - string containing one or more CSS selectors separated by commas
155
+ focus_selector: "string", # [null] - string containing one or more CSS selectors separated by commas
156
+ html: "string" # [null] - the HTML to use as replacement
157
+ )
158
+ ```
159
+
160
+ ##### JavaScript Events
161
+
162
+ - `cable-ready:before-outer-html`
163
+ - `cable-ready:after-outer-html`
164
+
148
165
  #### [textContent](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent)
149
166
 
150
167
  Sets the text content of a DOM element.
@@ -214,23 +231,6 @@ cable_ready["MyChannel"].remove(
214
231
  - `cable-ready:before-remove`
215
232
  - `cable-ready:after-remove`
216
233
 
217
- #### [replace](https://developer.mozilla.org/en-US/docs/Web/API/Node/replaceChild)
218
-
219
- Replaces a DOM element with new HTML.
220
-
221
- ```ruby
222
- cable_ready["MyChannel"].replace(
223
- selector: "string", # required - string containing one or more CSS selectors separated by commas
224
- focus_selector: "string", # [null] - string containing one or more CSS selectors separated by commas
225
- html: "string" # [null] - the HTML to use as replacement
226
- )
227
- ```
228
-
229
- ##### JavaScript Events
230
-
231
- - `cable-ready:before-replace`
232
- - `cable-ready:after-replace`
233
-
234
234
  #### [setValue](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement)
235
235
 
236
236
  Sets the value of an element.
@@ -344,5 +344,6 @@ The JavaScript source is located in `app/assets/javascripts/cable_ready/src`
344
344
 
345
345
  ```sh
346
346
  # build javascript
347
+ ./bin/yarn
347
348
  ./bin/webpack
348
349
  ```
data/Rakefile CHANGED
@@ -1,8 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
- task :default => [:test]
3
+ task default: [:test]
4
4
 
5
5
  task :test do
6
6
  exec "bundle exec pry-test --disable-pry"
7
7
  end
8
-
@@ -1 +1 @@
1
- window.CableReady=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(e,t,r){"use strict";var n,o="http://www.w3.org/1999/xhtml",a="undefined"==typeof document?void 0:document,c=a?a.body||a.createElement("div"):{},l=c.hasAttributeNS?function(e,t,r){return e.hasAttributeNS(t,r)}:c.hasAttribute?function(e,t,r){return e.hasAttribute(r)}:function(e,t,r){return null!=e.getAttributeNode(t,r)};function i(e,t){var r=e.nodeName,n=t.nodeName;return r===n||!!(t.actualize&&r.charCodeAt(0)<91&&n.charCodeAt(0)>90)&&r===n.toUpperCase()}function u(e,t,r){e[r]!==t[r]&&(e[r]=t[r],e[r]?e.setAttribute(r,""):e.removeAttribute(r,""))}var d={OPTION:function(e,t){u(e,t,"selected")},INPUT:function(e,t){u(e,t,"checked"),u(e,t,"disabled"),e.value!==t.value&&(e.value=t.value),l(t,null,"value")||e.removeAttribute("value")},TEXTAREA:function(e,t){var r=t.value;e.value!==r&&(e.value=r);var n=e.firstChild;if(n){var o=n.nodeValue;if(o==r||!r&&o==e.placeholder)return;n.nodeValue=r}},SELECT:function(e,t){if(!l(t,null,"multiple")){for(var r=0,n=t.firstChild;n;){var o=n.nodeName;if(o&&"OPTION"===o.toUpperCase()){if(l(n,null,"selected")){r;break}r++}n=n.nextSibling}e.selectedIndex=r}}},f=1,s=3,m=8;function b(){}function v(e){return e.id}var y=function(e){return function(t,r,c){if(c||(c={}),"string"==typeof r)if("#document"===t.nodeName||"HTML"===t.nodeName){var l=r;(r=a.createElement("html")).innerHTML=l}else r=function(e){var t;return!n&&a.createRange&&(n=a.createRange()).selectNode(a.body),n&&n.createContextualFragment?t=n.createContextualFragment(e):(t=a.createElement("body")).innerHTML=e,t.childNodes[0]}(r);var u,y=c.getNodeKey||v,p=c.onBeforeNodeAdded||b,S=c.onNodeAdded||b,h=c.onBeforeElUpdated||b,g=c.onElUpdated||b,N=c.onBeforeNodeDiscarded||b,C=c.onNodeDiscarded||b,x=c.onBeforeElChildrenUpdated||b,A=!0===c.childrenOnly,T={};function q(e){u?u.push(e):u=[e]}function E(e,t,r){!1!==N(e)&&(t&&t.removeChild(e),C(e),function e(t,r){if(t.nodeType===f)for(var n=t.firstChild;n;){var o=void 0;r&&(o=y(n))?q(o):(C(n),n.firstChild&&e(n,r)),n=n.nextSibling}}(e,r))}function j(e){S(e);for(var t=e.firstChild;t;){var r=t.nextSibling,n=y(t);if(n){var o=T[n];o&&i(t,o)&&(t.parentNode.replaceChild(o,t),O(o,t))}j(t),t=r}}function O(n,o,c){var l,u=y(o);if(u&&delete T[u],!r.isSameNode||!r.isSameNode(t)){if(!c){if(!1===h(n,o))return;if(e(n,o),g(n),!1===x(n,o))return}if("TEXTAREA"!==n.nodeName){var b,v,S,N,C=o.firstChild,A=n.firstChild;e:for(;C;){for(S=C.nextSibling,b=y(C);A;){if(v=A.nextSibling,C.isSameNode&&C.isSameNode(A)){C=S,A=v;continue e}l=y(A);var w=A.nodeType,M=void 0;if(w===C.nodeType&&(w===f?(b?b!==l&&((N=T[b])?A.nextSibling===N?M=!1:(n.insertBefore(N,A),v=A.nextSibling,l?q(l):E(A,n,!0),A=N):M=!1):l&&(M=!1),(M=!1!==M&&i(A,C))&&O(A,C)):w!==s&&w!=m||(M=!0,A.nodeValue!==C.nodeValue&&(A.nodeValue=C.nodeValue))),M){C=S,A=v;continue e}l?q(l):E(A,n,!0),A=v}if(b&&(N=T[b])&&i(N,C))n.appendChild(N),O(N,C);else{var V=p(C);!1!==V&&(V&&(C=V),C.actualize&&(C=C.actualize(n.ownerDocument||a)),n.appendChild(C),j(C))}C=S,A=v}for(;A;)v=A.nextSibling,(l=y(A))?q(l):E(A,n,!0),A=v}var L=d[n.nodeName];L&&L(n,o)}}!function e(t){if(t.nodeType===f)for(var r=t.firstChild;r;){var n=y(r);n&&(T[n]=r),e(r),r=r.nextSibling}}(t);var w=t,M=w.nodeType,V=r.nodeType;if(!A)if(M===f)V===f?i(t,r)||(C(t),w=function(e,t){for(var r=e.firstChild;r;){var n=r.nextSibling;t.appendChild(r),r=n}return t}(t,function(e,t){return t&&t!==o?a.createElementNS(t,e):a.createElement(e)}(r.nodeName,r.namespaceURI))):w=r;else if(M===s||M===m){if(V===M)return w.nodeValue!==r.nodeValue&&(w.nodeValue=r.nodeValue),w;w=r}if(w===r)C(t);else if(O(w,r,A),u)for(var L=0,P=u.length;L<P;L++){var H=T[u[L]];H&&E(H,H.parentNode,!1)}return!A&&w!==t&&t.parentNode&&(w.actualize&&(w=w.actualize(t.ownerDocument||a)),t.parentNode.replaceChild(w,t)),w}}(function(e,t){var r,n,o,a,c,i=t.attributes;for(r=i.length-1;r>=0;--r)o=(n=i[r]).name,a=n.namespaceURI,c=n.value,a?(o=n.localName||o,e.getAttributeNS(a,o)!==c&&e.setAttributeNS(a,o,c)):e.getAttribute(o)!==c&&e.setAttribute(o,c);for(r=(i=e.attributes).length-1;r>=0;--r)!1!==(n=i[r]).specified&&(o=n.name,(a=n.namespaceURI)?(o=n.localName||o,l(t,a,o)||e.removeAttributeNS(a,o)):l(t,null,o)||e.removeAttribute(o))});e.exports=y},function(e,t,r){"use strict";r.r(t),r.d(t,"perform",function(){return l});var n=r(0),o=r.n(n),a=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};c.dispatchEvent({name:e,detail:t})},c={dispatchEvent:function(e){var t=document;e.selector&&(t=document.querySelector(e.selector)||document);var r=new Event(e.name);r.detail=e.detail,t.dispatchEvent(r)},morph:function(e){var t=document.createElement("template");t.innerHTML=String(e.html).trim(),a("cable-ready:before-morph",{config:e,content:t.content}),o()(document.querySelector(e.selector),t.content,{childrenOnly:!!e.childrenOnly}),e.focusSelector&&document.querySelector(e.focusSelector).focus(),a("cable-ready:after-morph",{config:e,content:t.content})},innerHtml:function(e){a("cable-ready:before-inner-html",e),document.querySelector(e.selector).innerHTML=e.html,e.focusSelector&&document.querySelector(e.focusSelector).focus(),a("cable-ready:after-inner-html",e)},textContent:function(e){a("cable-ready:before-text-content",e),document.querySelector(e.selector).textContent=e.text,a("cable-ready:after-text-content",e)},insertAdjacentHtml:function(e){a("cable-ready:before-insert-adjacent-html",e),document.querySelector(e.selector).insertAdjacentHTML(e.position||"beforeend",e.html),e.focusSelector&&document.querySelector(e.focusSelector).focus(),a("cable-ready:after-insert-adjacent-html",e)},insertAdjacentText:function(e){a("cable-ready:before-insert-adjacent-text",e),document.querySelector(e.querySelector).insertAdjacentText(e.position||"beforeend",e.text),a("cable-ready:after-insert-adjacent-text",e)},remove:function(e){a("cable-ready:before-remove",e),document.querySelector(e.selector).remove(),e.focusSelector&&document.querySelector(e.focusSelector).focus(),a("cable-ready:after-remove",e)},replace:function(e){a("cable-ready:before-replace",e);document.querySelector(e.selector);document.createElement("div").innerHTML=e.html,e.focusSelector&&document.querySelector(e.focusSelector).focus(),a("cable-ready:after-replace",e)},setValue:function(e){a("cable-ready:before-set-value",e),document.querySelector(e.selector).value=e.value,a("cable-ready:after-set-value",e)},setAttribute:function(e){a("cable-ready:before-set-attribute",e),document.querySelector(e.selector).setAttribute(e.name,e.value),a("cable-ready:after-set-attribute",e)},removeAttribute:function(e){a("cable-ready:before-remove-attribute",e),document.querySelector(e.selector).removeAttribute(e.name),a("cable-ready:after-remove-attribute",e)},addCssClass:function(e){a("cable-ready:before-add-css-class",e),document.querySelector(e.selector).classList.add(e.name),a("cable-ready:after-add-css-class",e)},removeCssClass:function(e){a("cable-ready:before-remove-css-class",e),document.querySelector(e.selector).classList.remove(e.name),a("cable-ready:after-remove-css-class",e)},setDatasetProperty:function(e){a("cable-ready:before-set-dataset-property",e),document.querySelector(e.selector).dataset[e.name]=e.value,a("cable-ready:after-set-dataset-property",e)}},l=function(e){for(var t in e)if(e.hasOwnProperty(t))for(var r=e[t],n=0;n<r.length;n++)try{var o=r[n];c[t](o)}catch(e){console.log("CableReady detected an error in ".concat(t,"! ").concat(e.message))}}}]);
1
+ window.CableReady=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(e,t,r){"use strict";var n,o="http://www.w3.org/1999/xhtml",a="undefined"==typeof document?void 0:document,c=a?a.body||a.createElement("div"):{},l=c.hasAttributeNS?function(e,t,r){return e.hasAttributeNS(t,r)}:c.hasAttribute?function(e,t,r){return e.hasAttribute(r)}:function(e,t,r){return null!=e.getAttributeNode(t,r)};function u(e,t){var r=e.nodeName,n=t.nodeName;return r===n||!!(t.actualize&&r.charCodeAt(0)<91&&n.charCodeAt(0)>90)&&r===n.toUpperCase()}function i(e,t,r){e[r]!==t[r]&&(e[r]=t[r],e[r]?e.setAttribute(r,""):e.removeAttribute(r,""))}var d={OPTION:function(e,t){i(e,t,"selected")},INPUT:function(e,t){i(e,t,"checked"),i(e,t,"disabled"),e.value!==t.value&&(e.value=t.value),l(t,null,"value")||e.removeAttribute("value")},TEXTAREA:function(e,t){var r=t.value;e.value!==r&&(e.value=r);var n=e.firstChild;if(n){var o=n.nodeValue;if(o==r||!r&&o==e.placeholder)return;n.nodeValue=r}},SELECT:function(e,t){if(!l(t,null,"multiple")){for(var r=0,n=t.firstChild;n;){var o=n.nodeName;if(o&&"OPTION"===o.toUpperCase()){if(l(n,null,"selected")){r;break}r++}n=n.nextSibling}e.selectedIndex=r}}},f=1,s=3,m=8;function b(){}function v(e){return e.id}var y=function(e){return function(t,r,c){if(c||(c={}),"string"==typeof r)if("#document"===t.nodeName||"HTML"===t.nodeName){var l=r;(r=a.createElement("html")).innerHTML=l}else r=function(e){var t;return!n&&a.createRange&&(n=a.createRange()).selectNode(a.body),n&&n.createContextualFragment?t=n.createContextualFragment(e):(t=a.createElement("body")).innerHTML=e,t.childNodes[0]}(r);var i,y=c.getNodeKey||v,p=c.onBeforeNodeAdded||b,S=c.onNodeAdded||b,h=c.onBeforeElUpdated||b,g=c.onElUpdated||b,N=c.onBeforeNodeDiscarded||b,C=c.onNodeDiscarded||b,x=c.onBeforeElChildrenUpdated||b,A=!0===c.childrenOnly,T={};function q(e){i?i.push(e):i=[e]}function E(e,t,r){!1!==N(e)&&(t&&t.removeChild(e),C(e),function e(t,r){if(t.nodeType===f)for(var n=t.firstChild;n;){var o=void 0;r&&(o=y(n))?q(o):(C(n),n.firstChild&&e(n,r)),n=n.nextSibling}}(e,r))}function j(e){S(e);for(var t=e.firstChild;t;){var r=t.nextSibling,n=y(t);if(n){var o=T[n];o&&u(t,o)&&(t.parentNode.replaceChild(o,t),O(o,t))}j(t),t=r}}function O(n,o,c){var l,i=y(o);if(i&&delete T[i],!r.isSameNode||!r.isSameNode(t)){if(!c){if(!1===h(n,o))return;if(e(n,o),g(n),!1===x(n,o))return}if("TEXTAREA"!==n.nodeName){var b,v,S,N,C=o.firstChild,A=n.firstChild;e:for(;C;){for(S=C.nextSibling,b=y(C);A;){if(v=A.nextSibling,C.isSameNode&&C.isSameNode(A)){C=S,A=v;continue e}l=y(A);var w=A.nodeType,M=void 0;if(w===C.nodeType&&(w===f?(b?b!==l&&((N=T[b])?A.nextSibling===N?M=!1:(n.insertBefore(N,A),v=A.nextSibling,l?q(l):E(A,n,!0),A=N):M=!1):l&&(M=!1),(M=!1!==M&&u(A,C))&&O(A,C)):w!==s&&w!=m||(M=!0,A.nodeValue!==C.nodeValue&&(A.nodeValue=C.nodeValue))),M){C=S,A=v;continue e}l?q(l):E(A,n,!0),A=v}if(b&&(N=T[b])&&u(N,C))n.appendChild(N),O(N,C);else{var V=p(C);!1!==V&&(V&&(C=V),C.actualize&&(C=C.actualize(n.ownerDocument||a)),n.appendChild(C),j(C))}C=S,A=v}for(;A;)v=A.nextSibling,(l=y(A))?q(l):E(A,n,!0),A=v}var H=d[n.nodeName];H&&H(n,o)}}!function e(t){if(t.nodeType===f)for(var r=t.firstChild;r;){var n=y(r);n&&(T[n]=r),e(r),r=r.nextSibling}}(t);var w=t,M=w.nodeType,V=r.nodeType;if(!A)if(M===f)V===f?u(t,r)||(C(t),w=function(e,t){for(var r=e.firstChild;r;){var n=r.nextSibling;t.appendChild(r),r=n}return t}(t,function(e,t){return t&&t!==o?a.createElementNS(t,e):a.createElement(e)}(r.nodeName,r.namespaceURI))):w=r;else if(M===s||M===m){if(V===M)return w.nodeValue!==r.nodeValue&&(w.nodeValue=r.nodeValue),w;w=r}if(w===r)C(t);else if(O(w,r,A),i)for(var H=0,L=i.length;H<L;H++){var P=T[i[H]];P&&E(P,P.parentNode,!1)}return!A&&w!==t&&t.parentNode&&(w.actualize&&(w=w.actualize(t.ownerDocument||a)),t.parentNode.replaceChild(w,t)),w}}(function(e,t){var r,n,o,a,c,u=t.attributes;for(r=u.length-1;r>=0;--r)o=(n=u[r]).name,a=n.namespaceURI,c=n.value,a?(o=n.localName||o,e.getAttributeNS(a,o)!==c&&e.setAttributeNS(a,o,c)):e.getAttribute(o)!==c&&e.setAttribute(o,c);for(r=(u=e.attributes).length-1;r>=0;--r)!1!==(n=u[r]).specified&&(o=n.name,(a=n.namespaceURI)?(o=n.localName||o,l(t,a,o)||e.removeAttributeNS(a,o)):l(t,null,o)||e.removeAttribute(o))});e.exports=y},function(e,t,r){"use strict";r.r(t),r.d(t,"perform",function(){return l});var n=r(0),o=r.n(n),a=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};c.dispatchEvent({name:e,detail:t})},c={dispatchEvent:function(e){var t=document;e.selector&&(t=document.querySelector(e.selector)||document);var r=new Event(e.name);r.detail=e.detail,t.dispatchEvent(r)},morph:function(e){var t=document.createElement("template");t.innerHTML=String(e.html).trim(),a("cable-ready:before-morph",{config:e,content:t.content}),o()(document.querySelector(e.selector),t.content,{childrenOnly:!!e.childrenOnly}),e.focusSelector&&document.querySelector(e.focusSelector).focus(),a("cable-ready:after-morph",{config:e,content:t.content})},innerHtml:function(e){a("cable-ready:before-inner-html",e),document.querySelector(e.selector).innerHTML=e.html,e.focusSelector&&document.querySelector(e.focusSelector).focus(),a("cable-ready:after-inner-html",e)},outerHtml:function(e){a("cable-ready:before-outer-html",e),document.querySelector(e.selector).outerHTML=e.html,e.focusSelector&&document.querySelector(e.focusSelector).focus(),a("cable-ready:after-outer-html",e)},textContent:function(e){a("cable-ready:before-text-content",e),document.querySelector(e.selector).textContent=e.text,a("cable-ready:after-text-content",e)},insertAdjacentHtml:function(e){a("cable-ready:before-insert-adjacent-html",e),document.querySelector(e.selector).insertAdjacentHTML(e.position||"beforeend",e.html),e.focusSelector&&document.querySelector(e.focusSelector).focus(),a("cable-ready:after-insert-adjacent-html",e)},insertAdjacentText:function(e){a("cable-ready:before-insert-adjacent-text",e),document.querySelector(e.querySelector).insertAdjacentText(e.position||"beforeend",e.text),a("cable-ready:after-insert-adjacent-text",e)},remove:function(e){a("cable-ready:before-remove",e),document.querySelector(e.selector).remove(),e.focusSelector&&document.querySelector(e.focusSelector).focus(),a("cable-ready:after-remove",e)},setValue:function(e){a("cable-ready:before-set-value",e),document.querySelector(e.selector).value=e.value,a("cable-ready:after-set-value",e)},setAttribute:function(e){a("cable-ready:before-set-attribute",e),document.querySelector(e.selector).setAttribute(e.name,e.value),a("cable-ready:after-set-attribute",e)},removeAttribute:function(e){a("cable-ready:before-remove-attribute",e),document.querySelector(e.selector).removeAttribute(e.name),a("cable-ready:after-remove-attribute",e)},addCssClass:function(e){a("cable-ready:before-add-css-class",e),document.querySelector(e.selector).classList.add(e.name),a("cable-ready:after-add-css-class",e)},removeCssClass:function(e){a("cable-ready:before-remove-css-class",e),document.querySelector(e.selector).classList.remove(e.name),a("cable-ready:after-remove-css-class",e)},setDatasetProperty:function(e){a("cable-ready:before-set-dataset-property",e),document.querySelector(e.selector).dataset[e.name]=e.value,a("cable-ready:after-set-dataset-property",e)}},l=function(e){for(var t in e)if(e.hasOwnProperty(t))for(var r=e[t],n=0;n<r.length;n++)try{var o=r[n];c[t](o)}catch(e){console.log("CableReady detected an error in ".concat(t,"! ").concat(e.message))}}}]);
data/bin/cloc ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+
3
+ cloc lib app/assets/javascripts/cable_ready/src/index.js
data/bin/standardize ADDED
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+
3
+ bundle exec standardrb --fix
4
+ prettier --no-config --single-quote --trailing-comma es5 --write app/assets/javascripts/cable_ready/src/*.js
@@ -28,6 +28,12 @@ module CableReady
28
28
  # html: "string"
29
29
  # }, ...],
30
30
  #
31
+ # outer_html: [{
32
+ # selector: "string",
33
+ # focus_selector: "string",
34
+ # html: "string"
35
+ # }, ...],
36
+ #
31
37
  # text_content: [{
32
38
  # selector: "string",
33
39
  # text: "string"
@@ -51,12 +57,6 @@ module CableReady
51
57
  # focus_selector: "string,
52
58
  # }, ...],
53
59
  #
54
- # replace: [{
55
- # selector: "string",
56
- # focus_selector: "string",
57
- # html: "string"
58
- # }, ...],
59
- #
60
60
  # set_value: [{
61
61
  # selector: "string",
62
62
  # value: "string"
@@ -111,81 +111,81 @@ module CableReady
111
111
  clear
112
112
  end
113
113
 
114
- def dispatch_event(options={})
114
+ def dispatch_event(options = {})
115
115
  operations[:dispatch_event] << options
116
116
  end
117
117
 
118
- def morph(options={})
118
+ def morph(options = {})
119
119
  operations[:morph] << options
120
120
  end
121
121
 
122
- def inner_html(options={})
122
+ def inner_html(options = {})
123
123
  operations[:inner_html] << options
124
124
  end
125
125
 
126
- def text_content(options={})
126
+ def outer_html(options = {})
127
+ operations[:outer_html] << options
128
+ end
129
+
130
+ def text_content(options = {})
127
131
  operations[:text_content] << options
128
132
  end
129
133
 
130
- def insert_adjacent_html(options={})
134
+ def insert_adjacent_html(options = {})
131
135
  operations[:insert_adjacent_html] << options
132
136
  end
133
137
 
134
- def insert_adjacent_text(options={})
138
+ def insert_adjacent_text(options = {})
135
139
  operations[:insert_adjacent_text] << options
136
140
  end
137
141
 
138
- def remove(options={})
142
+ def remove(options = {})
139
143
  operations[:remove] << options
140
144
  end
141
145
 
142
- def replace(options={})
143
- operations[:replace] << options
144
- end
145
-
146
- def set_value(options={})
146
+ def set_value(options = {})
147
147
  operations[:set_value] << options
148
148
  end
149
149
 
150
- def set_attribute(options={})
150
+ def set_attribute(options = {})
151
151
  operations[:set_attribute] << options
152
152
  end
153
153
 
154
- def remove_attribute(options={})
154
+ def remove_attribute(options = {})
155
155
  operations[:remove_attribute] << options
156
156
  end
157
157
 
158
- def add_css_class(options={})
158
+ def add_css_class(options = {})
159
159
  operations[:add_css_class] << options
160
160
  end
161
161
 
162
- def remove_css_class(options={})
162
+ def remove_css_class(options = {})
163
163
  operations[:remove_css_class] << options
164
164
  end
165
165
 
166
- def set_dataset_property(options={})
166
+ def set_dataset_property(options = {})
167
167
  operations[:set_dataset_property] << options
168
168
  end
169
169
 
170
170
  private
171
171
 
172
- def stub
173
- {
174
- dispatch_event: [],
175
- morph: [],
176
- inner_html: [],
177
- text_content: [],
178
- insert_adjacent_html: [],
179
- insert_adjacent_text: [],
180
- remove: [],
181
- replace: [],
182
- set_value: [],
183
- set_attribute: [],
184
- remove_attribute: [],
185
- add_css_class: [],
186
- remove_css_class: [],
187
- set_dataset_property: []
188
- }
189
- end
172
+ def stub
173
+ {
174
+ dispatch_event: [],
175
+ morph: [],
176
+ inner_html: [],
177
+ outer_html: [],
178
+ text_content: [],
179
+ insert_adjacent_html: [],
180
+ insert_adjacent_text: [],
181
+ remove: [],
182
+ set_value: [],
183
+ set_attribute: [],
184
+ remove_attribute: [],
185
+ add_css_class: [],
186
+ remove_css_class: [],
187
+ set_dataset_property: [],
188
+ }
189
+ end
190
190
  end
191
191
  end
@@ -1,3 +1,3 @@
1
1
  module CableReady
2
- VERSION = "2.0.8"
2
+ VERSION = "3.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cable_ready
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.8
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Hopkins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-25 00:00:00.000000000 Z
11
+ date: 2019-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: standardrb
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry-test
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
41
69
  description:
42
70
  email:
43
71
  - natehop@gmail.com
@@ -51,8 +79,10 @@ files:
51
79
  - README.md
52
80
  - Rakefile
53
81
  - app/assets/javascripts/cable_ready.js
82
+ - bin/cloc
54
83
  - bin/console
55
84
  - bin/setup
85
+ - bin/standardize
56
86
  - bin/webpack
57
87
  - bin/yarn
58
88
  - lib/cable_ready.rb
@@ -79,8 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
109
  - !ruby/object:Gem::Version
80
110
  version: '0'
81
111
  requirements: []
82
- rubyforge_project:
83
- rubygems_version: 2.7.6
112
+ rubygems_version: 3.0.3
84
113
  signing_key:
85
114
  specification_version: 4
86
115
  summary: Out-of-Band Server Triggered DOM Operations