hsp/rt/cptwrapper.js
function (change) {
        var chg = change, cpt = this.cpt;
        if (change.constructor === Array) {
            if (change.length > 0) {
                chg = change[0];
            } else {
                log.error('[CptNode] Invalid change - nbr of changes: '+change.length);
                return;
            }
        }
        this.needsRefresh=true;
        var nm = chg.name; // property name
        if (nm === "") {
            return; // doesn't make sens (!)
        }

        var callControllerCb = true; // true if the onXXXChange() callback must be called on the controller

        var att, isAttributeChange = false;
        if (cpt.$attributes) {
            att = cpt.$attributes[nm];
            isAttributeChange = (att !== undefined);
            if (isAttributeChange) {
                // adapt type if applicable
                var t = att.type;
                if (t) {
                    var v = ATTRIBUTE_TYPES[t].convert(chg.newValue, att);
                    chg.newValue = v;
                    cpt[nm] = v; // change is already raised, no need to trigger another one through json.set()
                }
            }

            if (isAttributeChange && this.nodeInstance) {
                // notify attribute changes to the node instance (and the host) if attribute has a 2-way binding
                if (att._binding === 2) {
                    chg.newValue = this.cpt[nm]; // attribute value may have been changed by the controller
                    this.nodeInstance.onAttributeChange(chg);
                }
            }

            if (isAttributeChange) {
                // check if cb must be called depending on binding mode
                if (att._binding === 0) {
                    callControllerCb = false;
                }
            }
        }

        if (callControllerCb) {
            if (this.processingChange === true) {
                // don't re-enter the change loop if we are already processing changes
                return;
            }
            this.processingChange = true;
            try {
                // calculate the callback name (e.g. onValueChange for the 'value' property)
                var cbnm='';
                if (isAttributeChange) {
                    cbnm=att.onchange;
                }
                if (!cbnm) {
                    cbnm = ["$on", nm.charAt(0).toUpperCase(), nm.slice(1), "Change"].join('');
                }

                if (cpt[cbnm]) {
                    cpt[cbnm].call(cpt, chg.newValue, chg.oldValue);
                }

            } finally {
                this.processingChange = false;
            }
        }
    }
function (change) {
        var chg = change, cpt = this.cpt;
        if (change.constructor === Array) {
            if (change.length > 0) {
                chg = change[0];
            } else {
                log.error('[CptNode] Invalid change - nbr of changes: '+change.length);
                return;
            }
        }
        this.needsRefresh=true;
        var nm = chg.name; // property name
        if (nm === "") {
            return; // doesn't make sens (!)
        }

        var callControllerCb = true; // true if the onXXXChange() callback must be called on the controller

        var att, isAttributeChange = false;
        if (cpt.$attributes) {
            att = cpt.$attributes[nm];
            isAttributeChange = (att !== undefined);
            if (isAttributeChange) {
                // adapt type if applicable
                var t = att.type;
                if (t) {
                    var v = ATTRIBUTE_TYPES[t].convert(chg.newValue, att);
                    chg.newValue = v;
                    cpt[nm] = v; // change is already raised, no need to trigger another one through json.set()
                }
            }

            if (isAttributeChange && this.nodeInstance) {
                // notify attribute changes to the node instance (and the host) if attribute has a 2-way binding
                if (att._binding === 2) {
                    chg.newValue = this.cpt[nm]; // attribute value may have been changed by the controller
                    this.nodeInstance.onAttributeChange(chg);
                }
            }

            if (isAttributeChange) {
                // check if cb must be called depending on binding mode
                if (att._binding === 0) {
                    callControllerCb = false;
                }
            }
        }

        if (callControllerCb) {
            if (this.processingChange === true) {
                // don't re-enter the change loop if we are already processing changes
                return;
            }
            this.processingChange = true;
            try {
                // calculate the callback name (e.g. onValueChange for the 'value' property)
                var cbnm='';
                if (isAttributeChange) {
                    cbnm=att.onchange;
                }
                if (!cbnm) {
                    cbnm = ["$on", nm.charAt(0).toUpperCase(), nm.slice(1), "Change"].join('');
                }

                if (cpt[cbnm]) {
                    cpt[cbnm].call(cpt, chg.newValue, chg.oldValue);
                }

            } finally {
                this.processingChange = false;
            }
        }
    }
function ( change ) { var chg = change , cpt = this . cpt ; if ( change . constructor === Array ) { if ( change . length > 0 ) { chg = change [ 0 ] ; } else { log . error ( '[CptNode] Invalid change - nbr of changes: ' + change . length ) ; return ; } } this . needsRefresh = true ; var nm = chg . name ; // property name if ( nm === "" ) { return ; // doesn't make sens (!) } var callControllerCb = true ; // true if the onXXXChange() callback must be called on the controller var att , isAttributeChange = false ; if ( cpt . $attributes ) { att = cpt . $attributes [ nm ] ; isAttributeChange = ( att !== undefined ) ; if ( isAttributeChange ) { // adapt type if applicable var t = att . type ; if ( t ) { var v = ATTRIBUTE_TYPES [ t ] . convert ( chg . newValue , att ) ; chg . newValue = v ; cpt [ nm ] = v ; // change is already raised, no need to trigger another one through json.set() } } if ( isAttributeChange && this . nodeInstance ) { // notify attribute changes to the node instance (and the host) if attribute has a 2-way binding if ( att . _binding === 2 ) { chg . newValue = this . cpt [ nm ] ; // attribute value may have been changed by the controller this . nodeInstance . onAttributeChange ( chg ) ; } } if ( isAttributeChange ) { // check if cb must be called depending on binding mode if ( att . _binding === 0 ) { callControllerCb = false ; } } } if ( callControllerCb ) { if ( this . processingChange === true ) { // don't re-enter the change loop if we are already processing changes return ; } this . processingChange = true ; try { // calculate the callback name (e.g. onValueChange for the 'value' property) var cbnm = '' ; if ( isAttributeChange ) { cbnm = att . onchange ; } if ( ! cbnm ) { cbnm = [ "$on" , nm . charAt ( 0 ) . toUpperCase ( ) , nm . slice ( 1 ) , "Change" ] . join ( '' ) ; } if ( cpt [ cbnm ] ) { cpt [ cbnm ] . call ( cpt , chg . newValue , chg . oldValue ) ; } } finally { this . processingChange = false ; } } }
Check if not already in event handler stack and call the change event handler
Check if not already in event handler stack and call the change event handler