Skip to content

Commit a10ed30

Browse files
author
Matt Soltani
committed
Add base url when removing stylesheets
1 parent d776b2b commit a10ed30

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/domino-chains/return.coffee

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
url = require("url")
2+
13
module.exports = exports =
24
exposeStylesheets: (document, options, sheets, finalCSS, next) ->
35
return next(null) if not options.cssExpose or typeof options.cssExpose isnt "string"
46

57
name = options.cssExpose
6-
78
script = document.createElement("script")
89
script.innerHTML = "#{name} = #{JSON.stringify(sheets)};"
910
script.innerHTML = "var " + script.innerHTML if name.indexOf(".") < 0
@@ -15,7 +16,7 @@ module.exports = exports =
1516
links = document.querySelectorAll("link[rel='stylesheet']")
1617
linkForHref = (href) ->
1718
for link in links
18-
return link if link.href is href
19+
return link if href is url.resolve(options.url, link.href)
1920

2021
for sheet in sheets
2122
el = linkForHref(sheet.href)

lib/phantom-chains/return.coffee

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
url = require("url")
2+
13
module.exports = exports =
24
exposeStylesheets: (page, options, stylesheets, finalCSS, next) ->
35
return next(null) if not options.cssExpose or typeof options.cssExpose isnt "string"
@@ -19,7 +21,7 @@ module.exports = exports =
1921
links = document.querySelectorAll("link[rel='stylesheet']")
2022
linkForHref = (href) ->
2123
for link in links
22-
return link if link.href is href
24+
return link if href is url.resolve(options.url, link.href)
2325

2426
try
2527
for sheet in stylesheets

0 commit comments

Comments
 (0)