No longer use arguments.callee or RegExp (use new RegExp, instead) for ES 3.1 and Caja compatibility. Fixes jQuery bug #4251.

This commit is contained in:
John Resig 2009-02-26 18:00:41 +00:00
parent 410e13b400
commit 985856b823
3 changed files with 7 additions and 7 deletions

View file

@ -116,7 +116,7 @@ jQuery.event = {
// Namespaced event handlers // Namespaced event handlers
var namespaces = type.split("."); var namespaces = type.split(".");
type = namespaces.shift(); type = namespaces.shift();
var namespace = RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)"); var namespace = new RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)");
if ( events[type] ) { if ( events[type] ) {
// remove the given handler for the given type // remove the given handler for the given type
@ -249,7 +249,7 @@ jQuery.event = {
// Cache this now, all = true means, any handler // Cache this now, all = true means, any handler
all = !namespaces.length && !event.exclusive; all = !namespaces.length && !event.exclusive;
var namespace = RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)"); var namespace = new RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)");
handlers = ( jQuery.data(this, "events") || {} )[event.type]; handlers = ( jQuery.data(this, "events") || {} )[event.type];
@ -354,7 +354,7 @@ jQuery.event = {
}, },
teardown: function( namespaces ){ teardown: function( namespaces ){
if ( namespaces.length ) { if ( namespaces.length ) {
var remove = 0, name = RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)"); var remove = 0, name = new RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)");
jQuery.each( (jQuery.data(this, "events").live || {}), function(){ jQuery.each( (jQuery.data(this, "events").live || {}), function(){
if ( name.test(this.type) ) if ( name.test(this.type) )
@ -560,7 +560,7 @@ jQuery.fn.extend({
}); });
function liveHandler( event ){ function liveHandler( event ){
var check = RegExp("(^|\\.)" + event.type + "(\\.|$)"), var check = new RegExp("(^|\\.)" + event.type + "(\\.|$)"),
stop = true, stop = true,
elems = []; elems = [];

View file

@ -659,7 +659,7 @@ var Expr = Sizzle.selectors = {
var origPOS = Expr.match.POS; var origPOS = Expr.match.POS;
for ( var type in Expr.match ) { for ( var type in Expr.match ) {
Expr.match[ type ] = RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source ); Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source );
} }
var makeArray = function(array, results) { var makeArray = function(array, results) {

View file

@ -75,11 +75,11 @@
root.removeChild( script ); root.removeChild( script );
if ( div.attachEvent && div.fireEvent ) { if ( div.attachEvent && div.fireEvent ) {
div.attachEvent("onclick", function(){ div.attachEvent("onclick", function click(){
// Cloning a node shouldn't copy over any // Cloning a node shouldn't copy over any
// bound event handlers (IE does this) // bound event handlers (IE does this)
jQuery.support.noCloneEvent = false; jQuery.support.noCloneEvent = false;
div.detachEvent("onclick", arguments.callee); div.detachEvent("onclick", click);
}); });
div.cloneNode(true).fireEvent("onclick"); div.cloneNode(true).fireEvent("onclick");
} }