-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce Node/DF#is method #3979
Comments
Example how code would be simplified: https://github.com/ckeditor/ckeditor5-image/pull/48/files#r100029767 |
Either you implement The idea is neat and might clean code, but I am afraid it will require some dirty ducktyping or properties like |
Good point.
Yep, exactly! I've been proposing this property long time ago anyway :) Checking the types by the property and not instance of will also prevent some nasty issues cause by duplicated engine modules (may happen in some broken cases). |
I mean.. Okay, I can live with this. This is language fault, not our fault, that importing is difficult and to check types we have to do such silly things. Still, I'd be more happy if |
Or the |
This is actually good idea. |
BTW: it reminds me that we have a |
But to be honest I have mixed feelings about the |
I'll implement this feature using @pjasiun idea. Of course (?) |
Do we bring those for view too? |
I guess we'd like to keep this consistent.
I'm not sure about that. This doesn't seem to be necessary. If there's |
You are right about |
Feature: Introduced `is()` method in model and view tree nodes and document fragments. Closes #809.
We had such method in CKE4, but it was only available for elements:
el.is( 'p' )
. It's just a bit nicer thanel.name == 'p'
, but a lot nicer thanel.name == 'p' || el.name == 'div'
.What I've been thinking of is to make this method even more useful, by allowing checking whether the node is a text node or document fragment or whatever else.
There are many algorithms which need to verify what kind of node they are dealing with. We've seen e.g. the whole discussion around https://github.com/ckeditor/ckeditor5-engine/issues/807.
If we had a nicer API to check the type of the node or DF, then we'd be more pleased to use it.
Some ideas:
Such method will have a lot of pros:
The text was updated successfully, but these errors were encountered: