Skip to content
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

Merged
merged 29 commits into from Oct 31, 2020
Merged

Sixth composite pull request #84

merged 29 commits into from Oct 31, 2020

Conversation

hmdne
Copy link
Member

@hmdne hmdne commented Jul 5, 2020

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)

hmdne and others added 29 commits November 18, 2019 02:25
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.
Copy link
Member

@elia elia left a 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 👍


})();

}
Copy link
Member

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 🤓

@elia elia merged commit 13f352d into opal:master Oct 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants