This repository was archived by the owner on May 25, 2019. It is now read-only.
File tree 2 files changed +16
-3
lines changed
2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -38,9 +38,9 @@ angular.module('ui.codemirror', [])
38
38
} , opts ) ;
39
39
}
40
40
41
- if ( iAttrs . uiCodemirror ) {
41
+ if ( iAttrs . uiCodemirror || iAttrs . uiCodemirrorOpts ) {
42
42
var codemirrorDefaultsKeys = Object . keys ( window . CodeMirror . defaults ) ;
43
- scope . $watch ( iAttrs . uiCodemirror , function updateOptions ( newValues , oldValue ) {
43
+ scope . $watch ( iAttrs . uiCodemirror || iAttrs . uiCodemirrorOpts , function updateOptions ( newValues , oldValue ) {
44
44
codemirrorDefaultsKeys . forEach ( function ( key ) {
45
45
if ( newValues . hasOwnProperty ( key ) && newValues [ key ] !== oldValue [ key ] ) {
46
46
codeMirror . setOption ( key , newValues [ key ] ) ;
Original file line number Diff line number Diff line change @@ -303,7 +303,7 @@ describe('uiCodemirror', function () {
303
303
} ) ;
304
304
305
305
306
- it ( 'should watch the options' , function ( ) {
306
+ it ( 'should watch the options (attribute directive) ' , function ( ) {
307
307
308
308
scope . cmOption = { readOnly : true } ;
309
309
$compile ( '<div ui-codemirror="cmOption"></div>' ) ( scope ) ;
@@ -316,6 +316,19 @@ describe('uiCodemirror', function () {
316
316
expect ( codemirror . getOption ( 'readOnly' ) ) . toBeFalsy ( ) ;
317
317
} ) ;
318
318
319
+ it ( 'should watch the options (element directive)' , function ( ) {
320
+
321
+ scope . cmOption = { readOnly : true } ;
322
+ $compile ( '<ui-codemirror ui-codemirror-opts="cmOption"></div>' ) ( scope ) ;
323
+ scope . $digest ( ) ;
324
+
325
+ expect ( codemirror . getOption ( 'readOnly' ) ) . toBeTruthy ( ) ;
326
+
327
+ scope . cmOption . readOnly = false ;
328
+ scope . $digest ( ) ;
329
+ expect ( codemirror . getOption ( 'readOnly' ) ) . toBeFalsy ( ) ;
330
+ } ) ;
331
+
319
332
it ( 'should watch the options (object property)' , function ( ) {
320
333
321
334
scope . cm = { } ;
You can’t perform that action at this time.
0 commit comments