-
Notifications
You must be signed in to change notification settings - Fork 534
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
Write protection should not vary between debug and prod mode #376
Comments
If clobbering is detected in debug mode doesn't it throw an error? If it does than I think that's fine. If it doesn't then it should. |
Nope, writing to a non-writable property does not throw an error. It just fails silently. > foo = {}
{}
> foo.bar = 'hello'
'hello'
> Object.defineProperty(foo, 'bar', { writable: false })
{ bar: 'hello' }
> foo.bar = 'goodbye'
'goodbye'
> foo.bar
'hello' |
We should make it error (it used to). Unless no-one cares about clobbering (but they probably should) |
It looks like this behavior's been the same since the first open source commit, at least. |
yeah you right, idk. |
weird it should throw in strict mode |
(long delayed response).
Yeah my mistake, I was running the node repl in sloppy mode. That said, flight cannot control whether the code that uses it runs in strict mode or sloppy mode. So I think the problem is still valid. |
Discussed briefly with @PhUU and mentioned to @lawnsea.
Right now the
canWriteProtect
function in utils behaves different in debug mode from production/normal mode:https://github.com/flightjs/flight/blob/master/lib/utils.js#L12
If
debug.enabled
is true, mixins cannot overwrite functions from earlier mixins. Otherwise, later mixins clobber functions from earlier mixins.This can lead to nasty bugs where a component will behave differently when debugging from production mode.
I'd like to remove the
setWritability
calls entirely fromcompose.mixin
, since that's how the library behaves in production. The alternative way to eliminate the discrepancy would be to always write protect, which is much slower.Thoughts?
The text was updated successfully, but these errors were encountered: