openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

sap.m.Input._doSelect has inconsistent return types: void & this

Open ghost opened this issue 12 years ago • 3 comments

In openui5-runtime-mobile-1.20.6.zip\resources\sap\m\Input-dbg.js, line 785, _doSelect has inconsistent return types: "return;" in line 787 "return this;" in line 796

/**
 * Selects the text of the InputDomRef in the given range
 * @param {int} [iStart=0] start position of the text selection
 * @param {int} [iEnd=<length of text>] end position of the text selection
 * @return {sap.m.Input} this Input instance
 * @private
 */
sap.m.Input.prototype._doSelect = function(iStart, iEnd){
    if(sap.ui.Device.support.touch){
        return;
    }
    var oDomRef = this._$input[0];
    if (oDomRef) {
        //if no Dom-Ref - no selection (Maybe popup closed)
        var $Ref = this._$input;
        oDomRef.focus();
        $Ref.selectText(iStart?iStart:0, iEnd?iEnd:$Ref.val().length);
    }
    return this;
};

ghost avatar Jun 11 '14 10:06 ghost

Even it looks like an error we can take this as a bug report since it is not allowed to use private/protected functions from outside of the control. But i will talk with control owner to make it consistent. Thanks for your feedback.

aborjinik avatar Jun 11 '14 21:06 aborjinik

Hi, I just thought that this can cause issues to "clean" users of the control, whether they adhere to the "private"/"protected" convention (rule) or not.

Talking of "private", the documentation might have to be fixed, I believe it should state "must NOT": "Private methods are identified by a name starting with an underscore and must be called from outside the control." https://openui5.hana.ondemand.com/docs/guide/85738e3ac3bb407d9e1cfeb8bb9268cb.html

Cheers.

ghost avatar Jun 12 '14 05:06 ghost

Thanks for the hint about the documentation. We'll correct it.

thomaskoetter avatar Jun 12 '14 05:06 thomaskoetter