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

[g-plugin-html-renderer] HTML 应该允许相同 id 正常渲染 #1475

Closed
xiaoiver opened this issue Aug 11, 2023 · 1 comment
Closed

[g-plugin-html-renderer] HTML 应该允许相同 id 正常渲染 #1475

xiaoiver opened this issue Aug 11, 2023 · 1 comment
Assignees
Labels

Comments

@xiaoiver
Copy link
Contributor

xiaoiver commented Aug 11, 2023

在下面的示例中,p1 & p2 id 相同,p1 展示不出来了:

截屏2023-08-11 下午5 13 28

原因是 g-plugin-html-renderer 内部会使用 DOM API getElementById 查询已创建的元素,id 相同总会返回第一个。

antvis/G2#5390

解决方案是在生成的 DOM 结构上增加 data-id 保存唯一生成的 ID,格式为:g-html-${entity},内部使用 [data-id=] 属性选择器查询:

截屏2023-08-11 下午5 39 35

可能会影响目前 G2 的集成测试中 tooltip 的部分。

@xiaoiver xiaoiver self-assigned this Aug 11, 2023
@xiaoiver xiaoiver added the bug label Aug 11, 2023
xiaoiver added a commit that referenced this issue Aug 11, 2023
* fix: should allow different HTMLs sharing the same Id #1475

* chore: commmit changeset
xiaoiver added a commit that referenced this issue Aug 11, 2023
* fix: should allow different HTMLs sharing the same Id #1475 (#1476)

* fix: should allow different HTMLs sharing the same Id #1475

* chore: commmit changeset

* chore(release): bump version (#1477)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@xiaoiver
Copy link
Contributor Author

仔细思考了一下没必要增加多余的 data-id 属性,内部维护一个 WeakMap 就行了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant