Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toRGBString 在特殊情况下会抛出异常 #115

Closed
nekocode opened this issue Jul 30, 2024 · 0 comments · Fixed by #116
Closed

toRGBString 在特殊情况下会抛出异常 #115

nekocode opened this issue Jul 30, 2024 · 0 comments · Fixed by #116

Comments

@nekocode
Copy link
Contributor

util/src/color/torgb.ts

Lines 10 to 16 in c499a30

function createTmp(): HTMLElement {
const i = document.createElement('i');
i.title = 'Web Colour Picker';
i.style.display = 'none';
document.body.appendChild(i);
return i;
}

在 tmp element 被第三方卸载之后(例如在 next.js 下,如果路由变化会触发 body 元素刷新的话,原有 body 里的所有手动添加的 dom 元素都会丢失掉),继续调用 toRGBString 会抛出异常:

image

感觉这里应该从 dom 树里,而不是全局变量里拿元素

nekocode added a commit to nekocode/antvis-util that referenced this issue Jul 30, 2024
nekocode added a commit to nekocode/antvis-util that referenced this issue Aug 1, 2024
hustcc pushed a commit that referenced this issue Aug 6, 2024
* fix: fix the way to get the tmp element (#115)

* test: fix ci issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant