Closed w33ble closed 7 years ago
Looks good! This will break in legacy IE so I'll have to make some changes but I think the approach is good! Stay tuned for final code...
Done! Can you please double check https://github.com/marcuswestin/store.js/blob/master/tests/tests.js#L61 to ensure that it behaves in the way you'd expect it to?
I think that looks right. I don't see a test that is checking the arguments to the super_fn, but the use in the second Sorry, now I see how that test works. Yup, that looks right.addPlugin
there is how I would expect to use it.
I'll update #204 and report back.
👍
When a mixin calls
super_fn
, the arguments are currently bound to the original call, which makes it impossible to do some more advanced things, like overrideset
for example.As a plugin author, you may expect that calling
set('foo', 'bar')
results inMODIFIEDbar
being stored. But because the original args value,bar
, is bound, that's the value that gets stored.With this PR, any arguments passed into
super_fn
override the original values, so callingset('foo', 'bar')
with this PR results inMODIFIEDbar
being stored.Additionally, any additional arguments passed in the original call will continue to be passed through unmodified.
I'm not entirely sure how to write tests for this change, short of writing a plugin that would use this change. That said, I would like to modify #204 to use it...