From 784b3edaec0497c517252ee7ba31a430834765a7 Mon Sep 17 00:00:00 2001 From: Rob Moran Date: Tue, 1 Mar 2016 10:51:37 +0000 Subject: [PATCH] Updated the forms.update() function to be generic --- plugins/c9.ide.ui/forms.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/plugins/c9.ide.ui/forms.js b/plugins/c9.ide.ui/forms.js index a8d916bd..1a4072d0 100644 --- a/plugins/c9.ide.ui/forms.js +++ b/plugins/c9.ide.ui/forms.js @@ -481,14 +481,21 @@ define(function(require, exports, module) { } break; default: - if ("value" in item) - el.lastChild.setAttribute('value', item.value); if ("onclick" in item) el.lastChild.onclick = item.onclick; - if ("visible" in item) - el.lastChild.setAttribute("visible", item.visible) - if ("zindex" in item) - el.lastChild.setAttribute("zindex", item.zindex) + + var ignoreList = ["onclick"]; + + Object.keys(item).forEach(function(key) { + if (ignoreList.indexOf(key) > -1) return; + + var attributeExists = el.lastChild.attributes.some(function(attribute) { + return (attribute.name === key) + }); + + if (attributeExists) + el.lastChild.setAttribute(key, item[key]); + }); break; } })