Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

Options not applied within transcluded directive #123

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

VanTanev
Copy link

I came across an issue where a wrapping directive within a transcluded directive would not be able to set ui-ace options. After stepping through the code, I found out the following:

When uiAce.link() is executing, the value of scope.$eval(attrs.uiAce) was undefined. However, when the scope.$watch(attrs.uiAce) was executed for the first time, the value was properly set to the expected object. However,

if (current === previous) return;
short-circuits that first trigger of $watch, leaving us just the default options.

The proposed fix removes that short-circuit (which was not a performance issue in my testing). It also fixes the first call of updateOptions, which erroneously used options instead of opts.

By the way, in my testing, the directive wroks as expected without that updateOptions call when the short-circuit is removed. However, the tests fail. It seems like the tests are in the wrong here - they should probably wait a digest cycle before doing their assertions on the Ace Editor options.

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.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant