From a19200015cac14b96e259c2aaa8e129fb9bcb6b4 Mon Sep 17 00:00:00 2001 From: Ivan Tanev Date: Sat, 12 Sep 2015 17:27:36 +0300 Subject: [PATCH 1/2] Fix wrong options object given to initial updateOptions() --- src/ui-ace.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui-ace.js b/src/ui-ace.js index a664fb1..424b063 100644 --- a/src/ui-ace.js +++ b/src/ui-ace.js @@ -309,7 +309,7 @@ angular.module('ui.ace', []) // set the options here, even if we try to watch later, if this // line is missing things go wrong (and the tests will also fail) - updateOptions(options); + updateOptions(opts); elm.on('$destroy', function () { acee.session.$stopWorker(); From 6835a49707c740b08a3d55d6a8e519676103db0a Mon Sep 17 00:00:00 2001 From: Ivan Tanev Date: Sat, 12 Sep 2015 17:29:05 +0300 Subject: [PATCH 2/2] Do not short-circuit updateOptions() on first call from $watch In some circumstances, the value of `scope.$eval(attrs.uiAce)` will change between the execution of our link function and the first time `scope.$watch(attrs.uiAce)` is triggered. Since this is context-dependent, we cannot predict it. We could manually store "currentOptions" only for the purpose of short-circuiting that first call, but that would be a waste of effort, so just allow it to execute every time. --- src/ui-ace.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ui-ace.js b/src/ui-ace.js index 424b063..09c15f5 100644 --- a/src/ui-ace.js +++ b/src/ui-ace.js @@ -275,9 +275,8 @@ angular.module('ui.ace', []) } // Listen for option updates - var updateOptions = function (current, previous) { - if (current === previous) return; - opts = angular.extend({}, options, scope.$eval(attrs.uiAce)); + var updateOptions = function (newOptions) { + opts = angular.extend({}, options, newOptions); opts.callbacks = [ opts.onLoad ]; if (opts.onLoad !== options.onLoad) {