Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Fix behavior themes in Google Chrome #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 18 additions & 7 deletions ace-element.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@
// this.editor is not set, we create a dummy editor. At editor
// initialization time, any pending changes are synch'd.
ready: function() {
ace.require("ace/lib/dom").importCssString = function(cssText, id) {
if (this.styles[id]) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this fix in Atom Shell (Chromium) and I get an exception here if I don't initialise this.styles.

return;
}

this.styles[id] = cssText;
addStyle.bind(this)(id, this.shadowRoot);
}.bind(this);

function addStyle(id, el) {
var s = document.createElement('style');
s.textContent = this.styles[id];
el.appendChild(s);
};

for (var i in this.styles) {
addStyle.bind(this)(i, this.shadowRoot);
}
this.editor = ace.edit(document.createElement('div'));
},
enteredView: function() {
Expand All @@ -85,13 +103,6 @@
},
themeChanged: function() {
this.editor.setTheme('ace/theme/' + this.theme);
// find style
this.onMutation(document.head, function() {
var style = document.querySelector('#ace-' + this.theme);
if (style) {
this.shadowRoot.appendChild(cloneStyle(style));
}
});
},
valueChanged: function() {
this.editorValue = this.value;
Expand Down