0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-22 15:23:29 -05:00

Treat inline tags as containers in malformed HTML

Fixes #239.
This commit is contained in:
Neil Jenkins 2016-09-26 11:37:38 +01:00
parent d8239d2570
commit 4f83b0a8bc
3 changed files with 10 additions and 4 deletions

View file

@ -206,7 +206,10 @@ function isLeaf ( node ) {
!!leafNodeNames[ node.nodeName ]; !!leafNodeNames[ node.nodeName ];
} }
function isInline ( node ) { function isInline ( node ) {
return inlineNodeNames.test( node.nodeName ); return inlineNodeNames.test( node.nodeName ) &&
// Malformed HTML can have block tags inside inline tags. Need to treat
// these as containers rather than inline. See #239.
( node.nodeType === TEXT_NODE || every( node.childNodes, isInline ) );
} }
function isBlock ( node ) { function isBlock ( node ) {
var type = node.nodeType; var type = node.nodeType;

File diff suppressed because one or more lines are too long

View file

@ -27,7 +27,10 @@ function isLeaf ( node ) {
!!leafNodeNames[ node.nodeName ]; !!leafNodeNames[ node.nodeName ];
} }
function isInline ( node ) { function isInline ( node ) {
return inlineNodeNames.test( node.nodeName ); return inlineNodeNames.test( node.nodeName ) &&
// Malformed HTML can have block tags inside inline tags. Need to treat
// these as containers rather than inline. See #239.
( node.nodeType === TEXT_NODE || every( node.childNodes, isInline ) );
} }
function isBlock ( node ) { function isBlock ( node ) {
var type = node.nodeType; var type = node.nodeType;