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.

Decorator added directives sometimes fail to compile #12374

Closed
@kschaefe

Description

@kschaefe

If you have a decorator for a directive and add a new directive to the returned array, that directive is never cleaned as it would be if it were added via $compileProvider.directive. This can lead to unexpected results during compilation and violate the principle of least surprise. See cases below, each assuming that the new directive added by the decorator does not include priority (expecting it to be treated as 0).

  1. During normal compilation (no max priority) in addDirective in compile.js, the following line works as expected because the missing priority is never evaluated:
if ((maxPriority === undefined || maxPriority > directive.priority) &&
                 directive.restrict.indexOf(location) != -1) {
  1. During a compilation with a priority, such as ngIf, the same line fails because maxPriority is defined and
maxPriority > directive.priority === false //because directive.priority is undefined

Since it should be valid to add directives during decoration, those directives should either be automatically cleaned or the compiler should perform safer checks for directive properties that have default values.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions