Skip to content

Commit 1354338

Browse files
author
Benjamin Grand
committed
fix: use background-color on inline element
niklasvh#2558 niklasvh#3092
1 parent ab49c48 commit 1354338

File tree

4 files changed

+24
-10
lines changed

4 files changed

+24
-10
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
html2canvas with "skipClone"
1+
html2canvas enhanced
22
===========
33

44
## JavaScript HTML renderer ##
@@ -24,15 +24,15 @@ The library should work fine on the following browsers (with `Promise` polyfill)
2424
## Installation ##
2525

2626
```shell
27-
npm install html2canvas-[email protected]
27+
npm install html2canvas-enhanced
2828
```
2929

3030
### NPM package aliasing ###
3131

3232
```json
3333
{
3434
"dependencies": {
35-
"html2canvas": "npm:html2canvas-[email protected]"
35+
"html2canvas": "npm:html2canvas-enhanced"
3636
}
3737
}
3838
```

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
2-
"title": "html2canvas-skipclone",
3-
"name": "html2canvas-skipclone",
2+
"title": "html2canvas-enhanced",
3+
"name": "html2canvas-enhanced",
44
"description": "Screenshots with JavaScript",
5+
"version": "1.0.0",
6+
"license": "MIT",
57
"main": "dist/html2canvas.js",
68
"module": "dist/html2canvas.esm.js",
79
"typings": "dist/types/index.d.ts",
810
"browser": "dist/html2canvas.js",
9-
"version": "1.0.0",
10-
"license": "MIT",
1111
"scripts": {
1212
"prebuild": "rimraf dist/ && rimraf build/ && mkdirp dist && mkdirp build",
1313
"build": "tsc --module commonjs && rollup -c rollup.config.ts && npm run build:create-reftest-list && npm run build:testrunner && npm run build:minify",

src/render/canvas/canvas-renderer.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,21 @@ export class CanvasRenderer extends Renderer {
714714

715715
if (!isTransparent(styles.backgroundColor)) {
716716
this.ctx.fillStyle = asString(styles.backgroundColor);
717-
this.ctx.fill();
717+
718+
if (styles.display === DISPLAY.INLINE) {
719+
for (const textNode of paint.container.textNodes) {
720+
for (const textBound of textNode.textBounds) {
721+
this.ctx.fillRect(
722+
textBound.bounds.left,
723+
textBound.bounds.top,
724+
textBound.bounds.width,
725+
textBound.bounds.height
726+
);
727+
}
728+
}
729+
} else {
730+
this.ctx.fill();
731+
}
718732
}
719733

720734
await this.renderBackgroundImage(paint.container);

0 commit comments

Comments
 (0)