Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arguments.callee is deprecated in strict mode for ecma 5 #169

Closed
choonkending opened this issue Dec 20, 2014 · 3 comments
Closed

arguments.callee is deprecated in strict mode for ecma 5 #169

choonkending opened this issue Dec 20, 2014 · 3 comments
Labels
docs Improvements or additions to the documentation package: system Specific to @mui/system

Comments

@choonkending
Copy link
Contributor

Great library, love the amount of effort you guys have put in.

I was checking out src/js/utils/events.js.

once: function (el, type, callback) {
    var typeArray = type.split(' ');

    for (var i = typeArray.length - 1; i >= 0; i--) {
      el.addEventListener(typeArray[i], function(e) {
        e.target.removeEventListener(e.type, arguments.callee);
        return callback(e);
      });
    };
  }

MDN warns that arguments.callee is forbidden in strict mode here.

Would a solution as below be a better option? Thanks!

module.exports = {
    once: function(el, type, callback) {
        var typeArray = type.split(' ');
        var recursiveFunction = function(e){
            e.target.removeEventListener(e.type, recursiveFunction);
            return callback(e);
        };
        for(var i = typeArray.length - 1; i > 0; i--) {
            on(el, typeArray[i], recursiveFunction);
        }
    },
       // IE8+ Support
    on: function(el, type, callback) {
        if(el.addEventListener) {
            el.addEventListener(type, callback);
        } else {
            el.attachEvent('on' + type, function() {
                callback.call(el);
            });
        }
    },
       // IE8+ Support
    off: function(el, type, callback) {
        if(el.removeEventListener) {
            el.removeEventListener(type, callback);
        } else {
            el.detachEvent('on' + type, callback);
        }
    }
};
@hai-cea
Copy link
Member

hai-cea commented Dec 29, 2014

@choonkending Thanks for catching this. Would you like to submit a PR?

@choonkending
Copy link
Contributor Author

@hai-cea Sure would! Will submit a PR soon.

hai-cea added a commit that referenced this issue Jan 3, 2015
#169 arguments.callee is deprecated in strict mode for ecma 5
@hai-cea
Copy link
Member

hai-cea commented Jan 6, 2015

This was fixed with #185

@hai-cea hai-cea closed this as completed Jan 6, 2015
@oliviertassinari oliviertassinari added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 25, 2022
@zannager zannager added docs Improvements or additions to the documentation package: system Specific to @mui/system and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation package: system Specific to @mui/system
Projects
None yet
Development

No branches or pull requests

4 participants