zipcode-rack 1.2.0 → 1.2.1

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: 9bebd4bab6dc70d16762e2b0485ed9993bdd3330
4
- data.tar.gz: 6c5a0b39b7a881955fcd75bf8ba44bea42198a0d
3
+ metadata.gz: 90ffb3fd8028dab924daaa8b7fe891e153ff16d4
4
+ data.tar.gz: e1d1f8810c15cd845bc12d17fda189b5894557ca
5
5
  SHA512:
6
- metadata.gz: df2fc8b878f6a4a2aaefa8b4535c50b2094b3720879466f6354e17d886690a229e92ba0be3c6fe6e8a192a8912401b2fa832d791f1df9c18ca8868202a22f41b
7
- data.tar.gz: 0742635ab688b3b7b9657d96b05b093fac732062b1926b0132929845113b70bc1aa613da1738ea91d636a02be19999246a6e7b119ddec966a4f426418caba2b5
6
+ metadata.gz: 8f288e090d970488309414c921626f0d6b98401680c8f8f1a52dd48dfa89f7a827347ab5a53657018f5ab9a809efc3097ed347a4d5d93734d5ae0616b5ca5abe
7
+ data.tar.gz: 92e38e2e74d8404a49911b09258216a8e83919644656f6a1af8a44662931b5749470b50f2d8cc7a396248a8647aedb3c5fb8875e39788cc996ef8f38de6408bb
@@ -311,6 +311,12 @@
311
311
  }
312
312
  }
313
313
 
314
+ function polyfillMaybe(node) {
315
+ if (node.nodeName === 'INPUT' && (node.getAttribute('type') === 'zip-city' || (node.getAttribute('type') === 'text' && node.classList.contains('zip-city')))) {
316
+ polyfill(node);
317
+ }
318
+ }
319
+
314
320
  function polyfillDocument() {
315
321
  var elements = document.querySelectorAll('input[type=zip-city], input[type=text].zip-city');
316
322
  for (var i = 0; i < elements.length; i++) {
@@ -318,14 +324,21 @@
318
324
  }
319
325
  }
320
326
 
327
+ function polyfillInsertedNodesFallback() {
328
+ document.addEventListener('DOMNodeInserted', function(e) {
329
+ polyfillMaybe(e.target);
330
+ });
331
+ }
332
+
321
333
  function polyfillInsertedNodes() {
334
+ if (typeof MutationObserver === 'undefined') {
335
+ return polyfillInsertedNodesFallback();
336
+ }
337
+
322
338
  var observer = new MutationObserver(function (mutations) {
323
339
  mutations.forEach(function (mutation) {
324
340
  for (var i = 0; i < mutation.addedNodes.length; i++) {
325
- var node = mutation.addedNodes[i];
326
- if (node.nodeName === 'INPUT' && (node.getAttribute('type') === 'zip-city' || (node.getAttribute('type') === 'text' && node.classList.contains('zip-city')))) {
327
- polyfill(node);
328
- }
341
+ polyfillMaybe(mutation.addedNodes[i]);
329
342
  }
330
343
  });
331
344
  });
@@ -354,4 +367,11 @@
354
367
  } else {
355
368
  document.addEventListener('DOMContentLoaded', handleLoaded);
356
369
  }
370
+
371
+ // polyfill IE
372
+ if (!('remove' in Element.prototype)) {
373
+ Element.prototype.remove = function() {
374
+ this.parentNode.removeChild(this);
375
+ };
376
+ }
357
377
  }).call(this);
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zipcode-rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Loic Nageleisen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-26 00:00:00.000000000 Z
11
+ date: 2015-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape