Skip to content

Commit 7a22856

Browse files
committed
♻️ Replace substr() with substring()
1 parent f68dc79 commit 7a22856

30 files changed

+58
-54
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ Overall the core Framework files, React Components, and Web Components and API a
1818
* New class version of the core `jsonData` page object:
1919
* `js/pages/classes/JsonData.js`
2020
* All variables and functions from the original file exist in the new one. The purpose of the new file is so that an app can extend it for custom page logic when defining pages as ES6 classes rather than ES5 objects.
21-
```
21+
* Replaces all occurrences of `String.prototype.substr()` with `String.prototype.substring()`. IDE's such as VS Code show `substr()` as depreciated because it is a non-standard function.
22+
* Updated `package.json` to use the latest and specific versions of `@babel/standalone`, `terser`, and `uglify-js` for the build process. This makes the build process work across systems as expected.
23+
```js
24+
// Framework updates to support Classes
25+
2226
app.addPage('name', class Page {
2327
onRouteLoad() {}
2428
onBeforeRender() {}

examples/code-playground-react.htm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@
355355
return {
356356
...state,
357357
selectedFile: action.selectedFile,
358-
currentName: action.selectedFile.substr(0, action.selectedFile.indexOf('.')),
358+
currentName: action.selectedFile.substring(0, action.selectedFile.indexOf('.')),
359359
file: {
360360
type: null,
361361
content: null,

examples/markdown-web.htm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ <h1>DataFormsJS &lt;markdown-content&gt; Web Component<br> with [<span id="selec
171171
// console.log(e.target);
172172

173173
// const html = e.target.innerHTML;
174-
// console.log('Rendered <markdown-content> [' + html.substr(0, 20) + '...] - Total Length: ' + html.length);
174+
// console.log('Rendered <markdown-content> [' + html.substring(0, 20) + '...] - Total Length: ' + html.length);
175175
});
176176
</script>
177177
</body>

js/DataFormsJS.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@
533533

534534
// Is # the first character? If yes remove it
535535
if (path.indexOf('#') === 0) {
536-
path = path.substr(1);
536+
path = path.substring(1);
537537
}
538538

539539
// Define as root url ('/') if blank
@@ -1349,7 +1349,7 @@
13491349
if (typeof page === 'object') {
13501350
obj = page;
13511351
checkModel = true;
1352-
} else if (typeof page === 'function' && page.toString().substr(0, 5) === 'class') {
1352+
} else if (typeof page === 'function' && page.toString().substring(0, 5) === 'class') {
13531353
// JavaScript class is being used
13541354
obj = page.prototype;
13551355
} else {
@@ -1422,7 +1422,7 @@
14221422
}
14231423

14241424
// If a class was passed then create an instance
1425-
if (typeof plugin === 'function' && plugin.toString().substr(0, 5) === 'class') {
1425+
if (typeof plugin === 'function' && plugin.toString().substring(0, 5) === 'class') {
14261426
plugin = new plugin();
14271427
}
14281428

@@ -2549,11 +2549,11 @@
25492549
if (value !== routeParts[n]) {
25502550
// If different then does the route path begin with ':'?
25512551
// If so it is a parameter and if not the route does not match.
2552-
if (routeParts[n].substr(0, 1) === ':') {
2552+
if (routeParts[n].substring(0, 1) === ':') {
25532553
// Add the value to the args[] array and as a property
25542554
// to the namedArgs{} object.
25552555
args.push(value);
2556-
namedArgs[routeParts[n].substr(1)] = value;
2556+
namedArgs[routeParts[n].substring(1)] = value;
25572557
} else {
25582558
return { isMatch: false };
25592559
}

js/DataFormsJS.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/controls/data-list.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@
8787
var attr = rootAttr[n];
8888
var pos = attr.indexOf('=');
8989
if (pos > 1) {
90-
var name = attr.substr(0, pos).trim();
91-
var value = attr.substr(pos+1).trim();
90+
var name = attr.substring(0, pos).trim();
91+
var value = attr.substring(pos+1).trim();
9292
html += ' ' + app.escapeHtml(name) + '="' + app.escapeHtml(value) + '"';
9393
} else {
9494
html += ' ' + app.escapeHtml(attr);

js/controls/data-list.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/controls/data-table.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@
177177
var attr = tableAttr[n];
178178
var pos = attr.indexOf('=');
179179
if (pos > 1) {
180-
name = attr.substr(0, pos).trim();
181-
value = attr.substr(pos+1).trim();
180+
name = attr.substring(0, pos).trim();
181+
value = attr.substring(pos+1).trim();
182182
tableHtml += ' ' + app.escapeHtml(name) + '="' + app.escapeHtml(value) + '"';
183183
// Add [data-sort] so that [app.plugins.sort] can handle
184184
// the Web Component [is="sortable-table"].
@@ -198,8 +198,8 @@
198198
classList.forEach(function(item) {
199199
var pos = item.indexOf('=');
200200
if (pos > 0) {
201-
var col = item.substr(0, pos);
202-
var className = item.substr(pos+1);
201+
var col = item.substring(0, pos);
202+
var className = item.substring(pos+1);
203203
classIndex[col] = className;
204204
}
205205
});

0 commit comments

Comments
 (0)