initialize: function()

in src/sim-host/ui/custom-elements.js [389:432]


        initialize: function () {
            var displayLabel = this.getAttribute('label');
            this.shadowRoot.querySelector('label').textContent = displayLabel;
            this.classList.add('cordova-panel-row');
            this.classList.add('cordova-group');
            this._internalValue = 0;

            var input = this.shadowRoot.querySelector('input');
            input.setAttribute('aria-label', this.getAttribute('spoken-text') || displayLabel);

            var maxValue = this.getAttribute('max'),
                minValue = this.getAttribute('min'),
                value = this.getAttribute('value'),
                step = this.getAttribute('step');

            // initialize _internalValue with one of the available values,
            // otherwise it remains 0
            if (value !== null && utils.isNumber(value)) {
                this._internalValue = value;
            } else if (minValue !== null && utils.isNumber(minValue)) {
                this._internalValue = minValue;
            } else if (maxValue !== null && utils.isNumber(maxValue) && this._internalValue > parseFloat(maxValue)) {
                this._internalValue = maxValue;
            }

            if (maxValue !== null) input.setAttribute('max', maxValue);
            if (minValue !== null) input.setAttribute('min', minValue);
            if (step !== null) input.setAttribute('step', step);
            if (value !== null) input.setAttribute('value', value);

            // verify and force the input value to be a valid number
            input.addEventListener('input', function (event) {
                var value = event.target.value;

                if (utils.isNumber(value)) {
                    this._internalValue = value;
                } else {
                    // the new value is not a number, set the value to the
                    // latest number value
                    input.value = this._internalValue;
                    return false;
                }
            }.bind(this));
        },