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

Proposal for angular.copy supporting circular references #7592

Closed
@myitcv

Description

@myitcv

#2618 and various other posts have explored and explained why Angular current does not support the copying of objects with circular references. I believe this is an unnecessary restriction and so would like to make a proposal.

The proposal is simple. Modify angular.copy such that:

function copy(source, destination){
  if (isWindow(source) || isScope(source)) {
    throw ngMinErr('cpws',
      "Can't copy! Making copies of Window or Scope instances is not supported.");
  }

  // ***** ADD THESE LINES ****
  if (source && (source.$clone != null)) {
    return source.$clone(destination);
  }

  // .... 

(The choice of $clone as the function name is intentional)

This then allows the developer to explicitly add support on objects that contain circular references.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions