Skip to content

Commit

Permalink
Handle legacy attributes on <body>
Browse files Browse the repository at this point in the history
  • Loading branch information
Gofake1 committed May 30, 2019
1 parent 84895d3 commit 67fd7e0
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion SafariExtension/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ function start() {
.reduce(makeStyleBundle, []);
const bgColors = [].slice.call(document.querySelectorAll('[bgcolor]'))
.reduce(makeBgColorBundle, []);
const bodyColors = ['text', 'link', 'alink', 'vlink'].reduce(makeBodyColorBundle, []);
const fontColors = [].slice.call(document.querySelectorAll('font[color]'))
.reduce(makeFontColorBundle, []);
const svgFills = [].slice.call(document.querySelectorAll('[fill]'))
Expand All @@ -240,7 +241,7 @@ function start() {
const images = [].slice.call(document.getElementsByTagName('img'))
.reduce(makeImageBundle, []);
return builtins.concat(overrides).concat(styles).concat(bgColors)
.concat(fontColors).concat(svgFills).concat(images);
.concat(bodyColors).concat(fontColors).concat(svgFills).concat(images);
}

// --- Bundle helpers ---
Expand Down Expand Up @@ -306,6 +307,17 @@ function makeBgColorBundle(arr, node) {
return arr;
}

function makeBodyColorBundle(arr, bodyAttr) {
const value = document.body.getAttribute(bodyAttr);
if(value) {
const newValue = makeLightStyleColor(value);
if(newValue) {
arr.push(new AttributeBundle(document.body, bodyAttr, value, newValue));
}
}
return arr;
}

function makeFontColorBundle(arr, node) {
const str = makeLightStyleColor(node.color);
if(str) {
Expand Down

0 comments on commit 67fd7e0

Please sign in to comment.