From d8ca64e81324c5021423c2216062d8e20028b73e Mon Sep 17 00:00:00 2001 From: Simon Blackwell Date: Sat, 16 Dec 2017 10:07:42 -0500 Subject: [PATCH] Ensure setAttribute does not cause stack overflow --- cell.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cell.js b/cell.js index 9fbbc07f..968b607e 100644 --- a/cell.js +++ b/cell.js @@ -391,7 +391,10 @@ } else if (key === 'style' && typeof val === 'object') { Phenotype.get(key).set.call($node, val); } else if (typeof val === 'number' || typeof val === 'string' || typeof val === 'boolean') { - $node.setAttribute(key, val); + // AnyWhichWay 2017-12-16 + // the getAttribute avoids issues where other libaries may have redefined setAttribute or made attributes actual object properties + // these can cause recursion stack overflows if not trapped beforehand to ensure the value if not the same + $node.getAttribute(key)==val || $node.setAttribute(key, val); } else if (typeof val === 'function') { Phenotype.get(key).set.call($node, val); }