diff options
| author | mrmr1993 | 2015-04-28 15:00:01 +0100 | 
|---|---|---|
| committer | mrmr1993 | 2015-04-28 15:00:01 +0100 | 
| commit | fe9933796baa9fd1c1cf717b9055a5ebcdc18c41 (patch) | |
| tree | fd158a124db5a72c40d84984f9895893d4431468 | |
| parent | 96b7a256d007e7faee8eb23c41bf4a46ed99dabc (diff) | |
| download | vimium-fe9933796baa9fd1c1cf717b9055a5ebcdc18c41.tar.bz2 | |
Load stylesheet via XHR to fix styles in UIComponent Shadow DOM
Shadow DOM doesn't support <link>s, so we have to load the stylesheet
manually and inject it into a <style> element.
| -rw-r--r-- | content_scripts/ui_component.coffee | 15 | 
1 files changed, 10 insertions, 5 deletions
| diff --git a/content_scripts/ui_component.coffee b/content_scripts/ui_component.coffee index 64831794..21431bd7 100644 --- a/content_scripts/ui_component.coffee +++ b/content_scripts/ui_component.coffee @@ -5,11 +5,16 @@ class UIComponent    options: null    constructor: (iframeUrl, className, @handleMessage) -> -    styleSheet = document.createElement "link" -    extend styleSheet, -      rel: "stylesheet" -      type: "text/css" -      href: chrome.runtime.getURL "content_scripts/vimium.css" +    styleSheet = document.createElement "style" +    styleSheet.type = "text/css" +    # Default to everything hidden while the stylesheet loads. +    styleSheet.innerHTML = "* {display: none !important;}" +    # Load stylesheet. +    xhr = new XMLHttpRequest() +    xhr.onload = (e) -> styleSheet.innerHTML = xhr.responseText +    xhr.open "GET", chrome.runtime.getURL("content_scripts/vimium.css"), true +    xhr.send() +      @iframeElement = document.createElement "iframe"      extend @iframeElement,        className: className | 
