Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Implement isText() helper #218

Merged
merged 3 commits into from
Feb 1, 2018
Merged

Implement isText() helper #218

merged 3 commits into from
Feb 1, 2018

Conversation

ma2ciek
Copy link
Contributor

@ma2ciek ma2ciek commented Jan 31, 2018

Suggested merge commit message (convention)

Other: Introduced isText() helper. Closes ckeditor/ckeditor5#4989.


Additional information

PRs in other packages:

@ma2ciek ma2ciek requested a review from oleq January 31, 2018 11:09
* @returns {Boolean}
*/
export default function isText( obj ) {
return Object.prototype.toString.call( obj ) == '[object Text]';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's better checking nodeType or calling toString(). IMO both options should be good here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking nodeType seems to be a too naive duck typing. Calling toString() is slightly safer. Eventually, we could switch to instanceof but starting with toString() seems to be simpler.

Copy link
Contributor Author

@ma2ciek ma2ciek Jan 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple instanceof check easily breaks in iframes, so it would be a little more complicated to implement it correctly.

Copy link
Member

@Reinmar Reinmar Jan 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I know. I meant instanceof check that we used in isDomNode().

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW: I wonder why isDomNode instead of isNode? It's under src/dom/. If we go with isText we should go with isNode too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to comment on this – yep, isNode() would be better. @ma2ciek could you report a separate ticket for it and do the change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll handle it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling f25ffdf on t/214 into f316584 on master.

@Reinmar Reinmar merged commit a9a6bec into master Feb 1, 2018
@Reinmar Reinmar deleted the t/214 branch February 1, 2018 14:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement the dom/isText helper
4 participants