Permalink
Browse files

Only seal objects that have been initialized.

  • Loading branch information...
1 parent d913da0 commit be9dc542a21cc83277fd5d622fee152549c50396 @creationix committed Aug 19, 2010
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/class.js
View
@@ -13,7 +13,9 @@ var Class = module.exports = Object.create(Object.prototype, {
// Implement new for easy self-initializing objects
new: {value: function new_() {
var obj = Object.create(this);
- if (typeof obj.initialize === 'function') obj.initialize.apply(obj, arguments);
+ if (typeof obj.initialize !== 'function') return obj;
+
+ obj.initialize.apply(obj, arguments);
Object.seal(obj); // Lock the object down so the fields are static
return obj;
}}

0 comments on commit be9dc54

Please sign in to comment.