web_components_rails 1.1.0 → 1.1.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: 4616f8671aeb678bfe6d123e1fd8ac02d855e472
4
- data.tar.gz: 81c4c56577ef7b1cf492872597a69ae0384cfa19
3
+ metadata.gz: 45e9793d133a86495296d7037647c52210173485
4
+ data.tar.gz: 8ef659e8c84fad1632f164c218612ec2ed4cb865
5
5
  SHA512:
6
- metadata.gz: cdec8bfd0dab8414ae902409ac78d13bb4bb0c13265092b11a3f4e5561fbcac97c0fdf2fa5bba46f0f9e908ffbd98c6498e9c5e94f76d904eaf2af13d4ce39f7
7
- data.tar.gz: 673f4240b5efb0b23fa829022eb6b71a0893744c65c7f2c9ff81f220b7a7136d0d4839781fa57142e168a24751034ee5c823edffc9ee80a920b26773ba0a793c
6
+ metadata.gz: 4b6c383f3745e352f89144b13e4228ab966da06951060c8ec39d118d12f7f875ad6713a73817aa1692a9d7662cbadcac355d81efa9064d71941c5ce28770752a
7
+ data.tar.gz: 6f3e88e90b22e985817c124e0cef7e8e7e9669c129f43978f5878461d302a87136057dafb6ac7926695b81bbba4caa761bad6633eece0d8360f3dc31d6858399
@@ -73,9 +73,12 @@ class WebComponentsRails::HTMLImportProcessor
73
73
  when 'css', 'text/css'
74
74
  asset = ::Rails.application.assets.find_asset(path, accept: 'text/css')
75
75
  # Replace it inline with a style node containing the referenced CSS
76
- style = Nokogiri::XML::Element.new('style', doc)
77
- style.inner_html = asset.source
78
- link.replace(style)
76
+ if asset
77
+ style = Nokogiri::XML::Element.new('style', doc)
78
+ style['original-href'] = href
79
+ style.content = "\n" + asset.source
80
+ link.replace(style)
81
+ end
79
82
  nil
80
83
  # Ignore unknown types
81
84
  else
@@ -86,16 +89,20 @@ class WebComponentsRails::HTMLImportProcessor
86
89
  # Script/JS imports should just have their src rewritten to work with sprockets
87
90
  # (because they could repeat a lot, and we can't mark non-HTML files as dependencies)
88
91
  doc.css('script[src]').map do |script|
89
- puts "SCRIPT"
90
92
  src = script.attributes['src'].value
91
93
  if src.present?
92
94
  # Some references may try to be relative to the bower_components root,
93
95
  # which is already in the asset pipeline search path; fix those
94
96
  # (eg. from 'web_components/lib-a/foo.html', <script src='../lib-b/bar.js'> -> 'lib-b/bar.js')
95
- src = src.sub(/^..\//, '')
96
- new_script = Nokogiri::XML::Element.new('script', doc)
97
- new_script['src'] = @context.asset_path(src)
98
- script.replace(new_script)
97
+ path = href_to_asset_path(src, base_dir)
98
+ asset = ::Rails.application.assets.find_asset(path, accept: 'application/javascript')
99
+ # Replace it with a script tag containing the referenced JS inline
100
+ if asset
101
+ new_script = Nokogiri::XML::Element.new('script', doc)
102
+ new_script['original-src'] = src
103
+ new_script.content = "\n" + asset.source
104
+ script.replace(new_script)
105
+ end
99
106
  end
100
107
  end
101
108
 
@@ -1,3 +1,3 @@
1
1
  module WebComponentsRails
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web_components_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Botelho