From e0d86209ffe97ab860ff0378ac2a34b049e5b2ff Mon Sep 17 00:00:00 2001 From: Robin Knaapen Date: Thu, 31 Aug 2017 12:22:52 +0200 Subject: [PATCH] Add removeField --- serializer.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/serializer.js b/serializer.js index 91d41cd..c3e93d7 100644 --- a/serializer.js +++ b/serializer.js @@ -111,6 +111,23 @@ class Serializer { } } + /** + * removeField + * + * @param {(HTMLElement|Serializer|SerializerField)} f Serializer child + */ + removeField(f){ + if(this._fields.has(f.name)){ + let fields = this._fields.get(f.name) + if(Array.isArray(fields)){ + let index = fields.indexOf(f); + this._fields.set(f.name, fields.splice(index, 1)) + } else { + this._fields.delete(); + } + } + } + /** * serialize *