From 279626a3e3fbd75d60fc3be49b68a99d8ba0a95d Mon Sep 17 00:00:00 2001 From: Jermolene Date: Mon, 17 Mar 2014 08:58:42 +0000 Subject: [PATCH] Freeze array or object tiddler fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously object fields like the tags array weren’t frozen. --- boot/boot.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/boot/boot.js b/boot/boot.js index a43d5ffdd..418936418 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -743,12 +743,18 @@ $tw.Tiddler = function(/* [fields,] fields */) { } } else { // Parse the field with the associated field module (if any) - var fieldModule = $tw.Tiddler.fieldModules[t]; + var fieldModule = $tw.Tiddler.fieldModules[t], + value; if(fieldModule && fieldModule.parse) { - this.fields[t] = fieldModule.parse.call(this,src[t]); + value = fieldModule.parse.call(this,src[t]); } else { - this.fields[t] = src[t]; + value = src[t]; } + // Freeze the field to keep it immutable + if(typeof value === "object") { + Object.freeze(value); + } + this.fields[t] = value; } } }