Fix .after() and .before() to accept sets/arrays of nodes (like other methods) #67

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
4 participants
@benvinegar
Contributor

benvinegar commented Jan 12, 2012

Enables the following:

var created = $.create('<span>some <em>shiza</em></span>')
$('.after-created-examples').after(created);

This works using a number of other Bonzo methods, so it seemed natural to extend it here. For example, one could do the following just fine:

var created = $.create('<span>some <em>shiza</em></span>')
created.appendTo('.after-created-examples');
@ded

This comment has been minimized.

Show comment Hide comment
@ded

ded Jan 12, 2012

Owner

thanks for the request. i'm confused how the example is an array of nodes. is it not just one node? <span> some <em>shiza</em></span> — tis still just one node to append (despite it having children).

i'll have a look at the tests and see what's going on.

Owner

ded commented Jan 12, 2012

thanks for the request. i'm confused how the example is an array of nodes. is it not just one node? <span> some <em>shiza</em></span> — tis still just one node to append (despite it having children).

i'll have a look at the tests and see what's going on.

@benvinegar

This comment has been minimized.

Show comment Hide comment
@benvinegar

benvinegar Jan 12, 2012

Contributor

In this case, it's just a Bonzo object. By "set", I meant Bonzo object. I should have included a test for arrays too.

Contributor

benvinegar commented Jan 12, 2012

In this case, it's just a Bonzo object. By "set", I meant Bonzo object. I should have included a test for arrays too.

@benvinegar

This comment has been minimized.

Show comment Hide comment
@benvinegar

benvinegar Jan 31, 2012

Contributor

Okay, I've seriously beefed up the test suite to test a range of inputs for each of after, before, append, prepend.

Also, I changed append and prepend to use Bonzo.create instead of normalize. This is to match jQuery's append and prepend behaviour, where if you pass append and prepend a DOM element (or jQuery) object, that object is cloned for each append target.

Contributor

benvinegar commented Jan 31, 2012

Okay, I've seriously beefed up the test suite to test a range of inputs for each of after, before, append, prepend.

Also, I changed append and prepend to use Bonzo.create instead of normalize. This is to match jQuery's append and prepend behaviour, where if you pass append and prepend a DOM element (or jQuery) object, that object is cloned for each append target.

@ded

This comment has been minimized.

Show comment Hide comment
@ded

ded Jan 31, 2012

Owner

oy. right on. will have a look

Owner

ded commented Jan 31, 2012

oy. right on. will have a look

@herbdaily

This comment has been minimized.

Show comment Hide comment
@herbdaily

herbdaily Feb 10, 2012

I also ran into a problem with after(). I replaced it in my code with parent().append() and it works fine. Maybe the after() method should be replaced with something like that?

I also ran into a problem with after(). I replaced it in my code with parent().append() and it works fine. Maybe the after() method should be replaced with something like that?

@herbdaily

This comment has been minimized.

Show comment Hide comment
@herbdaily

herbdaily Feb 10, 2012

D'oh! Nvm, only works for last element in its parent, which happens to be what I'm doing.

D'oh! Nvm, only works for last element in its parent, which happens to be what I'm doing.

@benvinegar

This comment has been minimized.

Show comment Hide comment
@benvinegar

benvinegar Jun 21, 2012

Contributor

Getting constantly burned by this diff.

Another (related) issue is that one can't do this $('#foo').html($('

one
two
'));

Contributor

benvinegar commented Jun 21, 2012

Getting constantly burned by this diff.

Another (related) issue is that one can't do this $('#foo').html($('

one
two
'));

@ded

This comment has been minimized.

Show comment Hide comment
@ded

ded Jun 23, 2012

Owner

looks like @rvagg is starting to jump on these

Owner

ded commented Jun 23, 2012

looks like @rvagg is starting to jump on these

@rvagg rvagg closed this in 10b6abe Jul 12, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment