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