{ "id": "171774", "key": "TIMOB-26118", "fields": { "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "10100", "description": "This issue won't be actioned.", "name": "Won't Do" }, "resolutiondate": "2018-09-18T19:56:22.000+0000", "created": "2018-06-08T23:20:28.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "es6", "ios" ], "versions": [ { "id": "19957", "description": "", "name": "Release 7.1.0", "archived": false, "released": true, "releaseDate": "2018-03-14" } ], "issuelinks": [], "assignee": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2018-09-18T21:47:28.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "*Summary:*\r\niOS 8 does not support the following new ES6 \"String\" methods when \"tiapp.xml\" setting {{}} is set to {{true}}. We should add them so that ES6 support is consistent between iOS versions.\r\n* {{String.prototype.startsWith()}}\r\n* {{String.prototype.endsWith()}}\r\n* {{String.prototype.includes()}}\r\n* {{String.prototype.repeat()}}\r\n\r\n*Steps to reproduce:*\r\n# Set up a project's \"tiapp.xml\" with the below \"transpile\" setting.\r\n# Build and run the below code on iOS 8.\r\n\r\n{code:xml}\r\n\r\n\r\n\ttrue\r\n\r\n{code}\r\n\r\n{code:javascript}\r\nTi.API.info(\"@@@ String.startsWith: \" + (typeof String.prototype.startsWith));\r\nTi.API.info(\"@@@ String.endsWith: \" + (typeof String.prototype.endsWith));\r\nTi.API.info(\"@@@ String.includes: \" + (typeof String.prototype.includes));\r\nTi.API.info(\"@@@ String.repeat: \" + (typeof String.prototype.repeat));\r\n\r\nvar message = \"Hello World\";\r\nTi.API.info(\"@@@ String.startsWith() works? \" + message.startsWith(\"Hello\"));\r\nTi.API.info(\"@@@ String.endsWith() works? \" + message.endsWith(\"World\"));\r\nTi.API.info(\"@@@ String.includes() works? \" + message.includes(\"ello\"));\r\nTi.API.info(\"@@@ String.repeat() works? \" + (\"a\".repeat(3) === \"aaa\"));\r\n{code}\r\n\r\n*Result:*\r\nThe above throws an exception on iOS 8 because the new ES6 String methods are undefined.\r\n\r\nThe above works fine on iOS 9 and newer iOS versions.\r\nThe above works fine on Android as well.\r\n", "attachment": [ { "id": "65259", "filename": "String.js", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-06-11T18:54:53.000+0000", "size": 2236, "mimeType": "application/x-javascript" } ], "flagged": false, "summary": "iOS: Add new ES6 \"String\" methods to iOS 8", "creator": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "438259", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "We could use \"polyfill\" as mentioned here: [TIMOB-25816]\r\n\r\nAlternatively, we can add these methods to the {{String.prototype}} ourselves if we bootstrap the \"app.js\" loading on all platforms as proposed here: [TIMOB-26015]\r\n_(This is the faster/simpler approach.)_", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-06-08T23:46:38.000+0000", "updated": "2018-06-08T23:46:38.000+0000" }, { "id": "438266", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "I'd vote either for the polyfill or adding it on a native level. Using the shell-file for that feels wrong to me.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-06-09T14:26:32.000+0000", "updated": "2018-06-09T14:26:32.000+0000" }, { "id": "438305", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Implementing the missing functions via a JS file is exactly how it would work via polyfill and a webpage's JS. A polyfill is just an ES5 implementation of ES6 functions.\r\n\r\nCase-in-point, Mozilla shows devs how to implement their own polyfill of the {{startsWith()}} function below. Although their implementation can be optimized to use an {{indexOf()}} instead, but the point is that you can just implement your own JavaScript function if it's missing. Pretty easy.\r\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith\r\n\r\nAlso, I've already done it now. :)\r\nSee attached [^String.js] \r\n_(I'll see about optimizing my {{endsWith()}} function further to remove the {{substr()}} call.)_\r\n\r\nI'm not saying we should implement all of the ES6 functions ourselves. But we can implement the popular ones. Especially since Titanium supports disabling trasncoding.", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-06-11T18:56:45.000+0000", "updated": "2018-06-11T18:59:02.000+0000" }, { "id": "438350", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~jquick] The main reason for the babel-polyfill is that it would only be applied to targets that do not support it already, so it reduces the overhead of the built-in scripts. Also, see TIMOB-26123 for the general iOS 8 removal.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-06-12T16:47:32.000+0000", "updated": "2018-06-12T16:47:32.000+0000" }, { "id": "438453", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I do agree that a native implementation would be superior to a polyfill via JavaScript. Especially for the {{String.prototype.repeat()}} method.\r\n\r\nFor now, I need a solution since the core JS scripts I'm introducing to all platforms needs a couple of these functions and it's convenient to have them via our own polyfill. Only Android and Windows would be punished by this overhead (which I think is negligible) since they already have these ES6 functions. But an iOS app would always have these polyfills while the min iOS version supported is iOS 8. So, iOS requires the polyfill overhead unless we add these functions natively.\r\n\r\nIf you can offer me an alternative then I would love to hear it.", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-06-16T04:01:09.000+0000", "updated": "2018-06-16T04:01:09.000+0000" }, { "id": "438454", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "PR (master): https://github.com/appcelerator/titanium_mobile/pull/10112", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-06-16T04:01:13.000+0000", "updated": "2018-06-16T04:01:13.000+0000" }, { "id": "441658", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Titanium now supports ES6 polyfill when \"tiapp.xml\" transpile setting is set {{true}}. That is expected to be used instead. Closing.", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-09-18T19:54:55.000+0000", "updated": "2018-09-18T19:54:55.000+0000" }, { "id": "441662", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "FR Passed.\r\n\r\n{{ES6 \"String\"}} methods works with IOS 8 when {{true}}\r\n\r\nStudio Ver: 5.1.1.201809051655\r\nSDK Ver: 7.5.0.v20180913121236\r\nOS Ver: 10.13.5\r\nXcode Ver: Xcode 9.4.1\r\nAppc NPM: 4.2.13\r\nAppc CLI: 7.0.6\r\nDaemon Ver: 1.1.3\r\nTi CLI Ver: 5.1.1\r\nAlloy Ver: 1.13.2\r\nNode Ver: 8.9.1\r\nNPM Ver: 5.5.1\r\nJava Ver: 10.0.2\r\nIOS Simulator: 8.4", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-09-18T21:33:06.000+0000", "updated": "2018-09-18T21:33:06.000+0000" }, { "id": "441664", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Please ignore above FR comment. The ticket was closed & I had not refreshed my webpage, ", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-09-18T21:47:28.000+0000", "updated": "2018-09-18T21:47:28.000+0000" } ], "maxResults": 9, "total": 9, "startAt": 0 } } }