vue
vue copied to clipboard
Should `fill` and `copyWithIn` methods be intercepted (observed) now ?
What problem does this feature solve?
fill
and copyWithIn
methods are also mutating methods and has Standard status currently ECMAScript 2015 Language Specification – ECMA-262 6th Edition - copywithin , but they aren't being intercepted in https://github.com/vuejs/vue/blob/237294d88f65d65dcb790246394f1d37d64856a0/src/core/observer/array.js#L11-L19. Should they join now ?
What does the proposed API look like?
null
Is this something I could work on?
Sure @abrahamguo
They wrote such an answer. I hope it can help.
https://www.answerdeveloper.com/questions-answers/vue-questions/should-fill-and-copywithin-methods-be-intercepted-observed-now
The fill and copyWithin methods are array methods that modify the elements of an array in place. In Vue.js, the array.js file you mentioned contains code that patches certain array methods (such as push, pop, shift, unshift, splice, sort, and reverse) in order to make them reactive, so that changes to the array are detected and trigger updates in the view.
It looks like the fill and copyWithin methods are not currently being intercepted in array.js. This means that changes made using these methods will not be detected by Vue.js and will not trigger updates in the view.
If you want the fill and copyWithin methods to be reactive in your Vue.js application, you can add them to the list of methods that are intercepted in array.js.
To do this, you can modify the methodsToPatch array in array.js to include fill and copyWithin.
For example:
const methodsToPatch = [
'push',
'pop',
'shift',
'unshift',
'splice',
'sort',
'reverse',
'fill',
'copyWithin'
]
With this change, the fill and copyWithin methods will be intercepted and changes made using these methods will be detected by Vue.js and trigger updates in the view.