Skip to content

Commit

Permalink
fix(android): avoid recursion, properties beginning with _ in toJSON()
Browse files Browse the repository at this point in the history
  • Loading branch information
sgtcoolguy committed Jan 10, 2020
1 parent 7280fcc commit f5b6561
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions android/runtime/common/src/js/titanium.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@ bootstrap.defineLazyBinding(Titanium, 'API');
// in a circular reference loop.
Object.defineProperty(Titanium.TiView.prototype, 'toJSON', {
value: function () {
var keys = Object.keys(this);
var keyCount = keys.length;
var serialized = {};
const keys = Object.keys(this);
const keyCount = keys.length;
const serialized = {};

for (var i = 0; i < keyCount; i++) {
var k = keys[i];
if (k === 'parent') {
for (let i = 0; i < keyCount; i++) {
const k = keys[i];
if (k === 'parent' || k.charAt(0) === '_') {
continue;
}
serialized[k] = this[k];
Expand All @@ -184,13 +184,13 @@ Object.defineProperty(Titanium.TiView.prototype, 'toJSON', {

Object.defineProperty(Titanium.UI.NavigationWindow.prototype, 'toJSON', {
value: function () {
var keys = Object.keys(this);
var keyCount = keys.length;
var serialized = {};
const keys = Object.keys(this);
const keyCount = keys.length;
const serialized = {};

for (var i = 0; i < keyCount; i++) {
var k = keys[i];
if (k === 'parent' || k === 'window') {
for (let i = 0; i < keyCount; i++) {
const k = keys[i];
if (k === 'parent' || k === 'window' || k.charAt(0) === '_') {
continue;
}
serialized[k] = this[k];
Expand All @@ -203,13 +203,13 @@ Object.defineProperty(Titanium.UI.NavigationWindow.prototype, 'toJSON', {

Object.defineProperty(Titanium.Activity.prototype, 'toJSON', {
value: function () {
var keys = Object.keys(this);
var keyCount = keys.length;
var serialized = {};
const keys = Object.keys(this);
const keyCount = keys.length;
const serialized = {};

for (var i = 0; i < keyCount; i++) {
var k = keys[i];
if (k === 'activity' || k === 'window' || k === 'intent') {
for (let i = 0; i < keyCount; i++) {
const k = keys[i];
if (k === 'window' || k === 'intent' || k.charAt(0) === '_') {
continue;
}
serialized[k] = this[k];
Expand Down

0 comments on commit f5b6561

Please sign in to comment.