-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
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
Support using result of Vue.extend in mixins #5652
Comments
I always do |
As said in the PR, you should use plain objects instead of You can achieve something similar with |
@posva We are using TypeScript with How can we avoid this problem when we do not have the ability to change the underlying component that we have - are you telling me that I cannot use Vue and TypeScript in this scenario when a simple change to the code would fix this? |
Ideally, the mixin should not be a component, otherwise, you can extend them with |
Why do you use the |
At the same time this should work: http://jsfiddle.net/q1f9f6ts/ |
Actually, I implemented mixins for constructors in the past. The motivation was class style declaration is TypeScript friendly than objects. |
is it possible to have a different decorator to support the friendly declarations but not wrapping the object with |
I think wrapping |
There may be some other factors going on here, I've created an example that uses http://jsfiddle.net/sn7p2goh/4/ Error in firefox:
This was actually the issue that I was having and I traced it to the code that my PR is for, however I do not see what would cause the difference between browsers. A different decorator would be a possibility, however may not be required if this issue is resolved |
I can't work out why it would work in Chrome but not FF, is anyone else able to take a look/any ideas? |
Just a side note: |
Yes, because it's not declared in declaration files due to undocumented API. |
Is it considered public API though? It would definitely be helpful for tools/libs/plugins that need reflection over a component or instance to have access to a normalized options object. In the best case with its own |
It seems that the difference in behaviour in Firefox vs all other browsers is caused by vue-router being present on the page: Sample 1 includes vue-router (external resources) but does not use it - this will error in Firefox Sample 2 has vue-router removed - this works Update, it is not caused by vue-router as such but by the presence of any global mixin: |
@posva This means that when it reaches the watch merge strat parent.watch is already true and so it merges into a single array, which my pull request fixes. I am unsure if I can actually write a unit test for this as the issue is only present in Gecko (only browser with watch support). |
Hey, nice job and thanks a lot for looking into it. Well, you can simulate adding the |
Version
2.3.3
Reproduction link
http://jsfiddle.net/zna06rq4/1/
Steps to reproduce
Run fiddle, error will be shown in console:
What is expected?
"child" should be logged to the console via the watch handler in Child.
What is actually happening?
The watch is not being fired
In strats.watch (
vue/src/core/util/options.js
Line 175 in 086ae44
If this has already been converted to an array (via a previous merge operation) it will convert it to a nested array
[[child]]
.The fix for this seems to be updating line 175 to have:
Array.isArray(child) ? child : [child]
The text was updated successfully, but these errors were encountered: