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.

preLink, DOM manipulation ... compositeLinkFn "TypeError: Cannot read property 'childNodes' of undefined" #2532

Closed
@prashantjain68

Description

@prashantjain68

In one of my directives, in the preLink function I manipulate the DOM (element itself) and its children and descendants.

  • I add attributes to child elements.
  • I remove some children and may be their children.

Later, in the compositeLinkFn, I get the above error.
I also noticed, that if I do the same thing (remove children) in the postLinkFn, I get no errors.

Question: Is this by design (not be able to remove the children in the preLink) or is this a bug. I thought, preLink was supposed to let you manipulate the DOM any way you want.

Is there a way, I can do whatever I want with the DOM before the real compile starts. Something like a preCompile which starts from parent. OR I think there should be a capturePhase compile which goes top-down. In this phase, the compiler would have no knowledge of any descendants and the DOM can be easily manipulated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions