<commit_before>export class BehaviorInstance {
	constructor(taskQueue, observerLocator, behaviorType, executionContext, instruction){
		this.behaviorType = behaviorType;
		this.executionContext = executionContext;

		var lookup = observerLocator.getObserversLookup(executionContext),
        skipSelfSubscriber = behaviorType.handlesBind,
        attributes = instruction.attributes,
        boundProperties = this.boundProperties = [],
        properties = behaviorType.properties,
        i, ii, prop, selfSubscriber, observer, info, attribute;

    for(i = 0, ii = properties.length; i < ii; ++i){
      prop = properties[i];

      if(prop.changeHandler){
        selfSubscriber = (newValue, oldValue) => executionContext[prop.changeHandler](newValue, oldValue);
      }

      observer = lookup[prop.name] = new BehaviorPropertyObserver(
        taskQueue, 
        executionContext, 
        prop.name,
        selfSubscriber
        );

      Object.defineProperty(executionContext, prop.name, {
        configurable: true,
        enumerable: true,
        get: observer.getValue.bind(observer),
        set: observer.setValue.bind(observer)
      });

      info = { observer:observer };
      attribute = attributes[prop.attribute];

      if(skipSelfSubscriber){
        observer.selfSubscriber = null;
      }

      if(typeof attribute === 'string'){
        executionContext[prop.name] = attribute;
        observer.call();
      }else if(attribute){
        info.binding = attribute.createBinding(executionContext);
        boundProperties.push(info);
      }else if(prop.defaultValue){
        executionContext[prop.name] = prop.defaultValue;
        observer.call();
      }

      observer.publishing = true;
      observer.selfSubscriber = selfSubscriber;
    }
	}

  created(context){
    if(this.behaviorType.handlesCreated){
      this.executionContext.created(context);
    }
  }

	bind(context){
		var skipSelfSubscriber = this.behaviorType.handlesBind,
        boundProperties = this.boundProperties,
        i, ii, x, observer, selfSubscriber;

    for(i = 0, ii = boundProperties.length; i < ii; ++i){
      x = boundProperties[i];
      observer = x.observer;
      selfSubscriber = observer.selfSubscriber;
      observer.publishing = false;

      if(skipSelfSubscriber){
        observer.selfSubscriber = null;
      }

      x.binding.bind(context);
      observer.call();
<commit_msg>fix(behavior-instance): classic loop, function var bug<commit_after>export class BehaviorInstance {
	constructor(taskQueue, observerLocator, behaviorType, executionContext, instruction){
		this.behaviorType = behaviorType;
		this.executionContext = executionContext;

		var lookup = observerLocator.getObserversLookup(executionContext),
        skipSelfSubscriber = behaviorType.handlesBind,
        attributes = instruction.attributes,
        boundProperties = this.boundProperties = [],
        properties = behaviorType.properties;

    properties.forEach(prop => {
      var selfSubscriber, observer, info, attribute;
      
      if(prop.changeHandler){
        selfSubscriber = (newValue, oldValue) => executionContext[prop.changeHandler](newValue, oldValue);
      }

      observer = lookup[prop.name] = new BehaviorPropertyObserver(
        taskQueue, 
        executionContext, 
        prop.name,
        selfSubscriber
        );

      Object.defineProperty(executionContext, prop.name, {
        configurable: true,
        enumerable: true,
        get: observer.getValue.bind(observer),
        set: observer.setValue.bind(observer)
      });

      info = { observer:observer };
      attribute = attributes[prop.attribute];

      if(skipSelfSubscriber){
        observer.selfSubscriber = null;
      }

      if(typeof attribute === 'string'){
        executionContext[prop.name] = attribute;
        observer.call();
      }else if(attribute){
        info.binding = attribute.createBinding(executionContext);
        boundProperties.push(info);
      }else if(prop.defaultValue){
        executionContext[prop.name] = prop.defaultValue;
        observer.call();
      }

      observer.publishing = true;
      observer.selfSubscriber = selfSubscriber;
    });
	}

  created(context){
    if(this.behaviorType.handlesCreated){
      this.executionContext.created(context);
    }
  }

	bind(context){
		var skipSelfSubscriber = this.behaviorType.handlesBind,
        boundProperties = this.boundProperties,
        i, ii, x, observer, selfSubscriber;

    for(i = 0, ii = boundProperties.length; i < ii; ++i){
      x = boundProperties[i];
      observer = x.observer;
      selfSubscriber = observer.selfSubscriber;
      observer.publishing = false;

      if(skipSelfSubscriber){
        observer.selfSubscriber = null;
      }

      x.binding.bind(context);
      observer.call();

{'fraction_non_alphanumeric': 0.10509950248756218, 'fraction_numerical': 0.0006218905472636816, 'mean_word_length': 2.9068825910931175, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '1427570', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1270, 'n_words': 243}