From f5061497f465090be4bb53a4b4b6c534c586d214 Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Fri, 11 Jul 2014 14:01:22 +0200 Subject: [PATCH] fix: undefined newValue watched --- src/ui-codemirror.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ui-codemirror.js b/src/ui-codemirror.js index 3ed221a..42dfbd0 100644 --- a/src/ui-codemirror.js +++ b/src/ui-codemirror.js @@ -41,8 +41,16 @@ angular.module('ui.codemirror', []) if (iAttrs.uiCodemirror || iAttrs.uiCodemirrorOpts) { var codemirrorDefaultsKeys = Object.keys(window.CodeMirror.defaults); scope.$watch(iAttrs.uiCodemirror || iAttrs.uiCodemirrorOpts, function updateOptions(newValues, oldValue) { + if (! angular.isObject(newValues)){ + return; + } codemirrorDefaultsKeys.forEach(function (key) { - if (newValues.hasOwnProperty(key) && newValues[key] !== oldValue[key]) { + if (newValues.hasOwnProperty(key)) { + + if (oldValue && newValues[key] === oldValue[key]){ + return; + } + codeMirror.setOption(key, newValues[key]); } });