Self-closing html tags act as open tags #487

Closed
wants to merge 1 commit into
from
View
1 Gemfile
@@ -1,3 +1,4 @@
source :rubygems
gem 'rake'
+gem 'uglifier'
View
7 Gemfile.lock
@@ -1,10 +1,17 @@
GEM
remote: http://rubygems.org/
specs:
+ execjs (1.3.0)
+ multi_json (~> 1.0)
+ multi_json (1.3.2)
rake (0.9.2.2)
+ uglifier (1.2.4)
+ execjs (>= 0.3.0)
+ multi_json (>= 1.0.2)
PLATFORMS
ruby
DEPENDENCIES
rake
+ uglifier
View
6 src/zepto.js
@@ -101,6 +101,12 @@ var Zepto = (function() {
if (name === undefined) name = fragmentRE.test(html) && RegExp.$1
if (!(name in containers)) name = '*'
var container = containers[name]
+
+ if(html.replace) {
+ var tagExpander = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig
+ html = html.replace(tagExpander, "<$1></$2>")
+ }
+
container.innerHTML = '' + html
return $.each(slice.call(container.childNodes), function(){
container.removeChild(this)
View
3 test/zepto.html
@@ -525,6 +525,9 @@
t.assertEqual("<span>world</span>", outerHTML(fragment.get(2)))
t.assertEqual('', fragment.selector)
+ fragment = $("<div /><div />")
+ t.assertLength(2, fragment)
+
fragment = $("<div>hello</div> ")
t.assertLength(1, fragment)
},