This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 4 files changed +44
-2
lines changed
4 files changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ var _undefined = undefined,
105
105
/** @name angular.attrMarkup */
106
106
angularAttrMarkup = extensionMap ( angular , 'attrMarkup' ) ,
107
107
/** @name angular.directive */
108
- angularDirective = extensionMap ( angular , 'directive' ) ,
108
+ angularDirective = extensionMap ( angular , 'directive' , lowercase ) ,
109
109
/** @name angular.widget */
110
110
angularWidget = extensionMap ( angular , 'widget' , shivForIE ) ,
111
111
/** @name angular.filter */
Original file line number Diff line number Diff line change @@ -287,6 +287,7 @@ Compiler.prototype = {
287
287
} ) ;
288
288
} ) ;
289
289
eachAttribute ( element , function ( value , name ) {
290
+ name = lowercase ( name ) ;
290
291
fn = directiveFns [ name ] ;
291
292
if ( fn ) {
292
293
element . addClass ( 'ng-directive' ) ;
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
/**
4
- * @ngdoc overview
4
+ * @ngdoc function
5
5
* @name angular.directive
6
6
* @description
7
7
*
39
39
* For more information about how Angular directives work, and to learn how to create your own
40
40
* directives, see {@link guide/dev_guide.compiler.directives Understanding Angular Directives} in
41
41
* the Angular Developer Guide.
42
+ *
43
+ * @param {string } name Directive identifier (case insensitive).
44
+ * @param {function(string, Element) } compileFn Also called "template function" is a function called
45
+ * during compilation of the template when the compiler comes across the directive being
46
+ * registered. The string value of the element attribute representing the directive and
47
+ * jQuery/jqLite wrapped DOM element are passed as arguments to this function.
48
+ *
49
+ * The `compileFn` function may return a linking function also called an instance function.
50
+ * This function is called during the linking phase when a Scope is being associated with the
51
+ * template or template clone (see repeater notes below). The signature of the linking function
52
+ * is: `function(Element)` where Element is jQuery/jqLite wrapped DOM Element that is being
53
+ * linked.
54
+ *
55
+ * The biggest differenciator between the compile and linking functions is how they are being called
56
+ * when a directive is present within an {@link angular.widget.@ng:repeat ng:repeat}. In this case,
57
+ * the compile function gets called once per occurence of the directive in the template. On the
58
+ * other hand the linking function gets called once for each repeated clone of the template (times
59
+ * number of occurences of the directive in the repeated template).
42
60
*/
43
61
44
62
/**
Original file line number Diff line number Diff line change @@ -427,6 +427,29 @@ describe('angular', function() {
427
427
} ) ;
428
428
} ) ;
429
429
430
+
431
+ describe ( 'directive' , function ( ) {
432
+ it ( 'should register directives with case-insensitive id' , function ( ) {
433
+ angularDirective ( 'ALLCAPS' , function ( val , el ) { el . text ( '+' + val + '+' ) } ) ;
434
+ angularDirective ( 'lowercase' , function ( val , el ) { el . text ( '-' + val + '-' ) } ) ;
435
+
436
+ var el = jqLite ( '<div>' +
437
+ '<span allcaps="xx1"></span>' +
438
+ '<span ALLcaps="xx2"></span>' +
439
+ '<span ALLCAPS="xx3"></span>' +
440
+ '<span lowerCASE="XX4">xx4</span>' +
441
+ '</div>' ) ;
442
+ compile ( el ) ;
443
+ expect ( lowercase ( sortedHtml ( el ) ) ) . toBe ( '<div>' +
444
+ '<span allcaps="xx1">+xx1+</span>' +
445
+ '<span allcaps="xx2">+xx2+</span>' +
446
+ '<span allcaps="xx3">+xx3+</span>' +
447
+ '<span lowercase="xx4">-xx4-</span>' +
448
+ '</div>' ) ;
449
+ } ) ;
450
+ } ) ;
451
+
452
+
430
453
describe ( 'isDate' , function ( ) {
431
454
it ( 'should return true for Date object' , function ( ) {
432
455
expect ( isDate ( new Date ( ) ) ) . toBe ( true ) ;
You can’t perform that action at this time.
0 commit comments