This repository was archived by the owner on May 25, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 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', [])
3838 } , opts ) ;
3939 }
4040
41- if ( iAttrs . uiCodemirror ) {
41+ if ( iAttrs . uiCodemirror || iAttrs . uiCodemirrorOpts ) {
4242 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 ) {
4444 codemirrorDefaultsKeys . forEach ( function ( key ) {
4545 if ( newValues . hasOwnProperty ( key ) && newValues [ key ] !== oldValue [ key ] ) {
4646 codeMirror . setOption ( key , newValues [ key ] ) ;
Original file line number Diff line number Diff line change @@ -303,7 +303,7 @@ describe('uiCodemirror', function () {
303303 } ) ;
304304
305305
306- it ( 'should watch the options' , function ( ) {
306+ it ( 'should watch the options (attribute directive) ' , function ( ) {
307307
308308 scope . cmOption = { readOnly : true } ;
309309 $compile ( '<div ui-codemirror="cmOption"></div>' ) ( scope ) ;
@@ -316,6 +316,19 @@ describe('uiCodemirror', function () {
316316 expect ( codemirror . getOption ( 'readOnly' ) ) . toBeFalsy ( ) ;
317317 } ) ;
318318
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+
319332 it ( 'should watch the options (object property)' , function ( ) {
320333
321334 scope . cm = { } ;
You can’t perform that action at this time.
0 commit comments