Skip to content

Commit 95654d0

Browse files
author
Christoph Burgmer
committed
Document background image url issue in code
1 parent 876429d commit 95654d0

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

dist/rasterizeHTML.allinone.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rasterizeHTML.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! rasterizeHTML.js - v0.4.1 - 2013-04-10
1+
/*! rasterizeHTML.js - v0.4.1 - 2013-05-25
22
* http://www.github.com/cburgmer/rasterizeHTML.js
33
* Copyright (c) 2013 Christoph Burgmer; Licensed MIT */
44

@@ -291,8 +291,14 @@ window.rasterizeHTMLInline = (function (module, window, CSSOM) {
291291
return getArrayForArrayLike(rules);
292292
};
293293

294+
var browserHasBackgroundImageUrlIssue = (function () {
295+
// Checks for http://code.google.com/p/chromium/issues/detail?id=161644
296+
var rules = rulesForCssTextFromBrowser('a{background:url(i)}');
297+
return !rules.length || rules[0].cssText.indexOf('url()') >= 0;
298+
}());
299+
294300
module.css.rulesForCssText = function (styleContent) {
295-
if (CSSOM.parse && window.navigator.userAgent.indexOf("Chrome") >= 0) {
301+
if (browserHasBackgroundImageUrlIssue && CSSOM.parse) {
296302
return CSSOM.parse(styleContent).cssRules;
297303
} else {
298304
return rulesForCssTextFromBrowser(styleContent);

dist/rasterizeHTML.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/inlineCss.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,14 @@ window.rasterizeHTMLInline = (function (module, window, CSSOM) {
2020
return getArrayForArrayLike(rules);
2121
};
2222

23+
var browserHasBackgroundImageUrlIssue = (function () {
24+
// Checks for http://code.google.com/p/chromium/issues/detail?id=161644
25+
var rules = rulesForCssTextFromBrowser('a{background:url(i)}');
26+
return !rules.length || rules[0].cssText.indexOf('url()') >= 0;
27+
}());
28+
2329
module.css.rulesForCssText = function (styleContent) {
24-
if (CSSOM.parse && window.navigator.userAgent.indexOf("Chrome") >= 0) {
30+
if (browserHasBackgroundImageUrlIssue && CSSOM.parse) {
2531
return CSSOM.parse(styleContent).cssRules;
2632
} else {
2733
return rulesForCssTextFromBrowser(styleContent);

0 commit comments

Comments
 (0)