mirror of
https://github.com/fastmail/Squire.git
synced 2025-01-03 05:00:13 -05:00
Don't bother caching text node category
This commit is contained in:
parent
f46dee1255
commit
0b72f29ce5
3 changed files with 27 additions and 17 deletions
|
@ -213,16 +213,21 @@ function isLeaf ( node ) {
|
||||||
return node.nodeType === ELEMENT_NODE && !!leafNodeNames[ node.nodeName ];
|
return node.nodeType === ELEMENT_NODE && !!leafNodeNames[ node.nodeName ];
|
||||||
}
|
}
|
||||||
function getNodeCategory ( node ) {
|
function getNodeCategory ( node ) {
|
||||||
|
switch ( node.nodeType ) {
|
||||||
|
case TEXT_NODE:
|
||||||
|
return INLINE;
|
||||||
|
case ELEMENT_NODE:
|
||||||
|
case DOCUMENT_FRAGMENT_NODE:
|
||||||
if ( canWeakMap && nodeCategoryCache.has( node ) ) {
|
if ( canWeakMap && nodeCategoryCache.has( node ) ) {
|
||||||
return nodeCategoryCache.get( node );
|
return nodeCategoryCache.get( node );
|
||||||
}
|
}
|
||||||
var type = node.nodeType;
|
break;
|
||||||
|
default:
|
||||||
|
return UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
var nodeCategory;
|
var nodeCategory;
|
||||||
if ( type === TEXT_NODE ) {
|
if ( !every( node.childNodes, isInline ) ) {
|
||||||
nodeCategory = INLINE;
|
|
||||||
} else if ( type !== ELEMENT_NODE && type !== DOCUMENT_FRAGMENT_NODE ) {
|
|
||||||
nodeCategory = UNKNOWN;
|
|
||||||
} else if ( !every( node.childNodes, isInline ) ) {
|
|
||||||
// Malformed HTML can have block tags inside inline tags. Need to treat
|
// Malformed HTML can have block tags inside inline tags. Need to treat
|
||||||
// these as containers rather than inline. See #239.
|
// these as containers rather than inline. See #239.
|
||||||
nodeCategory = CONTAINER;
|
nodeCategory = CONTAINER;
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -33,16 +33,21 @@ function isLeaf ( node ) {
|
||||||
return node.nodeType === ELEMENT_NODE && !!leafNodeNames[ node.nodeName ];
|
return node.nodeType === ELEMENT_NODE && !!leafNodeNames[ node.nodeName ];
|
||||||
}
|
}
|
||||||
function getNodeCategory ( node ) {
|
function getNodeCategory ( node ) {
|
||||||
|
switch ( node.nodeType ) {
|
||||||
|
case TEXT_NODE:
|
||||||
|
return INLINE;
|
||||||
|
case ELEMENT_NODE:
|
||||||
|
case DOCUMENT_FRAGMENT_NODE:
|
||||||
if ( canWeakMap && nodeCategoryCache.has( node ) ) {
|
if ( canWeakMap && nodeCategoryCache.has( node ) ) {
|
||||||
return nodeCategoryCache.get( node );
|
return nodeCategoryCache.get( node );
|
||||||
}
|
}
|
||||||
var type = node.nodeType;
|
break;
|
||||||
|
default:
|
||||||
|
return UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
var nodeCategory;
|
var nodeCategory;
|
||||||
if ( type === TEXT_NODE ) {
|
if ( !every( node.childNodes, isInline ) ) {
|
||||||
nodeCategory = INLINE;
|
|
||||||
} else if ( type !== ELEMENT_NODE && type !== DOCUMENT_FRAGMENT_NODE ) {
|
|
||||||
nodeCategory = UNKNOWN;
|
|
||||||
} else if ( !every( node.childNodes, isInline ) ) {
|
|
||||||
// Malformed HTML can have block tags inside inline tags. Need to treat
|
// Malformed HTML can have block tags inside inline tags. Need to treat
|
||||||
// these as containers rather than inline. See #239.
|
// these as containers rather than inline. See #239.
|
||||||
nodeCategory = CONTAINER;
|
nodeCategory = CONTAINER;
|
||||||
|
|
Loading…
Reference in a new issue