Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Updated angular extend to ignore undefined properties #8387

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Updated angular extend to ignore undefined properties #8387

wants to merge 5 commits into from

Conversation

martynasb
Copy link

Updated angular.extend to ignore undefined properties.

@mary-poppins
Copy link

I'm sorry, but I wasn't able to verify your Contributor License Agreement (CLA) signature. CLA signature is required for any code contributions to AngularJS.

Please sign our CLA and ensure that the CLA signature email address and the email address in this PR's commits match.

If you signed the CLA as a corporation, please let us know the company's name.

Thanks a bunch!

PS: If you signed the CLA in the past then most likely the email addresses don't match. Please sign the CLA again or update the email address in the commit of this PR.
PS2: If you are a Googler, please sign the CLA as well to simplify the CLA verification process.

@mary-poppins
Copy link

CLA signature verified! Thank you!

Someone from the team will now triage your PR and it will be processed based on the determined priority (doc updates and fixes with tests are prioritized over other changes).

@martynasb martynasb removed the cla: no label Jul 29, 2014
Updated angular.extend functionality:
- omit undefined properties in source objects
- allow null properties to be copied
@petebacondarwin
Copy link
Contributor

@martynasb - can you give a use case where this was a problem for you. It would be great to keep angular.extend as fast as possible and I would like to see what the real world problem was that cause you to add this extra check.

@petebacondarwin petebacondarwin added this to the Backlog milestone Jul 29, 2014
@martynasb
Copy link
Author

@petebacondarwin Sure. I was working on a project that involves map visualizations. A map has certain settings: width, height, tile provider, etc.

A developer has an option of setting these options himself to override the defaults.

For example:

We get the default settings:
var defaultSettings = mapSettingsService.getDefaultSettings();

Then get the user options:

//
var userSettings = {
width: attrs.mapWidth,
height: attrs.mapHeight,
tiles: attrs.tiles, /* i.e. google */
...
};

Merge them:
var mapSettings = $.extend(true, {}, defaultSettings, userSettings);

I had to use jQuery's $.extend() because ignores undefined values.
I would prefer doing this with angular.extend

I hope this makes sense

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants