Skip to content
This repository has been archived by the owner on May 25, 2019. It is now read-only.

Commit

Permalink
fix: undefined newValue watched
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasduteil committed Jul 11, 2014
1 parent 0f5802e commit f506149
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/ui-codemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
});
Expand Down

0 comments on commit f506149

Please sign in to comment.