lazy_images-rails 1.1.1 → 1.2.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: 643784a2611cce70c7c98b03f5a657ae3349d796
4
- data.tar.gz: 2390a7ba3d54ffc12fca143cd1165d738d54a368
3
+ metadata.gz: 32743667e6924942ba8ddcec2783d963de1c87db
4
+ data.tar.gz: b4b3c6e7618906ecba0b61a8e563978f88a56c9c
5
5
  SHA512:
6
- metadata.gz: 7b5e9c27a5dc052d0a3d2176b8e2558239bb8d33bf90d3550f6b249fa6c0ac19b0d8b29794e29b936977fc4a70037cb21c5a4f1bdefbddc3ffb5402f355c1589
7
- data.tar.gz: 68121f9b1988c0278563fa6690379e1573f7b83c2eb0dc7cc88a59c9d2954f6f3a7aecb5d874d36ff2367394cdbd53646b75bb1df642505978af5cb09983b8a0
6
+ metadata.gz: be533d06e7faba168df5e585999ed70f87efb8da5053da4fd677f5063170af3d75470dd45b70774e4fb73a37bd4b47adb3c5fa750b182ef5efd3bd297b065fe2
7
+ data.tar.gz: b2654552eaace63a247e280b3eea92b90244d17598b0478ef9252a285d1590727320ee06a2ffe48f0e73d2b014da4d780c2e0b3c5440b42d88ad9bace5e72b8e
@@ -1,24 +1,21 @@
1
1
  class @LazyImagesRails
2
2
  @init: (all_replaced) ->
3
3
  replace_with_image = (placeholder) =>
4
- svg = placeholder.querySelector('svg')
5
-
6
- width = svg.attributes.width
7
- height = svg.attributes.height
8
- img = null
9
-
10
- if width? && height?
11
- img = new Image(parseInt(width.value, 10), parseInt(height.value, 10))
12
- else
13
- img = new Image()
4
+ noscript = placeholder.querySelector('noscript')
5
+ method = if 'innerText' in noscript then 'innerText' else 'textContent'
6
+ content = noscript[method]
14
7
 
8
+ tmp = document.createElement('div')
9
+ tmp.innerHTML = content # will trigger download of image
10
+ img = tmp.querySelector('img')
11
+ # Race condition:
12
+ # Event attachment happens after the download triggers above.
13
+ # If image loads before getting here, the callback never runs.
15
14
  img.onload = =>
16
15
  placeholder.parentNode.replaceChild(img, placeholder)
17
16
  if all_replaced? && --@placeholder_count == 0
18
17
  all_replaced.call()
19
18
 
20
- img.src = placeholder.dataset.rliImageSrc
21
-
22
19
  placeholders = document.querySelectorAll('div[data-rli-placeholder]')
23
20
  @placeholder_count = placeholders.length
24
21
 
@@ -1,5 +1,5 @@
1
1
  module LazyImages
2
2
  module Rails
3
- VERSION = "1.1.1"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lazy_images-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - René Hansen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-21 00:00:00.000000000 Z
11
+ date: 2015-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails