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
Sixth composite pull request #84
Conversation
This commit adds a few options to $document.create_element, so that it can add classes, id and attributes before dispatching. This commit introduces a subclass selection by a selector. This allows users to create their own subclasses based on any CSS selector. This commit enhances Element.create. Subclasses can now be instantiated with just a syntax like: DOM::Element::Textarea.create. While not adding support for custom elements, it lays groundwork for supporting those (ref. opal#82).
This commit introduces a slight incompatibility, but hopefully it's a worthy one. The rationale is that I often tend to write code like: `DOM { div }.append_to(other_node)` to construct a DOM tree and append it in one go. When I try to capture the tree, I can't - I think it makes no sense to return a parent. Regarding other cases where this is done this way, I would note jQuery even if some people may say it's an unpopular comparison, but I want this library to give jQuery users a familiar interface. Nokogiri has no say about this - it doesn't have {pre,ap}pend_to. Do note, that it makes no change to << and >> which should return a parent node.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work!
There's a nit about the EOF newline, but I'll merge anyway, it can be fixed afterwards 👍
|
||
})(); | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: It's better to always have a EOF newline if possible to keep git diffs neat, usually it can be configured in the editor 🤓
After some break I'm back with new features / bugfixes / modifications to opal-browser.
I think the most important part is a rework of DOM::Element subclassing, allowing for some component-like user code and laying some groundwork for future support of custom elements / web components (#82)