-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Replaced angular.extend with Utilities.extend #10023
Replaced angular.extend with Utilities.extend #10023
Conversation
Maybe this is one you would like to review @nathanwoulfe and I think the original issue then can be closed 😁🔥🚀 |
src/Umbraco.Web.UI.Client/src/common/directives/components/umbaceeditor.directive.js
Outdated
Show resolved
Hide resolved
src/Umbraco.Web.UI.Client/src/common/directives/components/umbaceeditor.directive.js
Outdated
Show resolved
Hide resolved
If that's the case, it's probably a bug in |
Looks like Umbraco-CMS/src/Umbraco.Web.UI.Client/src/utilities.js Lines 33 to 37 in 5e4d326
So that's the problem with using |
@ronaldbarendse yes, not sure if we wanted to support the format It would require changing the |
Pretty sure boring old Object.assign() allows multiples sources, so `var obj = Object.assign({}, foo, bar) would assign props from foo and bar to the empty object, and return that new object. Given that, do we need to abstract anything? Could we just use Object.assign instead? |
@nathanwoulfe it seems Do you know how we can change the |
@bjarnef @nathanwoulfe I'm definitely not an angular expert - just wondering what the differences are between https://codesandbox.io/s/polished-grass-61iqt I did initially pull down the repo, replace everything with |
At some point all the angular js facade stuff will disappear, and we'll be using Object.assign everywhere - I'm not sure of use cases where we'd want to be deep-copying (I haven't had a good look, but most cases are extending config objects with additional fields, so Object.assign would be perfectly ok). Biggest difference between the two methods is .extend is angular-friendly, and preserves the $$hashKey property, which is critical when extending angular-managed objects. If none of our extends are called on angular objects, then that's not an issue. |
@nathanwoulfe I have updated it to use the spread operator.
|
I tried with and without spread operator in the |
Hmm, that's interesting - my test case was entirely in the browser console, so maybe different result compared to the gulpified JavaScript? |
Yes, it could be some configuration in Gulp and/or in Babel. Maybe @nielslyngsoe or @madsrasmussen can help here? |
@nathanwoulfe okay, I found this https://davidwalsh.name/merge-objects mentioning this:
and it seems when configurating this Babel plugin it works: https://babeljs.io/docs/en/babel-plugin-proposal-object-rest-spread Fixed in 6f3b0f9 |
I have leaved the |
@ronaldbarendse @nathanwoulfe are you happy with the latest changes? 😁 |
@nathanwoulfe could you have another look at this? It would be great to solve the last part of your original issue/feature request ✨ |
src/Umbraco.Web.UI.Client/src/views/propertyeditors/datepicker/datepicker.controller.js
Outdated
Show resolved
Hide resolved
… makes multiple arguments easy
@bjarnef @ronaldbarendse it took a while, but we got there - I've gone with the alias in utilities:
because it's the lowest impact change. No need to modify parameters, it's a direct alias and will Just Work. No traces of |
@nathanwoulfe I see you've also merged the changes to |
@ronaldbarendse the changes in |
@bjarnef The spread operator isn't used anymore in this PR, as it now uses the function alias, right? Lets not try to add features/NPM packages that aren't needed to keep everything clean (and not introduce side-effects because of the additional transpiling) 😉 |
Prerequisites
If there's an existing issue for this PR then this fixes #7718
Description
This PR replaced of references on
angular.extend()
withUtilities.extend()
except in theUtilities
helper itself.Note that
angular.extend(dst, src)
could be use with two or more arguments to pass in multiple source objects.This was used a few places like
var object = angular.extend({}, object1, object2);
- we could implement this, but not sure if it is worth if as it was only use a few places and if AngularJS is replaced later or we later want to use vanilla JS here.For example
var opts = Utilities.extend({}, options, scope.umbAceEditor);
would returns an empty object, whilevar opts = Utilities.extend(options, scope.umbAceEditor);
returns the same as the previousvar opts = angular.extend({}, options, scope.umbAceEditor);
.