This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +21
-13
lines changed Expand file tree Collapse file tree 3 files changed +21
-13
lines changed Original file line number Diff line number Diff line change 480
480
*
481
481
* **Mult-slot transclusion** is declared by providing an object for the `transclude` property.
482
482
*
483
- * This object is a map where the keys are the name of the slot to fill and the value is the element selector
484
- * used to match the HTML to the slot. Only element names are supported for matching. If the element selector
485
- * is prefixed with a `?` then that slot is optional .
483
+ * This object is a map where the keys are the name of the slot to fill and the value is an element selector
484
+ * used to match the HTML to the slot. The element selector can be in normalized camelCase form and will match
485
+ * elements using any of the standard variants of the camelCase form .
486
486
*
487
- * For example, the transclude object `{ slotA: '?my-custom-element' }` maps `<my-custom-element>` elements to
487
+ * If the element selector is prefixed with a `?` then that slot is optional.
488
+ *
489
+ * For example, the transclude object `{ slotA: '?myCustomElement' }` maps `<my-custom-element>` elements to
488
490
* the `slotA` slot, which can be accessed via the `$transclude` function or via the {@link ngTransclude} directive.
489
491
*
490
492
* Slots that are not marked as optional (`?`) will trigger a compile time error if there are no matching elements
@@ -1910,7 +1912,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
1910
1912
1911
1913
// Add the matching elements into their slot
1912
1914
forEach ( $compileNode . contents ( ) , function ( node ) {
1913
- var slotName = slotMap [ nodeName_ ( node ) ] ;
1915
+ var slotName = slotMap [ directiveNormalize ( nodeName_ ( node ) ) ] ;
1914
1916
if ( slotName ) {
1915
1917
filledSlots [ slotName ] = true ;
1916
1918
slots [ slotName ] = slots [ slotName ] || [ ] ;
Original file line number Diff line number Diff line change 126
126
* return {
127
127
* restrict: 'E',
128
128
* transclude: {
129
- * 'title': '?pane-title ',
130
- * 'body': 'pane-body ',
131
- * 'footer': '?pane-footer '
129
+ * 'title': '?paneTitle ',
130
+ * 'body': 'paneBody ',
131
+ * 'footer': '?paneFooter '
132
132
* },
133
133
* template: '<div style="border: 1px solid black;">' +
134
134
* '<div class="title" ng-transclude="title">Fallback Title</div>' +
Original file line number Diff line number Diff line change @@ -7941,27 +7941,33 @@ describe('$compile', function() {
7941
7941
} ) ;
7942
7942
7943
7943
7944
- it ( 'should not normalize the element name' , function ( ) {
7944
+ it ( 'should match the normalized form of the element name' , function ( ) {
7945
7945
module ( function ( ) {
7946
7946
directive ( 'foo' , function ( ) {
7947
7947
return {
7948
7948
restrict : 'E' ,
7949
7949
scope : { } ,
7950
7950
transclude : {
7951
- fooBarSlot : 'foo-bar'
7951
+ fooBarSlot : 'fooBar' ,
7952
+ mooKarSlot : 'mooKar'
7952
7953
} ,
7953
7954
template :
7954
- '<div class="other" ng-transclude="fooBarSlot"></div>'
7955
+ '<div class="a" ng-transclude="fooBarSlot"></div>' +
7956
+ '<div class="b" ng-transclude="mooKarSlot"></div>'
7955
7957
} ;
7956
7958
} ) ;
7957
7959
} ) ;
7958
7960
inject ( function ( $rootScope , $compile ) {
7959
7961
element = $compile (
7960
7962
'<foo>' +
7961
- '<foo-bar>baz</foo-bar>' +
7963
+ '<foo-bar>bar1</foo-bar>' +
7964
+ '<foo:bar>bar2</foo:bar>' +
7965
+ '<moo-kar>baz1</moo-kar>' +
7966
+ '<data-moo-kar>baz2</data-moo-kar>' +
7962
7967
'</foo>' ) ( $rootScope ) ;
7963
7968
$rootScope . $apply ( ) ;
7964
- expect ( element . text ( ) ) . toEqual ( 'baz' ) ;
7969
+ expect ( element . children ( ) . eq ( 0 ) . text ( ) ) . toEqual ( 'bar1bar2' ) ;
7970
+ expect ( element . children ( ) . eq ( 1 ) . text ( ) ) . toEqual ( 'baz1baz2' ) ;
7965
7971
} ) ;
7966
7972
} ) ;
7967
7973
You can’t perform that action at this time.
0 commit comments