kindsoft / kindeditor

WYSIWYG HTML editor
http://kindeditor.net/
GNU Lesser General Public License v2.1
1.9k stars 606 forks source link

editor.html(null) 报错 Cannot call method 'replace' of null,应能处理null参数 #126

Closed mouhong closed 11 years ago

mouhong commented 11 years ago

问题描述

<textarea id="MyEditor"></textarea>

<script type="text/javascript" src="/scripts/kindeditor/kindeditor.js"></script>
<script type="text/javascript">
        $(function () {
            var editor = KindEditor.create('#MyEditor', { langType: 'en' });
            setTimeout(function () {
                editor.html(null);
            }, 3000);
        });
</script>

注意上面的setTimeout,如果没有setTimeout而立即执行html(null)的话,则一切正常,用setTimeout延迟下就出错了:Cannot call method 'replace' of null。

StackTrace:

_formatHtml (kindeditor line 713)
self.edit._edit.beforeSetHtml
_extend.html
KEditor.html

期望结果

把传入的null当作空字符串处理

测试环境

KindEditor版本:4.1.7 浏览器:Chrome (Version 27.0.1453.110 m)

luolonghao commented 11 years ago

已修复。