aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortimmywil <timmywillisn@gmail.com>2011-10-23 16:07:07 -0400
committertimmywil <timmywillisn@gmail.com>2011-10-23 16:08:10 -0400
commitf3a4d261ecd0e858515f6e3fa8f5ff59078ec895 (patch)
tree6672e48c062279c753e6f7ccf6ede12affb5abf1
parent516f3cd7b5fd0e374b01843b5f78240feb03d959 (diff)
downloadjquery-f3a4d261ecd0e858515f6e3fa8f5ff59078ec895.tar.gz
jquery-f3a4d261ecd0e858515f6e3fa8f5ff59078ec895.zip
Landing pull request 550. IE6,7,8 cannot use cached fragments from unknown elems. Fixes #10501.
More Details: - https://github.com/jquery/jquery/pull/550 - http://bugs.jquery.com/ticket/10501
-rw-r--r--src/manipulation.js30
-rw-r--r--test/data/testsuite.css3
-rw-r--r--test/unit/manipulation.js14
3 files changed, 32 insertions, 15 deletions
diff --git a/src/manipulation.js b/src/manipulation.js
index 11dca3100..9a662aca4 100644
--- a/src/manipulation.js
+++ b/src/manipulation.js
@@ -1,23 +1,22 @@
(function( jQuery ) {
function createSafeFragment( document ) {
- var nodeNames = (
- "abbr article aside audio canvas datalist details figcaption figure footer " +
- "header hgroup mark meter nav output progress section summary time video"
- ).split( " " ),
+ var list = nodeNames.split( " " ),
safeFrag = document.createDocumentFragment();
if ( safeFrag.createElement ) {
- while ( nodeNames.length ) {
+ while ( list.length ) {
safeFrag.createElement(
- nodeNames.pop()
+ list.pop()
);
}
}
return safeFrag;
}
-var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
+var nodeNames = "abbr article aside audio canvas datalist details figcaption figure footer " +
+ "header hgroup mark meter nav output progress section summary time video",
+ rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
rleadingWhitespace = /^\s+/,
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
rtagName = /<([\w:]+)/,
@@ -25,6 +24,7 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
rhtml = /<|&#?\w+;/,
rnoInnerhtml = /<(?:script|style)/i,
rnocache = /<(?:script|object|embed|option|style)/i,
+ rnoshimcache = new RegExp("<(?:" + nodeNames.replace(" ", "|") + ")", "i"),
// checked="checked" or checked
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
rscriptType = /\/(java|ecma)script/i,
@@ -456,7 +456,8 @@ function cloneFixAttributes( src, dest ) {
}
jQuery.buildFragment = function( args, nodes, scripts ) {
- var fragment, cacheable, cacheresults, doc;
+ var fragment, cacheable, cacheresults, doc,
+ first = args[ 0 ];
// nodes may contain either an explicit document object,
// a jQuery collection or context object.
@@ -476,12 +477,15 @@ jQuery.buildFragment = function( args, nodes, scripts ) {
// Cloning options loses the selected state, so don't cache them
// IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
// Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
- if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && doc === document &&
- args[0].charAt(0) === "<" && !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) {
+ // Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501
+ if ( args.length === 1 && typeof first === "string" && first.length < 512 && doc === document &&
+ first.charAt(0) === "<" && !rnocache.test( first ) &&
+ (jQuery.support.checkClone || !rchecked.test( first )) &&
+ (!jQuery.support.unknownElems && rnoshimcache.test( first )) ) {
cacheable = true;
- cacheresults = jQuery.fragments[ args[0] ];
+ cacheresults = jQuery.fragments[ first ];
if ( cacheresults && cacheresults !== 1 ) {
fragment = cacheresults;
}
@@ -493,7 +497,7 @@ jQuery.buildFragment = function( args, nodes, scripts ) {
}
if ( cacheable ) {
- jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
+ jQuery.fragments[ first ] = cacheresults ? fragment : 1;
}
return { fragment: fragment, cacheable: cacheable };
@@ -735,7 +739,7 @@ jQuery.extend({
},
cleanData: function( elems ) {
- var data, id,
+ var data, id,
cache = jQuery.cache,
special = jQuery.event.special,
deleteExpando = jQuery.support.deleteExpando;
diff --git a/test/data/testsuite.css b/test/data/testsuite.css
index 8c88a9334..d3e4b4e40 100644
--- a/test/data/testsuite.css
+++ b/test/data/testsuite.css
@@ -123,3 +123,6 @@ body, div { background: url(http://static.jquery.com/files/rocker/images/logo_jq
/* #6652 REMOVE FILTER:ALPHA(OPACITY=100) AFTER ANIMATION */
#t6652 div { filter: alpha(opacity=50); }
+
+/* #10501 */
+section { background:#f0f; display:block; } \ No newline at end of file
diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js
index 0b1a1e66a..e8c7cd72a 100644
--- a/test/unit/manipulation.js
+++ b/test/unit/manipulation.js
@@ -472,8 +472,18 @@ test("append HTML5 sectioning elements (Bug #6485)", function () {
var article = jQuery("article"),
aside = jQuery("aside");
- equal( article.css("fontSize"), "10px", 'HTML5 elements are styleable');
- equal( aside.length, 1, 'HTML5 elements do not collapse their children')
+ equal( article.css("fontSize"), "10px", "HTML5 elements are styleable");
+ equal( aside.length, 1, "HTML5 elements do not collapse their children")
+});
+
+test("HTML5 Elements inherit styles from style rules (Bug #10501)", function () {
+ expect(1);
+
+ jQuery("#qunit-fixture").append("<article id='article'></article>");
+ jQuery("#article").append("<section>This section should have a pink background.</section>");
+
+ // In IE, the missing background color will claim its value is "transparent"
+ notEqual( jQuery("section").css("background-color"), "transparent", "HTML5 elements inherit styles");
});
test("clone() (#6485)", function () {