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

当把一个组件放在最 template 最顶层的时候,会覆盖接下来所有的元素 #123

Closed
tonyke-bot opened this issue May 4, 2017 · 4 comments

Comments

@tonyke-bot
Copy link

具体表现:
【正常情况】
snipaste_20170504_120714

【覆盖:第一个Panel能正常编译出来,第二个Panel直接消失】
snipaste_20170504_120752

我尝试着修复这个 bug,定位到了 wepy-cli\src\compile-template.js@465 这里,猜测是因为这个判断导致了这样子的bug,但是不清楚为何这里要做一个顶层元素的判断,还请 repo 主解答一下
snipaste_20170504_120511

@Gcaufy
Copy link
Collaborator

Gcaufy commented May 4, 2017

因为在顶层就是components的情况下,编译会直接报错,最后为了fix这个问题加了这个判断。
如果顶层放两个components,那么node.documentElement === com还成立么?

@tonyke-bot
Copy link
Author

成立的。

<Panel/>
<Panel2/>

这样子的 source 传给 domParser 的时候,由于没有一个唯一的顶层元素,所以 parser 把 Panel 当成了顶层元素。

所以我想是不是可以在编译的时候,给 template 加一个顶层元素

<xml>
    <Panel/>
    <Panel2/>
</xml>

让其正常编译,在写入到 wxml 的时候再去掉这个顶层元素?

@Gcaufy
Copy link
Collaborator

Gcaufy commented May 4, 2017

xmldom在处理删除节点的时候比较麻烦,我暂时还没想到好的办法。这个问题后面我再调试一下看看。
你这边先暂且手动个个节点吧。

Gcaufy added a commit that referenced this issue May 4, 2017
@Gcaufy
Copy link
Collaborator

Gcaufy commented May 5, 2017

发布的1.5.3 版本已修复这个问题

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

No branches or pull requests

2 participants