Skip to content
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

fix(drag-drop): avoid generating elements with duplicate ids #13489

Merged
merged 1 commit into from
Nov 10, 2018

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Oct 8, 2018

If the consumer hasn't passed in a custom drag placeholder or preview, we clone the element that is being dragged. This can cause the DOM to have multiple elements with the same id.

@crisbeto crisbeto added the target: major This PR is targeted for the next major release label Oct 8, 2018
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Oct 8, 2018
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Oct 8, 2018
/** Creates a deep clone of an element. */
function deepCloneNode(node: HTMLElement): HTMLElement {
const clone = node.cloneNode(true) as HTMLElement;
// Remove the `id` to avoid having multiple elements with the same id on the page.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this cause issues if the element is styled based on the id?

Should we at least document this in the md file for dragdrop?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a note about it, but we've been doing this in the MatIconRegistry for a long time now and it hasn't come up.

@crisbeto crisbeto force-pushed the drag-drop-duplicate-ids branch from 0a5edb5 to 0816d8e Compare October 9, 2018 09:36
@crisbeto crisbeto added target: patch This PR is targeted for the next patch release and removed target: major This PR is targeted for the next major release labels Oct 18, 2018
@ngbot
Copy link

ngbot bot commented Oct 19, 2018

Hi @crisbeto! This PR has merge conflicts due to recent upstream merges.
Please help to unblock it by resolving these conflicts. Thanks!

@crisbeto crisbeto force-pushed the drag-drop-duplicate-ids branch from 0816d8e to 9311f64 Compare October 20, 2018 10:20
@crisbeto crisbeto force-pushed the drag-drop-duplicate-ids branch from 9311f64 to 8149766 Compare November 8, 2018 08:08
If the consumer hasn't passed in a custom drag placeholder or preview, we clone the element that is being dragged. This can cause the DOM to have multiple elements with the same id.
@vivian-hu-zz vivian-hu-zz merged commit 68b53f7 into angular:master Nov 10, 2018
vivian-hu-zz pushed a commit that referenced this pull request Nov 12, 2018
If the consumer hasn't passed in a custom drag placeholder or preview, we clone the element that is being dragged. This can cause the DOM to have multiple elements with the same id.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants