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

proxy dot-traversal into first element #13

Open
CooHunter opened this issue Apr 15, 2014 · 3 comments
Open

proxy dot-traversal into first element #13

CooHunter opened this issue Apr 15, 2014 · 3 comments

Comments

@CooHunter
Copy link

Im learning DOM from the code, I dont understand why you offer the first element instead of traverse it.
eg: I have two ul elements.

<ul><li>1</li><li>2</li></ul>
<ul><li>3</li><li>4</li></ul>

now HTML.body.ul.li only get the first ul's li, its very odd. and the second ul dont inherit any methods, i must use HTML.ify to initial it by manully.

How about write like this:

if (force || !list.each) {
     if (!list.slice){ list = _.slice.call(list); }
        _.methods(list);
        for (var i = 0, len = list.length; i < len; i++) {
            _.node(list[i], force);
       }
}
@nbubna
Copy link
Owner

nbubna commented Apr 15, 2014

Yeah, i figured someone would complain about this someday. The trouble is with non-uniform structures in the same list. Your list has all ul that contain lis in it, so HTML.body.ul.li makes all the sense in the world. But what about HTML.query('.foo') where there are multiple .foo elements that all are different tags and have different child tags? It gets messy, and could even become a performance drag for large lists with many/diverse child elements.

Basically, i tried to keep it simple here. I knew that cases like HTML.body.ul.li could always be worked around: HTML.body.ul.query('li'), but that if i proxied all child elements from all list members that people working with large/diverse lists could get confusing/slow proxied getters even if they were not using them.

I could probably be swayed on this, but for now, i thinking avoiding a potential problem that couldn't be worked around easily is better than creating a surprising behavior that can be worked around easily.

@nbubna
Copy link
Owner

nbubna commented Apr 15, 2014

Oh, and let's leave this open for others to comment. I'm very interested in hearing from the community on this one.

@CooHunter
Copy link
Author

Thanks for explain.

@nbubna nbubna reopened this Apr 15, 2014
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

No branches or pull requests

2 participants