html2canvas icon indicating copy to clipboard operation
html2canvas copied to clipboard

unexpected 'normal' characters in the generated image

Open 1757315673 opened this issue 2 years ago • 8 comments

there has unexpected 'normal' characters in the generated image

1757315673 avatar Jun 22 '22 05:06 1757315673

try 1.0.0-alpha.12 maybe useful

changjingli avatar Jun 29 '22 07:06 changjingli

getComputedStyle方法是否被改写了。通过html2cavas 获取before/after 的节点内容出错。触发了token type 为20。default写入。// safari doesn't parse string tokens correctly because of lack of quotes

bigbone avatar Jun 30 '22 03:06 bigbone

I also encountered this problem. I have try 1.4.1 and 1.3.4.

earlyup avatar Oct 21 '22 08:10 earlyup

see it https://github.com/niklasvh/html2canvas/pull/2913

bigbone avatar Nov 10 '22 09:11 bigbone

getComputedStyle方法是否被改写了。通过html2cavas 获取before/after 的节点内容出错。触发了token type 为20。default写入。// safari doesn't parse string tokens correctly because of lack of quotes

很奇怪, 确实是因为大量节点的 getComputedStyle.content 为 normal,但是不清楚为什么会这样。请问您有结论吗

oo10 avatar Aug 31 '23 03:08 oo10

getComputedStyle方法是否被改写了。通过html2cavas 获取before/after 的节点内容出错。触发了token type 为20。default写入。// safari doesn't parse string tokens correctly because of lack of quotes

很奇怪, 确实是因为大量节点的 getComputedStyle.content 为 normal,但是不清楚为什么会这样。请问您有结论吗

没有结论,调试时候发现有normal。将解析的content的值判断下normal问题就没了。。 chatgpt的答复:在使用 getComputedStyle 方法获取元素的样式属性时,content 属性的值为 "normal" 的情况包括:

对于非伪元素(non-pseudo-element):当没有应用伪元素的 content 属性或 ::before 或 ::after 伪元素选择器时,getComputedStyle 获取的 content 属性值将为 "normal"。这表示元素没有设置自定义的内容。

对于伪元素(pseudo-element):如果伪元素的 content 属性设置为 "normal",那么 getComputedStyle 获取到的伪元素的 content 属性值也将为 "normal"。这意味着伪元素将显示默认的内容,通常为空。

需要注意的是,getComputedStyle 返回的是计算后的样式值,而不是源代码中的初始值。因此,content 属性的值为 "normal" 并不意味着在 CSS 文件中没有设置该属性,而是表示没有自定义内容或使用默认内容。具体的样式规则和上下文将决定 content 属性的最终值。

bigbone avatar Sep 20 '23 06:09 bigbone

获取元素的样式属性时,content 属性的值为 "normal"

请问在源码的哪里判断content的值为normal呢?也被这个问题困扰了

bbzz7 avatar Nov 29 '23 04:11 bbzz7

获取元素的样式属性时,content 属性的值为 "normal"

请问在源码的哪里判断content的值为normal呢?也被这个问题困扰了

https://github.com/niklasvh/html2canvas/pull/2913

bigbone avatar Dec 15 '23 03:12 bigbone