hsp/rt/cptcomponent.js
function (defaultTplAtt) {
    if (!this.children) {
      return;
    }

    // TODO memoize result at prototype level to avoid processing this multiple times
    var ct=this.getCptContentType(), loadCpts=true;

    if (ct==="ERROR") {
      loadCpts=false;
      log.error(this.info+" Component content cannot mix attribute elements with content elements");
    } else if (ct!=="ATTELT") {
      if (defaultTplAtt) {
        // ct is CONTENT or INDEFINITE - so we create a default attribute element
        var catt=new $CptAttElement(defaultTplAtt,0,0,0,this.children); // name, exps, attcfg, ehcfg, children

        // add this default cpt att element as unique child
        this.children=[catt];
      } else {
        // there is no defaultTplAtt
        loadCpts=false;
      }
    }

    if (loadCpts) {
      var ni, cn=this.children, sz=cn.length;
      if (!this.attEltNodes) {
        this.attEltNodes=[];
      }
      for (var i=0;sz>i;i++) {
        if (!cn[i].isEmptyTextNode) {
          ni=cn[i].createNodeInstance(this);
          ni.isCptContent=true;
          this.attEltNodes.push(ni);
          // attribute elements will automatically register through registerAttElement()
        }
      }
    }
  }
function (defaultTplAtt) {
    if (!this.children) {
      return;
    }

    // TODO memoize result at prototype level to avoid processing this multiple times
    var ct=this.getCptContentType(), loadCpts=true;

    if (ct==="ERROR") {
      loadCpts=false;
      log.error(this.info+" Component content cannot mix attribute elements with content elements");
    } else if (ct!=="ATTELT") {
      if (defaultTplAtt) {
        // ct is CONTENT or INDEFINITE - so we create a default attribute element
        var catt=new $CptAttElement(defaultTplAtt,0,0,0,this.children); // name, exps, attcfg, ehcfg, children

        // add this default cpt att element as unique child
        this.children=[catt];
      } else {
        // there is no defaultTplAtt
        loadCpts=false;
      }
    }

    if (loadCpts) {
      var ni, cn=this.children, sz=cn.length;
      if (!this.attEltNodes) {
        this.attEltNodes=[];
      }
      for (var i=0;sz>i;i++) {
        if (!cn[i].isEmptyTextNode) {
          ni=cn[i].createNodeInstance(this);
          ni.isCptContent=true;
          this.attEltNodes.push(ni);
          // attribute elements will automatically register through registerAttElement()
        }
      }
    }
  }
function ( defaultTplAtt ) { if ( ! this . children ) { return ; } // TODO memoize result at prototype level to avoid processing this multiple times var ct = this . getCptContentType ( ) , loadCpts = true ; if ( ct === "ERROR" ) { loadCpts = false ; log . error ( this . info + " Component content cannot mix attribute elements with content elements" ) ; } else if ( ct !== "ATTELT" ) { if ( defaultTplAtt ) { // ct is CONTENT or INDEFINITE - so we create a default attribute element var catt = new $CptAttElement ( defaultTplAtt , 0 , 0 , 0 , this . children ) ; // name, exps, attcfg, ehcfg, children // add this default cpt att element as unique child this . children = [ catt ] ; } else { // there is no defaultTplAtt loadCpts = false ; } } if ( loadCpts ) { var ni , cn = this . children , sz = cn . length ; if ( ! this . attEltNodes ) { this . attEltNodes = [ ] ; } for ( var i = 0 ; sz > i ; i ++ ) { if ( ! cn [ i ] . isEmptyTextNode ) { ni = cn [ i ] . createNodeInstance ( this ) ; ni . isCptContent = true ; this . attEltNodes . push ( ni ) ; // attribute elements will automatically register through registerAttElement() } } } }
Check if a default attribute element has to be created and create one if necessary
Check if a default attribute element has to be created and create one if necessary