Skip to content

Firefox: TypeError: can't access property "trim", t is undefined #532

@Mapaler

Description

@Mapaler

Not work in Firefox.

oops, something went wrong! TypeError: can't access property "trim", t is undefined debugger eval code:20:12

Expected Behavior

Generate pictures like Chrome

Current Behavior

Stopped because of an error

Possible Solution

There's nothing I can do

Steps To Reproduce

Sample URL
I use html2canvas for the screenshot button, please use the code to test html-to-image.

(()=>{
const script = document.createElement('script');
script.src = "https://unpkg.com/html-to-image";
document.head.appendChild(script);
const node = document.body.querySelector(".formation-box");

script.onload = () => {
	htmlToImage
		.toPng(node)
		.then((dataUrl) => {
			const img = new Image();
			img.src = dataUrl;
			document.body.appendChild(img);
			const downLink = document.body.querySelector(".down-capture");
			downLink.href = dataUrl;
			downLink.download = `screenshot.png`;
			downLink.click();
		})
		.catch((err) => {
			console.error('oops, something went wrong!', err);
		});
}


})();
Error Message & Stack Trace in Firefox Developer 139.0b10

<!-- Provide a log message if relevant -->
oops, something went wrong! TypeError: can't access property "trim", t is undefined
    K https://unpkg.com/html-to-image:1
    Y https://unpkg.com/html-to-image:1
    Y https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    u https://unpkg.com/html-to-image:1
    promise callback*a https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    Y https://unpkg.com/html-to-image:1
    Z https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    Z https://unpkg.com/html-to-image:1
    tt https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    u https://unpkg.com/html-to-image:1
    promise callback*a https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    tt https://unpkg.com/html-to-image:1
    et https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    et https://unpkg.com/html-to-image:1
    toPng https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    toPng https://unpkg.com/html-to-image:1
    onload debugger eval code:9
    EventHandlerNonNull* debugger eval code:7
    <anonymous> debugger eval code:25
debugger eval code:20:12
    onload debugger eval code:20
    (异步:promise callback)
    onload debugger eval code:19
    (异步:EventHandlerNonNull)
    <anonymous> debugger eval code:7
    <anonymous> debugger eval code:25

Error Message & Stack Trace in Firefox ESR 128.10.1esr

<!-- Provide a log message if relevant -->
Error inlining remote css file DOMException: CSSStyleSheet.cssRules getter: Not allowed to access cross-origin stylesheet
    J https://unpkg.com/html-to-image:1
    J https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    J https://unpkg.com/html-to-image:1
    X https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    X https://unpkg.com/html-to-image:1
    Y https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    Y https://unpkg.com/html-to-image:1
    Z https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    Z https://unpkg.com/html-to-image:1
    tt https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    u https://unpkg.com/html-to-image:1
    promise callback*a https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    tt https://unpkg.com/html-to-image:1
    et https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    et https://unpkg.com/html-to-image:1
    toPng https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    toPng https://unpkg.com/html-to-image:1
    onload debugger eval code:9
    EventHandlerNonNull* debugger eval code:7
    <anonymous> debugger eval code:25
html-to-image:1:16038

Error while reading CSS rules from null DOMException: CSSStyleSheet.cssRules getter: Not allowed to access cross-origin stylesheet
    J https://unpkg.com/html-to-image:1
    J https://unpkg.com/html-to-image:1
    promise callback*J/</< https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    J https://unpkg.com/html-to-image:1
    X https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    X https://unpkg.com/html-to-image:1
    Y https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    Y https://unpkg.com/html-to-image:1
    Z https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    Z https://unpkg.com/html-to-image:1
    tt https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    u https://unpkg.com/html-to-image:1
    promise callback*a https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    tt https://unpkg.com/html-to-image:1
    et https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    et https://unpkg.com/html-to-image:1
    toPng https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    toPng https://unpkg.com/html-to-image:1
    onload debugger eval code:9
    EventHandlerNonNull* debugger eval code:7
    <anonymous> debugger eval code:25
html-to-image:1:16240

oops, something went wrong! TypeError: t is undefined
    K https://unpkg.com/html-to-image:1
    Y https://unpkg.com/html-to-image:1
    Y https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    u https://unpkg.com/html-to-image:1
    promise callback*a https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    Y https://unpkg.com/html-to-image:1
    Z https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    Z https://unpkg.com/html-to-image:1
    tt https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    u https://unpkg.com/html-to-image:1
    promise callback*a https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    tt https://unpkg.com/html-to-image:1
    et https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    et https://unpkg.com/html-to-image:1
    toPng https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    c https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    e https://unpkg.com/html-to-image:1
    toPng https://unpkg.com/html-to-image:1
    onload debugger eval code:9
    EventHandlerNonNull* debugger eval code:7
    <anonymous> debugger eval code:25
debugger eval code:20:12

Additional Context

Your Environment

  • html-to-image: [e.g. 1.11.13]
  • OS: [e.g. Windows 10.0.19045.5912]
  • Browser: [e.g. Firefox Developer 139.0b10], [e.g. Firefox ESR 128.10.1esr]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions