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

Is there any reason why the constructor function doesn't normalize its inputs? #102

Open
aawwawa opened this issue Nov 27, 2012 · 6 comments

Comments

@aawwawa
Copy link
Contributor

aawwawa commented Nov 27, 2012

If it did, it would save a hell of a lot of bonzo.create()s.

Anyway, it came up in IRC, and I was wondering if anyone else might be able to provide insight. If there's no good reason not to, then I'd like to propose that normalization get added...

Cheers!

@ded
Copy link
Owner

ded commented Nov 27, 2012

can you give an example? there's probably a very good reason — if not simply for the sake of speed, and that doing this via Ender would do it anyway.

@rvagg
Copy link
Collaborator

rvagg commented Nov 27, 2012

@ded I was discussing this with @adlwalrus and I couldn't come with a good reason that bonzo() isn't more clever and wondered if there was something I was overlooking.

bonzo(bonzo.create('<p>')).appendTo('#something') // unnecessarily awkward

The manip methods are clever enough to normalize() & query(), the constructor should probably be too, for Bonzo stand-alone. There's already a typeof elements == 'string' check in there but it doesn't do anything sensible.

That, and the fact that bonzo.create() doesn't return a Bonzo collection.

@ded
Copy link
Owner

ded commented Nov 27, 2012

hmmm.... i suppose so... we'd have to bump up the package a minor version tho

@ded
Copy link
Owner

ded commented Nov 27, 2012

and update a few tests...

@aawwawa
Copy link
Contributor Author

aawwawa commented Nov 28, 2012

Anyone wanna do it? If not, then anyone wanna coach me through doing it?

@aawwawa
Copy link
Contributor Author

aawwawa commented Nov 28, 2012

Well that was silly... how does this look? #103

(I had a look over the tests to see if there were any I could clearly identify as needing to be updated, but it appears not.)

(Also, I'm still not sure what @rvagg was talking about with query() after poking around in the sources. I assume it has to do with being able to pass a selector into the constructor, but I'm not sure.)

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

3 participants