Fixed err when .html and append use with null as input #670

Closed
wants to merge 2 commits into
from

Projects

None yet

2 participants

@AliMD
AliMD commented Dec 29, 2012

Fixed err when .html and append use with null as input

  $('h1').append( $('.notfound').html() );
AliMD added some commits Dec 29, 2012
@mislav mislav added a commit that closed this pull request Jan 2, 2013
@mislav mislav fix DOM insertion operators for null values
Closes #670
7b2685d
@mislav mislav closed this in 7b2685d Jan 2, 2013
@mislav
Collaborator
mislav commented Jan 2, 2013

Thanks for the report!

Fixed in a slightly different way.

@AliMD
AliMD commented Jan 2, 2013

Thank you
can you more describe about your way.

@AliMD AliMD commented on the diff Jan 2, 2013
src/zepto.js
if (html.replace) html = html.replace(tagExpanderRE, "<$1></$2>")
if (name === undefined) name = fragmentRE.test(html) && RegExp.$1
if (!(name in containers)) name = '*'
var nodes, dom, container = containers[name]
- container.innerHTML = '' + html
+ container.innerHTML = html
@AliMD
AliMD Jan 2, 2013

and more describe about this line !

@mislav
Collaborator
mislav commented Jan 2, 2013

The error that you were getting is because a null argument went into append method:

el.append(null)

This was passed to fragment function, which can only deal with string values.

Instead of changing the fragment function, I've opted to fix append (and similar methods) to simply ignore null or undefined arguments, resulting in no operation being performed.

@AliMD
AliMD commented Jan 5, 2013

and plz describe about that line

@lopper lopper added a commit to buddydvd/zepto that referenced this pull request Apr 24, 2013
@mislav mislav fix DOM insertion operators for null values
Closes #670
c3a3aa9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment