mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 07:13:08 -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 ];
|
||||
}
|
||||
function getNodeCategory ( node ) {
|
||||
if ( canWeakMap && nodeCategoryCache.has( node ) ) {
|
||||
return nodeCategoryCache.get( node );
|
||||
switch ( node.nodeType ) {
|
||||
case TEXT_NODE:
|
||||
return INLINE;
|
||||
case ELEMENT_NODE:
|
||||
case DOCUMENT_FRAGMENT_NODE:
|
||||
if ( canWeakMap && nodeCategoryCache.has( node ) ) {
|
||||
return nodeCategoryCache.get( node );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return UNKNOWN;
|
||||
}
|
||||
var type = node.nodeType;
|
||||
|
||||
var nodeCategory;
|
||||
if ( type === TEXT_NODE ) {
|
||||
nodeCategory = INLINE;
|
||||
} else if ( type !== ELEMENT_NODE && type !== DOCUMENT_FRAGMENT_NODE ) {
|
||||
nodeCategory = UNKNOWN;
|
||||
} else if ( !every( node.childNodes, isInline ) ) {
|
||||
if ( !every( node.childNodes, isInline ) ) {
|
||||
// Malformed HTML can have block tags inside inline tags. Need to treat
|
||||
// these as containers rather than inline. See #239.
|
||||
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 ];
|
||||
}
|
||||
function getNodeCategory ( node ) {
|
||||
if ( canWeakMap && nodeCategoryCache.has( node ) ) {
|
||||
return nodeCategoryCache.get( node );
|
||||
switch ( node.nodeType ) {
|
||||
case TEXT_NODE:
|
||||
return INLINE;
|
||||
case ELEMENT_NODE:
|
||||
case DOCUMENT_FRAGMENT_NODE:
|
||||
if ( canWeakMap && nodeCategoryCache.has( node ) ) {
|
||||
return nodeCategoryCache.get( node );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return UNKNOWN;
|
||||
}
|
||||
var type = node.nodeType;
|
||||
|
||||
var nodeCategory;
|
||||
if ( type === TEXT_NODE ) {
|
||||
nodeCategory = INLINE;
|
||||
} else if ( type !== ELEMENT_NODE && type !== DOCUMENT_FRAGMENT_NODE ) {
|
||||
nodeCategory = UNKNOWN;
|
||||
} else if ( !every( node.childNodes, isInline ) ) {
|
||||
if ( !every( node.childNodes, isInline ) ) {
|
||||
// Malformed HTML can have block tags inside inline tags. Need to treat
|
||||
// these as containers rather than inline. See #239.
|
||||
nodeCategory = CONTAINER;
|
||||
|
|
Loading…
Reference in a new issue