X Tutup
Skip to content

fix(ViewContainer) removeChild called with null parent#999

Closed
divdavem wants to merge 1 commit intoangular:masterfrom
divdavem:nestedTemplates
Closed

fix(ViewContainer) removeChild called with null parent#999
divdavem wants to merge 1 commit intoangular:masterfrom
divdavem:nestedTemplates

Conversation

@divdavem
Copy link
Copy Markdown
Contributor

This pull request contains a fix for #997.

In view_container.js, this.templateElement.parentNode can be null when two template tags are nested in one another. I replaced the call to DOM.removeChild by a call to DOM.remove which automatically finds the right parent node.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@vicb @rkirov Doesn't this have perf implication? since now we have to traverse to parent each time. I think there should be a better/faster fix. Can you suggest some?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Something like

var len = view.nodes.length;
if (len == 0) return;
var parent = view.nodes[0].parentNode;
for (var i = len - 1; i >= 0; --i) {
  DOM.removeChild(parent, view.nodes[i]);
}

@divdavem
Copy link
Copy Markdown
Contributor Author

@mhevery @vicb Thank you for your review. I have updated the code.

In view_container.js, templateElement.parentNode can be null
when two template tags are nested in one another.
Accessing the parent node through view.nodes[0].parentNode fixes
the problem.

closes angular#997
@mhevery mhevery added @lgtm action: merge The PR is ready for merge by the caretaker labels Mar 21, 2015
@mhevery mhevery closed this in bd48c92 Mar 21, 2015
@angular-automatic-lock-bot
Copy link
Copy Markdown

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 6, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

X Tutup