From e312050163f17e4a1339d68a01fee023a4fa51c4 Mon Sep 17 00:00:00 2001 From: Matt Colyer Date: Mon, 4 Nov 2013 16:21:50 -0800 Subject: [PATCH] Create valid DOM ids for stylesheets --- src/theme-manager.coffee | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/theme-manager.coffee b/src/theme-manager.coffee index ac0192dbc..34e0baac8 100644 --- a/src/theme-manager.coffee +++ b/src/theme-manager.coffee @@ -159,19 +159,23 @@ class ThemeManager #{e.message} """ + # Internal-only: + stringToId: (string) -> + string.replace(/\\/g, '') + # Internal-only: removeStylesheet: (stylesheetPath) -> unless fullPath = @resolveStylesheet(stylesheetPath) throw new Error("Could not find a file at path '#{stylesheetPath}'") - @stylesheetElementForId(fullPath).remove() + @stylesheetElementForId(@stringToId(fullPath)).remove() # Internal-only: - applyStylesheet: (id, text, ttype = 'bundled') -> - styleElement = @stylesheetElementForId(id) + applyStylesheet: (path, text, ttype = 'bundled') -> + styleElement = @stylesheetElementForId(@stringToId(path)) if styleElement.length styleElement.text(text) else if $("head style.#{ttype}").length - $("head style.#{ttype}:last").after "" + $("head style.#{ttype}:last").after "" else - $("head").append "" + $("head").append ""