Skip to content

Commit 7689013

Browse files
committed
Merge pull request #37 from RobLoach/jquery-migrate-1-2-0
Update to jQuery Migrate 1.2.0
2 parents d4c46a3 + 8943cf0 commit 7689013

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

jquery-migrate.js

+19-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* jQuery Migrate - v1.1.1 - 2013-02-16
2+
* jQuery Migrate - v1.2.0 - 2013-05-01
33
* https://github.com/jquery/jquery-migrate
44
* Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors; Licensed MIT
55
*/
@@ -17,8 +17,8 @@ jQuery.migrateWarnings = [];
1717
// jQuery.migrateMute = false;
1818

1919
// Show a message on the console so devs know we're active
20-
if ( !jQuery.migrateMute && window.console && console.log ) {
21-
console.log("JQMIGRATE: Logging is active");
20+
if ( !jQuery.migrateMute && window.console && window.console.log ) {
21+
window.console.log("JQMIGRATE: Logging is active");
2222
}
2323

2424
// Set to false to disable traces that appear with warnings
@@ -33,10 +33,11 @@ jQuery.migrateReset = function() {
3333
};
3434

3535
function migrateWarn( msg) {
36+
var console = window.console;
3637
if ( !warnedAbout[ msg ] ) {
3738
warnedAbout[ msg ] = true;
3839
jQuery.migrateWarnings.push( msg );
39-
if ( window.console && console.warn && !jQuery.migrateMute ) {
40+
if ( console && console.warn && !jQuery.migrateMute ) {
4041
console.warn( "JQMIGRATE: " + msg );
4142
if ( jQuery.migrateTrace && console.trace ) {
4243
console.trace();
@@ -189,26 +190,37 @@ jQuery.attrHooks.value = {
189190
var matched, browser,
190191
oldInit = jQuery.fn.init,
191192
oldParseJSON = jQuery.parseJSON,
193+
rignoreText = /^[^<]*(.*?)[^>]*$/,
192194
// Note this does NOT include the #9521 XSS fix from 1.7!
193-
rquickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*|#([\w\-]*))$/;
195+
rquickExpr = /^[^<]*<[\w\W]+>[^>]*$/;
194196

195197
// $(html) "looks like html" rule change
196198
jQuery.fn.init = function( selector, context, rootjQuery ) {
197199
var match;
198200

199201
if ( selector && typeof selector === "string" && !jQuery.isPlainObject( context ) &&
200-
(match = rquickExpr.exec( selector )) && match[1] ) {
202+
(match = rquickExpr.exec( selector )) && match[0] ) {
201203
// This is an HTML string according to the "old" rules; is it still?
202204
if ( selector.charAt( 0 ) !== "<" ) {
203205
migrateWarn("$(html) HTML strings must start with '<' character");
204206
}
207+
if ( selector.charAt( selector.length -1 ) !== ">" ) {
208+
migrateWarn("$(html) HTML text after last tag is ignored");
209+
}
210+
// Consistently reject any HTML-like string starting with a hash (#9521)
211+
// Note that this may break jQuery 1.6.x code that otherwise would work.
212+
if ( jQuery.trim( selector ).charAt( 0 ) === "#" ) {
213+
migrateWarn("HTML string cannot start with a '#' character");
214+
jQuery.error("JQMIGRATE: Invalid selector string (XSS)");
215+
}
205216
// Now process using loose rules; let pre-1.8 play too
206217
if ( context && context.context ) {
207218
// jQuery object as context; parseHTML expects a DOM object
208219
context = context.context;
209220
}
210221
if ( jQuery.parseHTML ) {
211-
return oldInit.call( this, jQuery.parseHTML( jQuery.trim(selector), context, true ),
222+
match = rignoreText.exec( selector );
223+
return oldInit.call( this, jQuery.parseHTML( match[1] || selector, context, true ),
212224
context, rootjQuery );
213225
}
214226
}

jquery-migrate.min.js

+2-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)