@@ -294,6 +294,26 @@ describe('$compile', function() {
294
294
inject ( function ( $compile ) { } ) ;
295
295
} ) ;
296
296
297
+ it ( 'should omit special chars before processing directive name' , function ( ) {
298
+ module ( function ( ) {
299
+ directive ( 't' , function ( log ) {
300
+ return {
301
+ restrict : 'A' ,
302
+ link : {
303
+ pre : log . fn ( 'pre' ) ,
304
+ post : log . fn ( 'post' )
305
+ }
306
+ } ;
307
+ } ) ;
308
+ } ) ;
309
+ inject ( function ( $compile , $rootScope , log ) {
310
+ element = $compile ( '<div _t></div>' ) ( $rootScope ) ;
311
+ element = $compile ( '<div -t></div>' ) ( $rootScope ) ;
312
+ element = $compile ( '<div :t></div>' ) ( $rootScope ) ;
313
+ expect ( log ) . toEqual ( 'pre; post; pre; post; pre; post' ) ;
314
+ } ) ;
315
+ } ) ;
316
+
297
317
it ( 'should throw an exception if the directive factory is not defined' , function ( ) {
298
318
module ( function ( ) {
299
319
expect ( function ( ) {
@@ -10638,7 +10658,10 @@ describe('$compile', function() {
10638
10658
template :
10639
10659
'<div class="a" ng-transclude="ng-transclude"></div>' +
10640
10660
'<div class="b" ng:transclude="ng:transclude"></div>' +
10641
- '<div class="c" data-ng-transclude="data-ng-transclude"></div>'
10661
+ '<div class="c" data-ng-transclude="data-ng-transclude"></div>' +
10662
+ '<div class="d" -ng-transclude="-ng-transclude"></div>' +
10663
+ '<div class="e" _ng_transclude="_ng_transclude"></div>' +
10664
+ '<div class="f" :ng:transclude=":ng:transclude"></div>'
10642
10665
} ;
10643
10666
} ) ;
10644
10667
} ) ;
@@ -10653,12 +10676,21 @@ describe('$compile', function() {
10653
10676
var a = element . children ( ) . eq ( 0 ) ;
10654
10677
var b = element . children ( ) . eq ( 1 ) ;
10655
10678
var c = element . children ( ) . eq ( 2 ) ;
10679
+ var d = element . children ( ) . eq ( 3 ) ;
10680
+ var e = element . children ( ) . eq ( 4 ) ;
10681
+ var f = element . children ( ) . eq ( 5 ) ;
10656
10682
expect ( a ) . toHaveClass ( 'a' ) ;
10657
10683
expect ( b ) . toHaveClass ( 'b' ) ;
10658
10684
expect ( c ) . toHaveClass ( 'c' ) ;
10685
+ expect ( d ) . toHaveClass ( 'd' ) ;
10686
+ expect ( e ) . toHaveClass ( 'e' ) ;
10687
+ expect ( f ) . toHaveClass ( 'f' ) ;
10659
10688
expect ( a . text ( ) ) . toEqual ( 'stuartbobkevin' ) ;
10660
10689
expect ( b . text ( ) ) . toEqual ( 'stuartbobkevin' ) ;
10661
10690
expect ( c . text ( ) ) . toEqual ( 'stuartbobkevin' ) ;
10691
+ expect ( d . text ( ) ) . toEqual ( 'stuartbobkevin' ) ;
10692
+ expect ( e . text ( ) ) . toEqual ( 'stuartbobkevin' ) ;
10693
+ expect ( f . text ( ) ) . toEqual ( 'stuartbobkevin' ) ;
10662
10694
} ) ;
10663
10695
} ) ;
10664
10696
@@ -11710,6 +11742,18 @@ describe('$compile', function() {
11710
11742
expect ( element . attr ( 'dash-test4' ) ) . toBe ( 'JamieMason' ) ;
11711
11743
} ) ) ;
11712
11744
11745
+ it ( 'should work if they are prefixed with special chars' , inject ( function ( ) {
11746
+ $rootScope . name = 'JamieMason' ;
11747
+ element = $compile ( '<span -ng-attr-dash-test2="{{name}}" _ng-attr-dash-test3="{{name}}" :ng:attr-dash-test4="{{name}}"></span>' ) ( $rootScope ) ;
11748
+ expect ( element . attr ( 'dash-test2' ) ) . toBeUndefined ( ) ;
11749
+ expect ( element . attr ( 'dash-test3' ) ) . toBeUndefined ( ) ;
11750
+ expect ( element . attr ( 'dash-test4' ) ) . toBeUndefined ( ) ;
11751
+ $rootScope . $digest ( ) ;
11752
+ expect ( element . attr ( 'dash-test2' ) ) . toBe ( 'JamieMason' ) ;
11753
+ expect ( element . attr ( 'dash-test3' ) ) . toBe ( 'JamieMason' ) ;
11754
+ expect ( element . attr ( 'dash-test4' ) ) . toBe ( 'JamieMason' ) ;
11755
+ } ) ) ;
11756
+
11713
11757
it ( 'should keep attributes ending with -start single-element directives' , function ( ) {
11714
11758
module ( function ( $compileProvider ) {
11715
11759
$compileProvider . directive ( 'dashStarter' , function ( log ) {
@@ -11774,6 +11818,27 @@ describe('$compile', function() {
11774
11818
expect ( element . find ( 'feDiffuseLighting' ) . attr ( 'surfaceScale' ) ) . toBe ( '1' ) ;
11775
11819
expect ( element . find ( 'feSpecularLighting' ) . attr ( 'surfaceScale' ) ) . toBe ( '1' ) ;
11776
11820
} ) ) ;
11821
+
11822
+ it ( 'should work if they are prefixed with special chars' , inject ( function ( $compile , $rootScope ) {
11823
+ $rootScope . dimensions = '0 0 0 0' ;
11824
+ $rootScope . number = 0.42 ;
11825
+ $rootScope . scale = 1 ;
11826
+
11827
+ element = $compile ( '<svg -ng-attr-view_box="{{dimensions}}">' +
11828
+ '<filter _ng-attr-filter_units="{{number}}">' +
11829
+ '<feDiffuseLighting -ng:attr_surface_scale="{{scale}}"' +
11830
+ ':ng:attr_diffuse_constant="{{number}}"></feDiffuseLighting>' +
11831
+ '<feSpecularLighting _ng:attr_surface_scale="{{scale}}"' +
11832
+ ':ng-attr_diffuse_constant="{{number}}"></feSpecularLighting>' ) ( $rootScope ) ;
11833
+ expect ( element . attr ( 'viewBox' ) ) . toBeUndefined ( ) ;
11834
+ $rootScope . $digest ( ) ;
11835
+ expect ( element . attr ( 'viewBox' ) ) . toBe ( '0 0 0 0' ) ;
11836
+ expect ( element . find ( 'filter' ) . attr ( 'filterUnits' ) ) . toBe ( '0.42' ) ;
11837
+ expect ( element . find ( 'feDiffuseLighting' ) . attr ( 'surfaceScale' ) ) . toBe ( '1' ) ;
11838
+ expect ( element . find ( 'feDiffuseLighting' ) . attr ( 'diffuseConstant' ) ) . toBe ( '0.42' ) ;
11839
+ expect ( element . find ( 'feSpecularLighting' ) . attr ( 'surfaceScale' ) ) . toBe ( '1' ) ;
11840
+ expect ( element . find ( 'feSpecularLighting' ) . attr ( 'diffuseConstant' ) ) . toBe ( '0.42' ) ;
11841
+ } ) ) ;
11777
11842
} ) ;
11778
11843
11779
11844
describe ( 'multi-element directive' , function ( ) {
@@ -12129,6 +12194,28 @@ describe('$compile', function() {
12129
12194
expect ( spans . eq ( 2 ) ) . toBeHidden ( ) ;
12130
12195
expect ( spans . eq ( 3 ) ) . toBeHidden ( ) ;
12131
12196
} ) ) ;
12197
+
12198
+
12199
+ it ( 'should support special char prefix' , inject ( function ( $compile , $rootScope ) {
12200
+ $rootScope . show = false ;
12201
+ element = $compile (
12202
+ '<div>' +
12203
+ '<span -ng-show-start="show"></span>' +
12204
+ '<span -ng-show-end></span>' +
12205
+ '<span :ng-show-start="show"></span>' +
12206
+ '<span :ng-show-end></span>' +
12207
+ '<span _ng-show-start="show"></span>' +
12208
+ '<span _ng-show-end></span>' +
12209
+ '</div>' ) ( $rootScope ) ;
12210
+ $rootScope . $digest ( ) ;
12211
+ var spans = element . find ( 'span' ) ;
12212
+ expect ( spans . eq ( 0 ) ) . toBeHidden ( ) ;
12213
+ expect ( spans . eq ( 1 ) ) . toBeHidden ( ) ;
12214
+ expect ( spans . eq ( 2 ) ) . toBeHidden ( ) ;
12215
+ expect ( spans . eq ( 3 ) ) . toBeHidden ( ) ;
12216
+ expect ( spans . eq ( 4 ) ) . toBeHidden ( ) ;
12217
+ expect ( spans . eq ( 5 ) ) . toBeHidden ( ) ;
12218
+ } ) ) ;
12132
12219
} ) ;
12133
12220
12134
12221
describe ( '$animate animation hooks' , function ( ) {
0 commit comments