Fix for bug #1549, where the DOM conversion of <code/> and similar elements would fail. This forces it to work correctly in all browsers.
This commit is contained in:
parent
7d02f06e03
commit
d259ec1a93
2 changed files with 13 additions and 1 deletions
9
src/jquery/coreTest.js
vendored
9
src/jquery/coreTest.js
vendored
|
@ -12,7 +12,7 @@ test("Basic requirements", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("$()", function() {
|
test("$()", function() {
|
||||||
expect(2);
|
expect(5);
|
||||||
|
|
||||||
var main = $("#main");
|
var main = $("#main");
|
||||||
isSet( $("div p", main).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" );
|
isSet( $("div p", main).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" );
|
||||||
|
@ -29,6 +29,13 @@ test("$()", function() {
|
||||||
pass = false;
|
pass = false;
|
||||||
}
|
}
|
||||||
ok( pass, "$('<tag>') needs optional document parameter to ease cross-frame DOM wrangling, see #968" );*/
|
ok( pass, "$('<tag>') needs optional document parameter to ease cross-frame DOM wrangling, see #968" );*/
|
||||||
|
|
||||||
|
var code = $("<code/>");
|
||||||
|
equals( code.length, 1, "Correct number of elements generated for code" );
|
||||||
|
var img = $("<img/>");
|
||||||
|
equals( img.length, 1, "Correct number of elements generated for img" );
|
||||||
|
var div = $("<div/><hr/><code/><b/>");
|
||||||
|
equals( div.length, 4, "Correct number of elements generated for div hr code b" );
|
||||||
});
|
});
|
||||||
|
|
||||||
test("isFunction", function() {
|
test("isFunction", function() {
|
||||||
|
|
5
src/jquery/jquery.js
vendored
5
src/jquery/jquery.js
vendored
|
@ -633,6 +633,11 @@ jQuery.extend({
|
||||||
|
|
||||||
// Convert html string into DOM nodes
|
// Convert html string into DOM nodes
|
||||||
if ( typeof arg == "string" ) {
|
if ( typeof arg == "string" ) {
|
||||||
|
// Fix "XHTML"-style tags in all browsers
|
||||||
|
arg = arg.replace(/(<(\w+)[^>]*?)\/>/g, function(m, all, tag){
|
||||||
|
return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area)$/i)? m : all+"></"+tag+">";
|
||||||
|
});
|
||||||
|
|
||||||
// Trim whitespace, otherwise indexOf won't work as expected
|
// Trim whitespace, otherwise indexOf won't work as expected
|
||||||
var s = jQuery.trim(arg).toLowerCase(), div = doc.createElement("div"), tb = [];
|
var s = jQuery.trim(arg).toLowerCase(), div = doc.createElement("div"), tb = [];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue