-
Notifications
You must be signed in to change notification settings - Fork 26
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
Can this mod be made into a sugar? #14
Comments
Interesting. Might add next / previous to core. As a chainable ex: |
EDIT: refactor for clarity. That unfortunately looks like it's going to grab the parent element then next/prev sibling which would dodge grabbing a void element. What about having me() check if there is a previousElementSibling first if that doesn't exist then use the parent instead? me(selector=null, start=document, warning=true) {
if (!selector) return $.sugar(start.currentScript.previousElementSibling || start.currentScript.parentElement) // Just local me() in <script>
...
},
any(selector, start=document, warning=true) {
if (!selector) return $.sugar([start.currentScript.previousElementSibling || start.currentScript.parentElement]) // Just local me() in <script>
...
}, That will allow for the capture void elements like input below. <div class="flex">
<input type="search" placeholder="Search">
<script>me().on('input', e=>{search_table(me('#tmarkdown'), me(e))})</script>
...
</div> me() would retrieve input instead of the current behavior of retrieving the div. Moving script directly below |
I was experimenting with some tree traversal over here. #6 With that system your case would be something like |
@gazpachoking That looks interesting and is beyond what I'm looking for. My objective is to be as lazy as possible and retrieve previous adjacent element or the parent. Advanced traversal is beyond me other than using CSS selectors. I refactored my previous comment for clarity. |
Closing this in favor of PR #17 |
This adds in a small modifier to pick up elementSiblings.
It's been great for picking up single tags at the same level like
<input>
and<img>
. Putting some of the scripting outside of a tag like<td>
is nice for for searching a table without creating a text node.Is it possible to use the sugar system for this?
The text was updated successfully, but these errors were encountered: