Skip to content

Commit ae7ef56

Browse files
committed
Build json-schema-form#895 changes
1 parent 1e18225 commit ae7ef56

File tree

2 files changed

+37
-35
lines changed

2 files changed

+37
-35
lines changed

dist/angular-schema-form.js

+31-29
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* angular-schema-form
33
* @version 1.0.0-alpha.5
4-
* @date Sun, 25 Jun 2017 09:09:24 GMT
4+
* @date Sun, 25 Jun 2017 11:12:48 GMT
55
* @link https://github.com/json-schema-form/angular-schema-form
66
* @license MIT
77
* Copyright (c) 2014-2017 JSON Schema Form
@@ -87,7 +87,7 @@ module.exports = angular;
8787
/* WEBPACK VAR INJECTION */(function(global, setImmediate) {/*!
8888
* json-schema-form-core
8989
* @version 1.0.0-alpha.5
90-
* @date Sat, 24 Jun 2017 14:16:26 GMT
90+
* @date Sun, 25 Jun 2017 10:52:17 GMT
9191
* @link https://github.com/json-schema-form/json-schema-form-core
9292
* @license MIT
9393
* Copyright (c) 2014-2017 JSON Schema Form
@@ -3239,10 +3239,6 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
32393239
model.splice(index, 1);
32403240
}
32413241

3242-
if (item.$$hashKey) {
3243-
scope.destroyed = item.$$hashKey;
3244-
}
3245-
32463242
return model;
32473243
};
32483244

@@ -3638,36 +3634,42 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
36383634
var destroyStrategy = form.destroyStrategy || scope.options && scope.options.destroyStrategy || 'remove';
36393635
// No key no model, and we might have strategy 'retain'
36403636
if (key && destroyStrategy !== 'retain') {
3641-
// Get the object that has the property we wan't to clear.
3642-
var obj = scope.model;
3643-
if (key.length > 1) {
3644-
obj = sfSelect(key.slice(0, key.length - 1), obj);
3645-
}
3646-
3647-
if (obj && scope.destroyed && obj.$$hashKey && obj.$$hashKey !== scope.destroyed) {
3648-
return;
3649-
}
3650-
3651-
// We can get undefined here if the form hasn't been filled out entirely
3652-
if (obj === undefined) {
3653-
return;
3654-
}
36553637

36563638
// Type can also be a list in JSON Schema
36573639
var type = form.schema && form.schema.type || '';
36583640

36593641
// Empty means '',{} and [] for appropriate types and undefined for the rest
3660-
// console.log('destroy', destroyStrategy, key, type, obj);
3661-
if (destroyStrategy === 'empty' && type.indexOf('string') !== -1) {
3662-
obj[key.slice(-1)] = '';
3663-
} else if (destroyStrategy === 'empty' && type.indexOf('object') !== -1) {
3664-
obj[key.slice(-1)] = {};
3665-
} else if (destroyStrategy === 'empty' && type.indexOf('array') !== -1) {
3666-
obj[key.slice(-1)] = [];
3642+
var value = void 0;
3643+
if (destroyStrategy === 'empty') {
3644+
value = type.indexOf('string') !== -1 ? '' : type.indexOf('object') !== -1 ? {} : type.indexOf('array') !== -1 ? [] : undefined;
36673645
} else if (destroyStrategy === 'null') {
3668-
obj[key.slice(-1)] = null;
3646+
value = null;
3647+
}
3648+
3649+
if (value !== undefined) {
3650+
sfSelect(key, scope.model, value);
36693651
} else {
3670-
delete obj[key.slice(-1)];
3652+
// Get the object parent object
3653+
var obj = scope.model;
3654+
if (key.length > 1) {
3655+
obj = sfSelect(key.slice(0, key.length - 1), obj);
3656+
}
3657+
3658+
// parent can be undefined if the form hasn't been filled out
3659+
// entirely
3660+
if (obj === undefined) {
3661+
return;
3662+
}
3663+
3664+
// if parent is an array, then we have already been removed.
3665+
// set flag to all children (who are about to recieve a $destroy
3666+
// event as well) that we have already been destroyed
3667+
if (__WEBPACK_IMPORTED_MODULE_0_angular___default.a.isArray(obj)) {
3668+
scope.externalDestructionInProgress = true;
3669+
return;
3670+
}
3671+
3672+
delete obj[key[key.length - 1]];
36713673
}
36723674
}
36733675
}

0 commit comments

Comments
 (0)