Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
wants to merge 2 commits into from

2 participants

@AliMD

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

  $('h1').append( $('.notfound').html() );
@mislav mislav closed this in 7b2685d
@mislav
Collaborator

Thanks for the report!

Fixed in a slightly different way.

@AliMD

Thank you
can you more describe about your way.

@AliMD AliMD commented on the diff
src/zepto.js
((5 lines not shown))
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 added a note

and more describe about this line !

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

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

and plz describe about that line

@xiaody xiaody referenced this pull request from a commit in xiaody/zepto
@mislav mislav fix DOM insertion operators for null values
Closes #670

Conflicts:
	src/zepto.js
65a3f62
@lopper lopper referenced this pull request from a commit in buddydvd/zepto
@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
Commits on Dec 29, 2012
  1. @AliMD

    Merge pull request #3 from madrobby/master

    AliMD authored
    Update 1rc to last
  2. @AliMD

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

    AliMD authored
    $('h1').append( $('.notfound').html() );
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 1 deletion.
  1. +2 −1  src/zepto.js
View
3  src/zepto.js
@@ -108,12 +108,13 @@ var Zepto = (function() {
// This function can be overriden in plugins for example to make
// it compatible with browsers that don't support the DOM fully.
zepto.fragment = function(html, name, properties) {
+ html+=''
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 added a note

and more describe about this line !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
dom = $.each(slice.call(container.childNodes), function(){
container.removeChild(this)
})
Something went wrong with that request. Please try again.