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

FIX: textNode with whitespace would generate useless <p> tag #495

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

loo2k
Copy link

@loo2k loo2k commented Nov 30, 2016

问题

如果 textarea 内不同的标签有空格节点,Simditor 会把空格节点当成一个文本并创建一个没用的 <p> 标签。

<textarea>
    <h1>This is a header</h1>
    <p>Lorem ipsum dolor sit amet...</p>
</textarea>

以上内容经 simditor 格式化后会生成以下下代码

<h1>This is a header</h1>
<p>    </p>
<p>Lorem ipsum dolor sit amet...</p>

解决方案

cleanNode 方法中对 textNode 执行 trim() 方法,判断内容是否为空,如果为空则删除该节点。

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 this pull request may close these issues.

1 participant