ded / klass

a utility for creating expressive classes in JavaScript
751 stars 78 forks source link

Bug: self.supr property can get out of sync #10

Closed dwt closed 11 years ago

dwt commented 12 years ago

Hi there,

if a method throws an exception, then the code that resets the supr property does not get executed and therefore the this.supr poperty is out of sync. Consider a situation like this:

var Super = klass({ throwing: function() { throw new Exception(); }, catching: function() {} }; var Sub = Super.extend({ throwing: function() { this.supr() }, catching: function() { try { this.throwing() } catch() { this.supr() } } }

Here the supr() call in catching will actually call throwing again.

dwt commented 12 years ago

IMO you need to protect the code in klass.js at about line 25 with an exception context.

dwt commented 12 years ago

See my pull request #11 for a fix.

rbu commented 11 years ago

ping