Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18475] String.format is not overwritable, nor inspectable

GitHub Issuen/a
TypeBug
Priorityn/a
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 3.5.0
Fix Version/sn/a
ComponentsTiAPI
Labelsios, ios-jscore, kroll
ReporterPier Paolo Ramon
AssigneeUnknown
Created2015-01-29T09:46:18.000+0000
Updated2018-02-28T19:55:51.000+0000

Description

printPropertyDescriptor(String, 'format');

String.format = 42;

console.log("String.format = " + String.format);

function printPropertyDescriptor(obj, name) {
	var descriptor = Object.getOwnPropertyDescriptor(obj, 'clearTimeout');
	var formatted = JSON.stringify(descriptor, null, 2);
	console.log(name + " = " + formatted);
}
Expected result:
[INFO] :   format = { …some flags here… }
[INFO] :   String.format = 42
Actual result:
[INFO] :   format = undefined
[INFO] :   String.format = function format() {
[INFO] :       [native code]
[INFO] :   }

Comments

  1. Pier Paolo Ramon 2015-01-29

    Here’s the culprit: https://github.com/appcelerator/titanium_mobile/blob/2c7f6fb74fa772e1ecc8d9d5209f83c4a0c06aab/iphone/Classes/KrollContext.m#L1203
  2. Pier Paolo Ramon 2015-01-29

    This issue can be extended to include String.format, String.formatDate, String.formatTime, String.formatDecimal and String.formatCurrency.

JSON Source