aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2013-05-08 21:07:41 -0400
committerDave Methvin <dave.methvin@gmail.com>2013-05-09 14:07:19 -0400
commit00eafdf028f7730665ce1c05ab44e3f0bc80fbc2 (patch)
treebc646dfe9e2805e2bc5b602978ed276f9becab4c
parent0135a223f4970134190f6ff9af3f53a8efd4966d (diff)
downloadjquery-00eafdf028f7730665ce1c05ab44e3f0bc80fbc2.tar.gz
jquery-00eafdf028f7730665ce1c05ab44e3f0bc80fbc2.zip
Fix #13223. Re-allow leading space in HTML. Close gh-1264.
-rw-r--r--src/core.js2
-rw-r--r--test/unit/core.js8
-rw-r--r--test/unit/selector.js12
3 files changed, 8 insertions, 14 deletions
diff --git a/src/core.js b/src/core.js
index 44e622717..e957e4ee1 100644
--- a/src/core.js
+++ b/src/core.js
@@ -55,7 +55,7 @@ var
// A simple way to check for HTML strings
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
// Strict HTML recognition (#11290: must start with <)
- rquickExpr = /^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/,
+ rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
// Match a standalone tag
rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,
diff --git a/test/unit/core.js b/test/unit/core.js
index 0969c933e..20e1178d2 100644
--- a/test/unit/core.js
+++ b/test/unit/core.js
@@ -33,7 +33,7 @@ test("jQuery()", function() {
div = jQuery("<div/><hr/><code/><b/>"),
exec = false,
lng = "",
- expected = 20,
+ expected = 22,
attrObj = {
"text": "test",
"class": "test2",
@@ -108,6 +108,12 @@ test("jQuery()", function() {
equal( jQuery(document.body).get(0), jQuery("body").get(0), "Test passing an html node to the factory" );
+ elem = jQuery(" <em>hello</em>")[0];
+ equal( elem.nodeName.toLowerCase(), "em", "leading space" );
+
+ elem = jQuery("\n\n<em>world</em>")[0];
+ equal( elem.nodeName.toLowerCase(), "em", "leading newlines" );
+
elem = jQuery("<div/>", attrObj );
if ( jQuery.fn.width ) {
diff --git a/test/unit/selector.js b/test/unit/selector.js
index 440e7167b..7939ea350 100644
--- a/test/unit/selector.js
+++ b/test/unit/selector.js
@@ -73,18 +73,6 @@ test("disconnected nodes - jQuery only", function() {
equal( $opt.is(":selected"), true, "selected option" );
});
-test("jQuery only - broken", 1, function() {
- raises(function() {
- // Setting context to null here somehow avoids QUnit's window.error handling
- // making the e & e.message correct
- // For whatever reason, without this,
- // Sizzle.error will be called but no error will be seen in oldIE
- jQuery.call( null, " <div/> " );
- }, function( e ) {
- return (/syntax.err/i).test( e.message );
- }, "leading space invalid: $(' <div/> ')" );
-});
-
testIframe("selector/html5_selector", "attributes - jQuery.attr", function( jQuery, window, document ) {
expect( 35 );