Add window.removeStylesheet

This commit is contained in:
Corey Johnson
2012-12-26 17:35:19 -08:00
parent b08422bc6b
commit 5eb16d8304
4 changed files with 20 additions and 4 deletions

View File

@@ -65,9 +65,14 @@ windowAdditions =
requireStylesheet: (path) ->
unless fullPath = require.resolve(path)
throw new Error("requireStylesheet could not find a file at path '#{path}'")
throw new Error("Could not find a file at path '#{path}'")
window.applyStylesheet(fullPath, fs.read(fullPath))
removeStylesheet: (path) ->
unless fullPath = require.resolve(path)
throw new Error("Could not find a file at path '#{path}'")
$("head style[id='#{fullPath}']").remove()
applyStylesheet: (id, text) ->
unless $("head style[id='#{id}']").length
$('head').append "<style id='#{id}'>#{text}</style>"