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
|
||||
// upon encountering the unsupported parameter value "browser_action", so we have to catch it.
|
||||
|
||||
try {
|
||||
chrome.contextMenus.create({
|
||||
id: "show-badge", title: chrome.i18n.getMessage("menuShowBadge"),
|
||||
type: "checkbox", contexts: ["browser_action"], checked: prefs.getPref("show-badge")
|
||||
|
@ -85,6 +85,7 @@ chrome.contextMenus.create({
|
|||
id: "disableAll", title: chrome.i18n.getMessage("disableAllStyles"),
|
||||
type: "checkbox", contexts: ["browser_action"], checked: prefs.getPref("disableAll")
|
||||
}, function() { var clearError = chrome.runtime.lastError; });
|
||||
} catch(e) {}
|
||||
chrome.contextMenus.onClicked.addListener(function(info, tab) {
|
||||
if (info.menuItemId == "disableAll") {
|
||||
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];
|
||||
});
|
||||
|
||||
// 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
|
||||
var commandsToReroute = {
|
||||
save: true, jumpToLine: true, nextEditor: true, prevEditor: true,
|
||||
|
|
|
@ -35,13 +35,14 @@ function tNodeList(nodes) {
|
|||
if (node.nodeType != 1) { // not an ELEMENT_NODE
|
||||
continue;
|
||||
}
|
||||
for (var a = 0; a < node.attributes.length; a++) {
|
||||
var name = node.attributes[a].nodeName;
|
||||
for (var a = node.attributes.length - 1; a >= 0; a--) {
|
||||
var attr = node.attributes[a];
|
||||
var name = attr.nodeName;
|
||||
if (name.indexOf("i18n-") != 0) {
|
||||
continue;
|
||||
}
|
||||
name = name.substr(5); // "i18n-".length
|
||||
var value = t(node.attributes[a].nodeValue);
|
||||
var value = t(attr.nodeValue);
|
||||
switch (name) {
|
||||
case "text":
|
||||
node.insertBefore(document.createTextNode(value), node.firstChild);
|
||||
|
@ -52,6 +53,7 @@ function tNodeList(nodes) {
|
|||
default:
|
||||
node.setAttribute(name, value);
|
||||
}
|
||||
node.removeAttributeNode(attr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,5 +71,6 @@ function tDocLoader() {
|
|||
observer.observe(document, {subtree: true, childList: true});
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
observer.disconnect();
|
||||
tNodeList(document.querySelectorAll("*"));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -271,7 +271,7 @@ function shallowCopy(obj) {
|
|||
}
|
||||
|
||||
function equal(a, b) {
|
||||
if (!a || !b || typeof a != "object") {
|
||||
if (!a || !b || typeof a != "object" || typeof b != "object") {
|
||||
return a === b;
|
||||
}
|
||||
if (Object.keys(a).length != Object.keys(b).length) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user