constructor.name polyfill is buggy under strict mode #2139

Closed
paulmillr opened this Issue Feb 25, 2012 · 2 comments

Comments

Projects
None yet
2 participants
class Class

var Class;
Class = (function() {
  Class.name = 'Class';
  function Class() {}
  return Class;
})();

wrap it

(function() {
  'use strict';
  var Class;
  Class = (function() {
    Class.name = 'Class';
    function Class() {}
    return Class;
  })();
})();

Result: TypeError: Attempted to assign to readonly property.. #2135 is related.

paulmillr referenced this issue in maxtaco/coffee-script Feb 25, 2012

Open

Class.name is readonly in strict mode #22

Workaround: compile to

var Class;
Class = (function() {
  if (Class.name == null) Class.name = 'Class';
  function Class() {}
  return Class;
})();
Collaborator

michaelficarra commented Feb 25, 2012

Thanks, but we're already looking into this in #2052.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment