fixes for Chrome 31
This commit is contained in:
parent
a3401b0572
commit
ae8683873a
|
@ -76,7 +76,7 @@ chrome.commands.onCommand.addListener(function(command) {
|
||||||
|
|
||||||
// contextMenus API is present in ancient Chrome but it throws an exception
|
// contextMenus API is present in ancient Chrome but it throws an exception
|
||||||
// upon encountering the unsupported parameter value "browser_action", so we have to catch it.
|
// upon encountering the unsupported parameter value "browser_action", so we have to catch it.
|
||||||
|
try {
|
||||||
chrome.contextMenus.create({
|
chrome.contextMenus.create({
|
||||||
id: "show-badge", title: chrome.i18n.getMessage("menuShowBadge"),
|
id: "show-badge", title: chrome.i18n.getMessage("menuShowBadge"),
|
||||||
type: "checkbox", contexts: ["browser_action"], checked: prefs.getPref("show-badge")
|
type: "checkbox", contexts: ["browser_action"], checked: prefs.getPref("show-badge")
|
||||||
|
@ -85,6 +85,7 @@ chrome.contextMenus.create({
|
||||||
id: "disableAll", title: chrome.i18n.getMessage("disableAllStyles"),
|
id: "disableAll", title: chrome.i18n.getMessage("disableAllStyles"),
|
||||||
type: "checkbox", contexts: ["browser_action"], checked: prefs.getPref("disableAll")
|
type: "checkbox", contexts: ["browser_action"], checked: prefs.getPref("disableAll")
|
||||||
}, function() { var clearError = chrome.runtime.lastError; });
|
}, function() { var clearError = chrome.runtime.lastError; });
|
||||||
|
} catch(e) {}
|
||||||
chrome.contextMenus.onClicked.addListener(function(info, tab) {
|
chrome.contextMenus.onClicked.addListener(function(info, tab) {
|
||||||
if (info.menuItemId == "disableAll") {
|
if (info.menuItemId == "disableAll") {
|
||||||
disableAllStylesToggle(info.checked);
|
disableAllStylesToggle(info.checked);
|
||||||
|
|
3
edit.js
3
edit.js
|
@ -58,6 +58,9 @@ var jumpToLineTemplate = t('editGotoLine') + ': <input class="CodeMirror-jump-fi
|
||||||
NodeList.prototype[method]= Array.prototype[method];
|
NodeList.prototype[method]= Array.prototype[method];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Chrome pre-34
|
||||||
|
Element.prototype.matches = Element.prototype.matches || Element.prototype.webkitMatchesSelector;
|
||||||
|
|
||||||
// reroute handling to nearest editor when keypress resolves to one of these commands
|
// reroute handling to nearest editor when keypress resolves to one of these commands
|
||||||
var commandsToReroute = {
|
var commandsToReroute = {
|
||||||
save: true, jumpToLine: true, nextEditor: true, prevEditor: true,
|
save: true, jumpToLine: true, nextEditor: true, prevEditor: true,
|
||||||
|
|
|
@ -35,13 +35,14 @@ function tNodeList(nodes) {
|
||||||
if (node.nodeType != 1) { // not an ELEMENT_NODE
|
if (node.nodeType != 1) { // not an ELEMENT_NODE
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (var a = 0; a < node.attributes.length; a++) {
|
for (var a = node.attributes.length - 1; a >= 0; a--) {
|
||||||
var name = node.attributes[a].nodeName;
|
var attr = node.attributes[a];
|
||||||
|
var name = attr.nodeName;
|
||||||
if (name.indexOf("i18n-") != 0) {
|
if (name.indexOf("i18n-") != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
name = name.substr(5); // "i18n-".length
|
name = name.substr(5); // "i18n-".length
|
||||||
var value = t(node.attributes[a].nodeValue);
|
var value = t(attr.nodeValue);
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case "text":
|
case "text":
|
||||||
node.insertBefore(document.createTextNode(value), node.firstChild);
|
node.insertBefore(document.createTextNode(value), node.firstChild);
|
||||||
|
@ -52,6 +53,7 @@ function tNodeList(nodes) {
|
||||||
default:
|
default:
|
||||||
node.setAttribute(name, value);
|
node.setAttribute(name, value);
|
||||||
}
|
}
|
||||||
|
node.removeAttributeNode(attr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,5 +71,6 @@ function tDocLoader() {
|
||||||
observer.observe(document, {subtree: true, childList: true});
|
observer.observe(document, {subtree: true, childList: true});
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
observer.disconnect();
|
observer.disconnect();
|
||||||
|
tNodeList(document.querySelectorAll("*"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,7 +271,7 @@ function shallowCopy(obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function equal(a, b) {
|
function equal(a, b) {
|
||||||
if (!a || !b || typeof a != "object") {
|
if (!a || !b || typeof a != "object" || typeof b != "object") {
|
||||||
return a === b;
|
return a === b;
|
||||||
}
|
}
|
||||||
if (Object.keys(a).length != Object.keys(b).length) {
|
if (Object.keys(a).length != Object.keys(b).length) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user