File tree 4 files changed +9
-9
lines changed
4 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import Attribute from './Attribute';
5
5
export default class Slot extends Element {
6
6
type : 'Element' ;
7
7
name : string ;
8
+ slot_name : string ;
8
9
attributes : Attribute [ ] ;
9
10
children : Node [ ] ;
10
11
@@ -27,8 +28,8 @@ export default class Slot extends Element {
27
28
} ) ;
28
29
}
29
30
30
- const slot_name = attr . value [ 0 ] . data ;
31
- if ( slot_name === 'default' ) {
31
+ this . slot_name = attr . value [ 0 ] . data ;
32
+ if ( this . slot_name === 'default' ) {
32
33
component . error ( attr , {
33
34
code : `invalid-slot-name` ,
34
35
message : `default is a reserved word — it cannot be used as a slot name`
@@ -46,6 +47,8 @@ export default class Slot extends Element {
46
47
// validator.slots.add(slot_name);
47
48
} ) ;
48
49
50
+ if ( ! this . slot_name ) this . slot_name = 'default' ;
51
+
49
52
// if (node.attributes.length === 0) && validator.slots.has('default')) {
50
53
// validator.error(node, {
51
54
// code: `duplicate-slot`,
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import add_event_handlers from '../shared/add_event_handlers';
20
20
import add_actions from '../shared/add_actions' ;
21
21
import create_debugging_comment from '../shared/create_debugging_comment' ;
22
22
import { get_context_merger } from '../shared/get_context_merger' ;
23
+ import Slot from '../../../nodes/Slot' ;
23
24
24
25
const events = [
25
26
{
@@ -213,8 +214,7 @@ export default class ElementWrapper extends Wrapper {
213
214
const { renderer } = this ;
214
215
215
216
if ( this . node . name === 'slot' ) {
216
- const slot_name = this . node . get_static_attribute_value ( 'name' ) || 'default' ;
217
- renderer . slots . add ( slot_name ) ;
217
+ renderer . slots . add ( ( this . node as Slot ) . slot_name ) ;
218
218
}
219
219
220
220
if ( this . node . name === 'noscript' ) return ;
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ export default class SlotWrapper extends Wrapper {
55
55
) {
56
56
const { renderer } = this ;
57
57
58
- const slot_name = this . node . get_static_attribute_value ( 'name' ) || 'default' ;
58
+ const { slot_name } = this . node ;
59
59
renderer . slots . add ( slot_name ) ;
60
60
61
61
let get_slot_changes ;
Original file line number Diff line number Diff line change @@ -2,10 +2,7 @@ import { quote_prop_if_necessary } from '../../../utils/names';
2
2
import get_slot_data from '../../utils/get_slot_data' ;
3
3
4
4
export default function ( node , renderer , options ) {
5
- const name = node . attributes . find ( attribute => attribute . name === 'name' ) ;
6
-
7
- const slot_name = name && name . chunks [ 0 ] . data || 'default' ;
8
- const prop = quote_prop_if_necessary ( slot_name ) ;
5
+ const prop = quote_prop_if_necessary ( node . slot_name ) ;
9
6
10
7
const slot_data = get_slot_data ( node . attributes , true ) ;
11
8
You can’t perform that action at this time.
0 commit comments