Opened 7 years ago

Last modified 7 years ago

#9520 confirmed Bug

Shorter way for node's type check

Reported by: Piotrek Koszuliński Owned by:
Priority: Normal Milestone:
Component: Performance Version: 3.0
Keywords: Cc:

Description (last modified by Piotrek Koszuliński)

The current way is long and isn't minifiable at all:

node.type == CKEDITOR.NODE_TEXT || node.type == CKEDITOR.NODE_ELEMENT

We may introduce shorter version. E.g. method 'is' may be added to node:

node.is( '#doc' );
// or
node.is( [ '#text', '#element' ] );

Tokens have to be prepended with hash, because we already have is method to check element name. Also, it was used to duck typing, what would has to be fixed.

This solution's flaw is that additional check has to be done when method is called on element. Thus, we may think of other method's name specialized in type checking. E.g. node#node ( node.node( 'text' ) ).

Change History (3)

comment:1 Changed 7 years ago by Piotrek Koszuliński

Description: modified (diff)

comment:2 Changed 7 years ago by Garry Yao

Milestone: CKEditor 4.0.1CKEditor 4.1
Status: newconfirmed

API changes moved to 4.1.

comment:3 Changed 7 years ago by Frederico Caldeira Knabben

Milestone: CKEditor 4.1
Note: See TracTickets for help on using tickets.
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy