Skip to content

Commit ee538b1

Browse files
authored
Merge branch 'master' into master
2 parents 40620b5 + fae625b commit ee538b1

File tree

9 files changed

+744
-22
lines changed

9 files changed

+744
-22
lines changed

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,12 @@ Set to true to have the resulting image take into account scroll positioning, th
164164
It's tested on latest Chrome and Firefox (49 and 45 respectively at the time
165165
of writing), with Chrome performing significantly better on big DOM trees,
166166
possibly due to it's more performant SVG support, and the fact that it supports
167-
`CSSStyleDeclaration.cssText` property.
167+
`CSSStyleDeclaration.cssText` property.
168+
168169
_Internet Explorer is not (and will not be) supported, as it does not support
169-
SVG `<foreignObject>` tag_
170+
SVG `<foreignObject>` tag_
171+
172+
_Safari [is not supported](https://github.com/tsayen/dom-to-image/issues/27), as it uses a stricter security model on `<foreignObject`> tag. Suggested workaround is to use `toSvg` and render on the server._`
170173

171174
## Dependencies
172175

bower.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dom-to-image",
3-
"version": "2.5.2",
3+
"version": "2.6.0",
44
"homepage": "https://github.com/tsayen/dom-to-image",
55
"authors": [
66
"Anatolii Saienko <[email protected]>"
@@ -29,7 +29,6 @@
2929
"devDependencies": {
3030
"js-imagediff": "~1.0.8",
3131
"jquery": "~2.1.3",
32-
"fontawesome": "~4.4.0",
33-
"ocrad-bower": "*"
32+
"fontawesome": "~4.4.0"
3433
}
3534
}

dist/dom-to-image.min.js

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

karma.conf.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = function (config) {
2020

2121
'bower_components/jquery/dist/jquery.js',
2222
'bower_components/js-imagediff/imagediff.js',
23-
'bower_components/ocrad-bower/ocrad.js',
23+
'test-lib/tesseract-1.0.10.js',
2424

2525
'src/dom-to-image.js',
2626
'spec/dom-to-image.spec.js'

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dom-to-image",
3-
"version": "2.5.2",
3+
"version": "2.6.0",
44
"description": "Generates an image from a DOM node using HTML5 canvas and SVG",
55
"main": "src/dom-to-image.js",
66
"dependencies": {},

spec/dom-to-image.spec.js

+19-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
var imagediff = global.imagediff;
66
var domtoimage = global.domtoimage;
77
var Promise = global.Promise;
8-
var ocr = global.OCRAD;
98

109
var delay = domtoimage.impl.util.delay;
1110

@@ -124,6 +123,7 @@
124123
});
125124

126125
it('should render text nodes', function (done) {
126+
this.timeout(10000);
127127
loadTestPage('text/dom-node.html', 'text/style.css')
128128
.then(renderToPng)
129129
.then(drawDataUrl)
@@ -132,11 +132,12 @@
132132
});
133133

134134
it('should preserve content of ::before and ::after pseudo elements', function (done) {
135+
this.timeout(10000);
135136
loadTestPage('pseudo/dom-node.html', 'pseudo/style.css')
136137
.then(renderToPng)
137138
.then(drawDataUrl)
138-
.then(assertTextRendered(["ONLYBEFORE", "BOTHBEFORE"]))
139-
.then(assertTextRendered(["ONLYAFTER", "BOTHAFTER"]))
139+
.then(assertTextRendered(["JUSTBEFORE", "BOTHBEFORE"]))
140+
.then(assertTextRendered(["JUSTAFTER", "BOTHAFTER"]))
140141
.then(done).catch(done);
141142
});
142143

@@ -185,7 +186,7 @@
185186
.then(delay(1000))
186187
.then(renderToPng)
187188
.then(drawDataUrl)
188-
.then(assertTextRendered(['o']))
189+
.then(assertTextRendered(['O']))
189190
.then(done).catch(done);
190191
});
191192

@@ -237,11 +238,11 @@
237238
ctx.fillRect(0, 0, canvas.width, canvas.height);
238239
ctx.fillStyle = '#000000';
239240
ctx.font = '100px monospace';
240-
ctx.fillText('o', canvas.width / 2, canvas.height / 2);
241+
ctx.fillText('0', canvas.width / 2, canvas.height / 2);
241242
})
242243
.then(renderToPng)
243244
.then(drawDataUrl)
244-
.then(assertTextRendered(["o"]))
245+
.then(assertTextRendered(['0']))
245246
.then(done).catch(done);
246247
});
247248

@@ -384,9 +385,18 @@
384385

385386
function assertTextRendered(lines) {
386387
return function () {
387-
var renderedText = ocr(canvas());
388-
lines.forEach(function (line) {
389-
assert.include(renderedText, line);
388+
return new Promise(function (resolve, reject) {
389+
Tesseract.recognize(canvas())
390+
.then(function(result) {
391+
lines.forEach(function(line) {
392+
try {
393+
assert.include(result.text, line);
394+
} catch(e) {
395+
reject(e);
396+
}
397+
});
398+
resolve();
399+
});
390400
});
391401
};
392402
}

spec/resources/pseudo/style.css

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.with-before::before {
2-
content: 'ONLYBEFORE';
2+
content: 'JUSTBEFORE';
33
}
44
.with-after::after {
5-
content: 'ONLYAFTER';
5+
content: 'JUSTAFTER';
66
}
77
.with-both::before {
88
content: 'BOTHBEFORE';
@@ -13,6 +13,6 @@
1313

1414
#dom-node {
1515
background-color: white;
16-
font-family: monospace;
16+
font-family: sans-serif;
1717
font-size: 20px;
1818
}

src/dom-to-image.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
} else {
150150
domtoimage.impl.options.cacheBust = options.cacheBust;
151151
}
152-
152+
153153
if(typeof(options.scrollFix) === 'undefined') {
154154
domtoimage.impl.options.scrollFix = defaultOptions.scrollFix;
155155
} else {

0 commit comments

Comments
 (0)