5 ms·
Seems like they shouldn’t have implemented this without a full API. Instead the 5 or so commands, it looks like it’s possible to implement ALL JavaScript functi
by vFunct 2y ago
Seems like they shouldn’t have implemented this without a full API. Instead the 5 or so commands, it looks like it’s possible to implement ALL JavaScript functionality through HTML, including high level APIs. That could be thousands of commands..
- ericyd 2y agoThis is my thought too, I'm having trouble envisioning a case where a reasonably complex UI wouldn't still need JS. I guess it provides a roadmap to incremental adoption.
- Someone1234 2y agoThe real power is custom commands and a standard way to implement them. The built-in commands will always be just conveniences that many convert to a custom version as complexity increases. Even something like close will wind up being --my-close, and several additional checks will be run before dialogEl.close() is called.
- PokestarFan 2y agoI don't see how it should be too hard to implement, you could abstractly have a system where the command string is translated as such: 1. Split the string by dashes into an array 2. Make the first character of the first array item lowercase, make the first character of the rest uppercase 3. Concatenate the pieces together 4. Do `document.getElementById(element.commandfor)[concatenated]()` Obviously this doesn't have the myriad number of checks to make sure that the element exists, the method exists, the method takes no parameters, etc. This would also allow custom commands easily, since you could do `document.getElementById(element.commandfor).myCustomMethod = function() { /* ... */ }`
- rafram 2y agoGiven that this is meant to be a safe alternative to inline JS, executing arbitrary JS would be counterproductive.