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

Replacing input element in the directive re-attaches the formatters and parsers #2573

Open
katranci opened this issue May 3, 2013 · 1 comment

Comments

@katranci
Copy link

katranci commented May 3, 2013

Given that I've got the following HTML template:

    <input ng-model="test" my-directive />

And the directive definition:

    angular.module('myApp', []).
        directive('myDirective', function() {
            return {
                restrict: 'A',
                template: '<input ng-maxlength="3" />',
                replace: true
            }
        });

When I enter more than three characters the input is set as invalid and then set as valid immediately after due to the model value being set to undefined as a result of the first formatter.

Here is a Fiddle that shows the behaviour: http://jsfiddle.net/katranci/G8znC/

lgalfaso added a commit to lgalfaso/angular.js that referenced this issue May 9, 2013
Fix the collecting of directives from elements that will get replaced
by another directive on an attribute. If the element has an attribute
or class directive that will replace the entire element, then do not
collect the directive on the element

Closes angular#2573

BREAKING CHANGE:
* Will break directives that made the assumption that any directive
on the replaced element would get collected
* Will break directives that expect to be collected twice when they
were replaced by another directive that is marked as replace
@IgorMinar
Copy link
Contributor

this issue is more generic. see: #2617 (comment)

@Narretz Narretz added this to the Backlog milestone Jul 4, 2014
@btford btford removed the gh: issue label Aug 20, 2014
Narretz added a commit that referenced this issue Apr 9, 2018
Narretz added a commit that referenced this issue Apr 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants