Skip to content

Commit

Permalink
Merge pull request madrobby#166 from deepsweet/upstream
Browse files Browse the repository at this point in the history
$(document.createDocumentFragment()) fix.
  • Loading branch information
madrobby committed Jul 1, 2011
2 parents 3572c6f + cf0cc6a commit c4cd3c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/zepto.js
Expand Up @@ -5,6 +5,7 @@ var Zepto = (function() {
elementDisplay = {}, classCache = {},
getComputedStyle = document.defaultView.getComputedStyle,
fragmentRE = /^\s*<[^>]+>/,
nodeTypeRE = /^1|9|11$/,
container = document.createElement('div');

function isF(value) { return ({}).toString.call(value) == "[object Function]" }
Expand Down Expand Up @@ -54,7 +55,7 @@ var Zepto = (function() {
else {
var dom;
if (isA(selector)) dom = compact(selector);
else if (selector instanceof Element || selector === window || selector === document)
else if ((selector.nodeType && nodeTypeRE.test(selector.nodeType)) || selector === window)
dom = [selector], selector = null;
else if (fragmentRE.test(selector))
dom = fragment(selector), selector = null;
Expand Down
6 changes: 6 additions & 0 deletions test/zepto.html
Expand Up @@ -320,6 +320,12 @@ <h1>Zepto DOM unit tests</h1>
t.assertEqual('', z.selector);
},

testDollarWithDocumentFragment: function(t){
var documentFragment = $(document.createDocumentFragment());
t.assertLength(1, documentFragment);
t.assertEqual(Node.DOCUMENT_FRAGMENT_NODE, documentFragment.get(0).nodeType);
},

testDollarWithFragment: function(t){
var fragment = $("<div>");
t.assertLength(1, fragment);
Expand Down

0 comments on commit c4cd3c0

Please sign in to comment.