git.asbjorn.biz
/
jquery.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8c18dcd
)
Added an improvement to quickExpr and some more tests for jQuery('html'). Fixes ...
author
John Resig
<jeresig@gmail.com>
Mon, 27 Jul 2009 20:47:32 +0000
(20:47 +0000)
committer
John Resig
<jeresig@gmail.com>
Mon, 27 Jul 2009 20:47:32 +0000
(20:47 +0000)
src/core.js
patch
|
blob
|
history
test/unit/core.js
patch
|
blob
|
history
diff --git
a/src/core.js
b/src/core.js
index
7e7a4e2
..
5f2cf20
100644
(file)
--- a/
src/core.js
+++ b/
src/core.js
@@
-20,7
+20,7
@@
var jQuery = function( selector, context ) {
// A simple way to check for HTML strings or ID strings
// (both of which we optimize for)
// A simple way to check for HTML strings or ID strings
// (both of which we optimize for)
- quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,
+ quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,
// Is it a simple selector
isSimple = /^.[^:#\[\.,]*$/,
// Is it a simple selector
isSimple = /^.[^:#\[\.,]*$/,
@@
-70,12
+70,12
@@
jQuery.fn = jQuery.prototype = {
// HANDLE: $("#id")
} else {
// HANDLE: $("#id")
} else {
- elem = document.getElementById( match[3] );
+ elem = document.getElementById( match[2] );
if ( elem ) {
// Handle the case where IE and Opera return items
// by name instead of ID
if ( elem ) {
// Handle the case where IE and Opera return items
// by name instead of ID
- if ( elem.id !== match[3] ) return rootjQuery.find( selector );
+ if ( elem.id !== match[2] ) return rootjQuery.find( selector );
// Otherwise, we inject the element directly into the jQuery object
this.length++;
// Otherwise, we inject the element directly into the jQuery object
this.length++;
diff --git
a/test/unit/core.js
b/test/unit/core.js
index
c58f13f
..
b6dc206
100644
(file)
--- a/
test/unit/core.js
+++ b/
test/unit/core.js
@@
-303,7
+303,7
@@
test("isXMLDoc - XML", function() {
}
test("jQuery('html')", function() {
}
test("jQuery('html')", function() {
- expect(8);
+ expect(13);
reset();
jQuery.foo = false;
reset();
jQuery.foo = false;
@@
-313,6
+313,14
@@
test("jQuery('html')", function() {
jQuery("body").append("<script>jQuery.foo='test';</script>");
ok( jQuery.foo, "Executing a scripts contents in the right context" );
jQuery("body").append("<script>jQuery.foo='test';</script>");
ok( jQuery.foo, "Executing a scripts contents in the right context" );
+ // Test multi-line HTML
+ var div = jQuery("<div>\r\nsome text\n<p>some p</p>\nmore text\r\n</div>")[0];
+ equals( div.nodeName.toUpperCase(), "DIV", "Make sure we're getting a div." );
+ equals( div.firstChild.nodeType, 3, "Text node." );
+ equals( div.lastChild.nodeType, 3, "Text node." );
+ equals( div.childNodes[1].nodeType, 1, "Paragraph." );
+ equals( div.childNodes[1].firstChild.nodeType, 3, "Paragraph text." );
+
reset();
ok( jQuery("<link rel='stylesheet'/>")[0], "Creating a link" );
reset();
ok( jQuery("<link rel='stylesheet'/>")[0], "Creating a link" );