benchmarks/scenarios/ember.js
function normalizeComponentAttributes(component, isAngleBracket, attrs) {
    var normalized = {};
    var attributeBindings = component.attributeBindings;
    var streamBasePath = component.isComponent ? '' : 'view.';
    var i, l;

    if (attrs.id && _emberHtmlbarsHooksGetValue.default(attrs.id)) {
      // Do not allow binding to the `id`
      normalized.id = _emberHtmlbarsHooksGetValue.default(attrs.id);
      component.elementId = normalized.id;
    } else {
      normalized.id = component.elementId;
    }

    if (attributeBindings) {
      for (i = 0, l = attributeBindings.length; i < l; i++) {
        var attr = attributeBindings[i];
        var colonIndex = attr.indexOf(':');

        var attrName, expression;
        if (colonIndex !== -1) {
          var attrProperty = attr.substring(0, colonIndex);
          attrName = attr.substring(colonIndex + 1);
          expression = ['get', '' + streamBasePath + attrProperty];
        } else if (attrs[attr]) {
          // TODO: For compatibility with 1.x, we probably need to `set`
          // the component's attribute here if it is a CP, but we also
          // probably want to suspend observers and allow the
          // willUpdateAttrs logic to trigger observers at the correct time.
          attrName = attr;
          expression = ['value', attrs[attr]];
        } else {
          attrName = attr;
          expression = ['get', '' + streamBasePath + attr];
        }

        _emberMetalDebug.assert('You cannot use class as an attributeBinding, use classNameBindings instead.', attrName !== 'class');

        normalized[attrName] = expression;
      }
    }

    if (isAngleBracket) {
      for (var prop in attrs) {
        var val = attrs[prop];
        if (!val) {
          continue;
        }

        if (typeof val === 'string' || val.isConcat) {
          normalized[prop] = ['value', val];
        }
      }
    }

    if (attrs.tagName) {
      component.tagName = attrs.tagName;
    }

    var normalizedClass = normalizeClass(component, attrs, streamBasePath);

    if (normalizedClass) {
      normalized.class = normalizedClass;
    }

    if (_emberMetalProperty_get.get(component, 'isVisible') === false) {
      var hiddenStyle = ['subexpr', '-html-safe', ['display: none;'], []];
      var existingStyle = normalized.style;

      if (existingStyle) {
        normalized.style = ['subexpr', 'concat', [existingStyle, ' ', hiddenStyle], []];
      } else {
        normalized.style = hiddenStyle;
      }
    }

    return normalized;
  }
function normalizeComponentAttributes(component, isAngleBracket, attrs) {
    var normalized = {};
    var attributeBindings = component.attributeBindings;
    var streamBasePath = component.isComponent ? '' : 'view.';
    var i, l;

    if (attrs.id && _emberHtmlbarsHooksGetValue.default(attrs.id)) {
      // Do not allow binding to the `id`
      normalized.id = _emberHtmlbarsHooksGetValue.default(attrs.id);
      component.elementId = normalized.id;
    } else {
      normalized.id = component.elementId;
    }

    if (attributeBindings) {
      for (i = 0, l = attributeBindings.length; i < l; i++) {
        var attr = attributeBindings[i];
        var colonIndex = attr.indexOf(':');

        var attrName, expression;
        if (colonIndex !== -1) {
          var attrProperty = attr.substring(0, colonIndex);
          attrName = attr.substring(colonIndex + 1);
          expression = ['get', '' + streamBasePath + attrProperty];
        } else if (attrs[attr]) {
          // TODO: For compatibility with 1.x, we probably need to `set`
          // the component's attribute here if it is a CP, but we also
          // probably want to suspend observers and allow the
          // willUpdateAttrs logic to trigger observers at the correct time.
          attrName = attr;
          expression = ['value', attrs[attr]];
        } else {
          attrName = attr;
          expression = ['get', '' + streamBasePath + attr];
        }

        _emberMetalDebug.assert('You cannot use class as an attributeBinding, use classNameBindings instead.', attrName !== 'class');

        normalized[attrName] = expression;
      }
    }

    if (isAngleBracket) {
      for (var prop in attrs) {
        var val = attrs[prop];
        if (!val) {
          continue;
        }

        if (typeof val === 'string' || val.isConcat) {
          normalized[prop] = ['value', val];
        }
      }
    }

    if (attrs.tagName) {
      component.tagName = attrs.tagName;
    }

    var normalizedClass = normalizeClass(component, attrs, streamBasePath);

    if (normalizedClass) {
      normalized.class = normalizedClass;
    }

    if (_emberMetalProperty_get.get(component, 'isVisible') === false) {
      var hiddenStyle = ['subexpr', '-html-safe', ['display: none;'], []];
      var existingStyle = normalized.style;

      if (existingStyle) {
        normalized.style = ['subexpr', 'concat', [existingStyle, ' ', hiddenStyle], []];
      } else {
        normalized.style = hiddenStyle;
      }
    }

    return normalized;
  }
function normalizeComponentAttributes ( component , isAngleBracket , attrs ) { var normalized = { } ; var attributeBindings = component . attributeBindings ; var streamBasePath = component . isComponent ? '' : 'view.' ; var i , l ; if ( attrs . id && _emberHtmlbarsHooksGetValue . default ( attrs . id ) ) { // Do not allow binding to the `id` normalized . id = _emberHtmlbarsHooksGetValue . default ( attrs . id ) ; component . elementId = normalized . id ; } else { normalized . id = component . elementId ; } if ( attributeBindings ) { for ( i = 0 , l = attributeBindings . length ; i < l ; i ++ ) { var attr = attributeBindings [ i ] ; var colonIndex = attr . indexOf ( ':' ) ; var attrName , expression ; if ( colonIndex !== - 1 ) { var attrProperty = attr . substring ( 0 , colonIndex ) ; attrName = attr . substring ( colonIndex + 1 ) ; expression = [ 'get' , '' + streamBasePath + attrProperty ] ; } else if ( attrs [ attr ] ) { // TODO: For compatibility with 1.x, we probably need to `set` // the component's attribute here if it is a CP, but we also // probably want to suspend observers and allow the // willUpdateAttrs logic to trigger observers at the correct time. attrName = attr ; expression = [ 'value' , attrs [ attr ] ] ; } else { attrName = attr ; expression = [ 'get' , '' + streamBasePath + attr ] ; } _emberMetalDebug . assert ( 'You cannot use class as an attributeBinding, use classNameBindings instead.' , attrName !== 'class' ) ; normalized [ attrName ] = expression ; } } if ( isAngleBracket ) { for ( var prop in attrs ) { var val = attrs [ prop ] ; if ( ! val ) { continue ; } if ( typeof val === 'string' || val . isConcat ) { normalized [ prop ] = [ 'value' , val ] ; } } } if ( attrs . tagName ) { component . tagName = attrs . tagName ; } var normalizedClass = normalizeClass ( component , attrs , streamBasePath ) ; if ( normalizedClass ) { normalized . class = normalizedClass ; } if ( _emberMetalProperty_get . get ( component , 'isVisible' ) === false ) { var hiddenStyle = [ 'subexpr' , '-html-safe' , [ 'display: none;' ] , [ ] ] ; var existingStyle = normalized . style ; if ( existingStyle ) { normalized . style = [ 'subexpr' , 'concat' , [ existingStyle , ' ' , hiddenStyle ] , [ ] ] ; } else { normalized . style = hiddenStyle ; } } return normalized ; }
Takes a component and builds a normalized set of attribute bindings consumable by HTMLBars' `attribute` hook.
Takes a component and builds a normalized set of attribute bindings consumable by HTMLBars attribute hook .