element.innerHTML = element.innerHTML 更改 Firefox 4 中的布局
我在浏览较旧的 Ext 文档时发现了一个奇怪的问题, http://extjs.cachefly.net/ext-3.2.1/docs/?class=Ext.grid.PropertyGrid
继承框(右上角)的布局有些破碎。
布局损坏 http://img339.imageshack.us/img339/374/bildschirmfoto20110427u.png< /a>
但执行后
var resblock = document.getElementById('docs-Ext.grid.PropertyGrid').getElementsByClassName('res-block-inner')[0];
resblock.innerHTML = resblock.innerHTML; // should be a no-op(?)
一切正常。
好的布局 http://img204.imageshack.us/img204/374/bildschirmfoto20110427u.png< /a>
怎么可能? Firefox 4 中的一个错误?
编辑 一个最小的测试用例: http://jsfiddle.net/uZ3eC/
I found a strange issue when browsing the older Ext documentation, http://extjs.cachefly.net/ext-3.2.1/docs/?class=Ext.grid.PropertyGrid
The layout of the inheritance box (top right) is somewhat shattered.
broken layout http://img339.imageshack.us/img339/374/bildschirmfoto20110427u.png
But after executing
var resblock = document.getElementById('docs-Ext.grid.PropertyGrid').getElementsByClassName('res-block-inner')[0];
resblock.innerHTML = resblock.innerHTML; // should be a no-op(?)
everything is okay.
okay layout http://img204.imageshack.us/img204/374/bildschirmfoto20110427u.png
How can that be? A bug in Firefox 4?
Edit
A minimal testcase: http://jsfiddle.net/uZ3eC/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,它看起来像是 Firefox 4
在处理处理行结尾时的一个错误。resblock 元素是一个包含多个文本节点的
但是,运行
resblock.innerHTML = resblock.innerHTML;
后,它们现在包含换行符 (U+000A),后跟不间断空格。Firefox 4 似乎只是将换行符视为换行符,并将类层次结构的部分呈现在新行上。
编辑:鲍里斯说的话。
HTML5 草案规范部分 8.2.2.3 预处理输入流< /a> 说:
Yes, it looks like
a bug inthe way Firefox 4, over the handling ofhandles line endings.The resblock element is a
<pre>
element containing a number of text nodes, which deal with new lines and indentations. When they are constructed through the scripts, they contain a CARRIAGE RETURN (U+000D) followed by a sequence of non-breaking spaces.However, after running
resblock.innerHTML = resblock.innerHTML;
they now contain a LINE FEED (U+000A) followed by the non-breaking spaces.It seems that Firefox 4 is only treating the line feed character as a line break, and rendering the parts of the class hierarchy on new lines.
Edit: What Boris said.
The HTML5 draft spec Section 8.2.2.3 Preprocessing the input stream says: