Extension talk:CodeMirror
Add topic
|
jQuery in frontend hooks
[edit]I know it may be too late, but couldn’t we use native DOM objects in frontend hooks instead of jQuery objects? jQuery is a quite sloppy interface: it tries to handle everything uniformly, even though it’s impossible – one naturally has to handle elements and collections of elements differently (“elements” are jQuery objects with zero or one HTML element, “collections” are jQuery objects with potentially more than one element), just like different types of elements (e.g. jQuery provides a .val()
method on all jQuery objects, even though it makes sense only on form elements). If you see that the ext.CodeMirror.initialize
gives you a jQuery object, you don’t know what you actually get. If it gives you an HTMLTextAreaElement
, you know that
- it’s one element, not zero and not more,
- and it has all the properties a text area has (value, read-only state etc.).
Given the HTMLTextAreaElement
, you can always wrap it in a jQuery object if it’s more convenient, but unwrapping is not possible in a statically-provably safe way. —Tacsipacsi (talk) 19:19, 19 November 2024 (UTC)