Socket
Socket
Sign inDemoInstall

html2canvas

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html2canvas - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

23

CHANGELOG.md

@@ -5,2 +5,25 @@ # Changelog

## [1.2.2](https://github.com/niklasvh/html2canvas/compare/v1.2.1...v1.2.2) (2021-08-10)
### ci
* add ios15 target (#2564) ([e429e04](https://github.com/niklasvh/html2canvas/commit/e429e0443adf5c7ca3041b97a8157b8911302206)), closes [#2564](https://github.com/niklasvh/html2canvas/issues/2564)
### docs
* update test previewer (#2637) ([7a06d0c](https://github.com/niklasvh/html2canvas/commit/7a06d0c2c2f3b8a1d1a8a85c540f8288b782e8c6)), closes [#2637](https://github.com/niklasvh/html2canvas/issues/2637)
### fix
* parsing counter content in pseudo element (#2640) ([1941b9e](https://github.com/niklasvh/html2canvas/commit/1941b9e0acfd9243da0beaf70e1643cab1b4a963)), closes [#2640](https://github.com/niklasvh/html2canvas/issues/2640)
* radial gradient ry check (#2631) ([a0dd38a](https://github.com/niklasvh/html2canvas/commit/a0dd38a8be4e540ae1c1f4b4e41f6c386f3e454f)), closes [#2631](https://github.com/niklasvh/html2canvas/issues/2631)
* test for ios range line break error (#2635) ([f43f942](https://github.com/niklasvh/html2canvas/commit/f43f942fcd793dde9cdc6c0438f379ec3c05c405)), closes [#2635](https://github.com/niklasvh/html2canvas/issues/2635)
### test
* large base64 encoded background (#2636) ([e36408a](https://github.com/niklasvh/html2canvas/commit/e36408ad030fe31acd9969a37fe24c1621c0bd04)), closes [#2636](https://github.com/niklasvh/html2canvas/issues/2636)
## [1.2.1](https://github.com/niklasvh/html2canvas/compare/v1.2.0...v1.2.1) (2021-08-05)

@@ -7,0 +30,0 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FEATURES = exports.loadSerializedSVG = exports.createForeignObjectSVG = void 0;
var css_line_break_1 = require("css-line-break");
var testRangeBounds = function (document) {

@@ -24,2 +25,32 @@ var TEST_HEIGHT = 123;

};
var testIOSLineBreak = function (document) {
var testElement = document.createElement('boundtest');
testElement.style.width = '50px';
testElement.style.display = 'block';
testElement.style.fontSize = '12px';
testElement.style.letterSpacing = '0px';
testElement.style.wordSpacing = '0px';
document.body.appendChild(testElement);
var range = document.createRange();
testElement.innerHTML = typeof ''.repeat === 'function' ? '👨'.repeat(10) : '';
var node = testElement.firstChild;
var textList = css_line_break_1.toCodePoints(node.data).map(function (i) { return css_line_break_1.fromCodePoint(i); });
var offset = 0;
var prev = {};
// ios 13 does not handle range getBoundingClientRect line changes correctly #2177
var supports = textList.every(function (text, i) {
range.setStart(node, offset);
range.setEnd(node, offset + text.length);
var rect = range.getBoundingClientRect();
offset += text.length;
var boundAhead = rect.x > prev.x || rect.y > prev.y;
prev = rect;
if (i === 0) {
return true;
}
return boundAhead;
});
document.body.removeChild(testElement);
return supports;
};
var testCORS = function () { return typeof new Image().crossOrigin !== 'undefined'; };

@@ -117,2 +148,8 @@ var testResponseType = function () { return typeof new XMLHttpRequest().responseType === 'string'; };

},
get SUPPORT_WORD_BREAKING() {
'use strict';
var value = exports.FEATURES.SUPPORT_RANGE_BOUNDS && testIOSLineBreak(document);
Object.defineProperty(exports.FEATURES, 'SUPPORT_WORD_BREAKING', { value: value });
return value;
},
get SUPPORT_SVG_DRAWING() {

@@ -119,0 +156,0 @@ 'use strict';

@@ -17,2 +17,9 @@ "use strict";

};
Bounds.fromDOMRectList = function (context, domRectList) {
var domRect = domRectList[0];
return domRect
? new Bounds(domRect.x + context.windowBounds.left, domRect.y + context.windowBounds.top, domRect.width, domRect.height)
: Bounds.EMPTY;
};
Bounds.EMPTY = new Bounds(0, 0, 0, 0);
return Bounds;

@@ -19,0 +26,0 @@ }());

16

dist/lib/css/layout/text.js

@@ -23,3 +23,8 @@ "use strict";

if (features_1.FEATURES.SUPPORT_RANGE_BOUNDS) {
textBounds.push(new TextBounds(text, getRangeBounds(context, node, offset, text.length)));
if (!features_1.FEATURES.SUPPORT_WORD_BREAKING) {
textBounds.push(new TextBounds(text, bounds_1.Bounds.fromDOMRectList(context, createRange(node, offset, text.length).getClientRects())));
}
else {
textBounds.push(new TextBounds(text, getRangeBounds(context, node, offset, text.length)));
}
}

@@ -55,5 +60,5 @@ else {

}
return new bounds_1.Bounds(0, 0, 0, 0);
return bounds_1.Bounds.EMPTY;
};
var getRangeBounds = function (context, node, offset, length) {
var createRange = function (node, offset, length) {
var ownerDocument = node.ownerDocument;

@@ -66,4 +71,7 @@ if (!ownerDocument) {

range.setEnd(node, offset + length);
return bounds_1.Bounds.fromClientRect(context, range.getBoundingClientRect());
return range;
};
var getRangeBounds = function (context, node, offset, length) {
return bounds_1.Bounds.fromClientRect(context, createRange(node, offset, length).getBoundingClientRect());
};
var breakText = function (value, styles) {

@@ -70,0 +78,0 @@ return styles.letterSpacing !== 0 ? css_line_break_1.toCodePoints(value).map(function (i) { return css_line_break_1.fromCodePoint(i); }) : breakWords(value, styles);

@@ -36,2 +36,5 @@ "use strict";

canReset = false;
if (!counter.length) {
counter.push(1);
}
counter[Math.max(0, counter.length - 1)] += entry.increment;

@@ -38,0 +41,0 @@ }

@@ -681,3 +681,3 @@ "use strict";

_g = gradient_1.calculateRadius(backgroundImage, x, y, width, height), rx = _g[0], ry = _g[1];
if (rx > 0 && rx > 0) {
if (rx > 0 && ry > 0) {
radialGradient_1 = this_1.ctx.createRadialGradient(left + x, top_1 + y, 0, left + x, top_1 + y, rx);

@@ -684,0 +684,0 @@ gradient_1.processColorStops(backgroundImage.stops, rx * 2).forEach(function (colorStop) {

@@ -5,2 +5,3 @@ export declare const createForeignObjectSVG: (width: number, height: number, x: number, y: number, node: Node) => SVGForeignObjectElement;

readonly SUPPORT_RANGE_BOUNDS: boolean;
readonly SUPPORT_WORD_BREAKING: boolean;
readonly SUPPORT_SVG_DRAWING: boolean;

@@ -7,0 +8,0 @@ readonly SUPPORT_FOREIGNOBJECT_DRAWING: Promise<boolean>;

@@ -10,4 +10,6 @@ import { Context } from '../../core/context';

static fromClientRect(context: Context, clientRect: ClientRect): Bounds;
static fromDOMRectList(context: Context, domRectList: DOMRectList): Bounds;
static EMPTY: Bounds;
}
export declare const parseBounds: (context: Context, node: Element) => Bounds;
export declare const parseDocumentSize: (document: Document) => Bounds;
import { LIST_STYLE_TYPE } from '../../property-descriptors/list-style-type';
import { CSSParsedCounterDeclaration } from '../../index';
export declare class CounterState {
readonly counters: {
[key: string]: number[];
};
constructor();
private readonly counters;
getCounterValue(name: string): number;
getCounterValues(name: string): number[];
getCounterValues(name: string): readonly number[];
pop(counters: string[]): void;

@@ -11,0 +8,0 @@ parse(style: CSSParsedCounterDeclaration): string[];

@@ -9,3 +9,3 @@ {

"browser": "dist/html2canvas.js",
"version": "1.2.1",
"version": "1.2.2",
"author": {

@@ -12,0 +12,0 @@ "name": "Niklas von Hertzen",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc