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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45e9793d133a86495296d7037647c52210173485
|
4
|
+
data.tar.gz: 8ef659e8c84fad1632f164c218612ec2ed4cb865
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
77
|
-
|
78
|
-
|
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
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
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
|
|