<commit_before>'use strict';

angular.module('stormpathIdpApp')
  .directive('formControl', function () {
    return {
      restrict: 'A',
      link: function postLink(scope, element, attrs) {
        var fieldname = attrs.name;
        if(!scope.fields){
          scope.fields = {};
        }
        scope.fields[fieldname] = {
          value: element.val(),
          validationError: false,
          errors: scope.errors || {},
          validate: function(){
            return typeof scope.validate === 'function' ? scope.validate(element) : true;
          }
        };

        scope.clearErrors = function(){
          Object.keys(scope.errors).map(function(k){scope.errors[k]=false;});
        };

        element.on('input',function(){
          scope.$apply(function(scope){
            scope.fields[fieldname].value = element.val();
          });
        });
        scope.$watchCollection('errors',function(a){
          angular.extend(scope.fields[fieldname].errors,a||{});
        });
        scope.$watchCollection('fields.'+fieldname,function(a){
          element.val(a.value);
        });
        scope.$watchCollection('fields.'+fieldname+'.errors',function(a){
          angular.extend(scope.errors,a||{});
        });
      }
    };
  });<commit_msg>remove un-necessary element value setter<commit_after>'use strict';

angular.module('stormpathIdpApp')
  .directive('formControl', function () {
    return {
      restrict: 'A',
      link: function postLink(scope, element, attrs) {
        var fieldname = attrs.name;
        if(!scope.fields){
          scope.fields = {};
        }
        scope.fields[fieldname] = {
          value: element.val(),
          validationError: false,
          errors: scope.errors || {},
          validate: function(){
            return typeof scope.validate === 'function' ? scope.validate(element) : true;
          }
        };

        scope.clearErrors = function(){
          Object.keys(scope.errors).map(function(k){scope.errors[k]=false;});
        };

        element.on('input',function(){
          scope.$apply(function(scope){
            scope.fields[fieldname].value = element.val();
          });
        });
        scope.$watchCollection('errors',function(a){
          angular.extend(scope.fields[fieldname].errors,a||{});
        });
        scope.$watchCollection('fields.'+fieldname+'.errors',function(a){
          angular.extend(scope.errors,a||{});
        });
      }
    };
  });
{'fraction_non_alphanumeric': 0.16484848484848486, 'fraction_numerical': 0.0, 'mean_word_length': 2.178433889602054, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4316175', 'n_tokens_mistral': 674, 'n_tokens_neox': 675, 'n_words': 94}