Commit 231d957 1 parent 81f7fcc commit 231d957 Copy full SHA for 231d957
File tree 3 files changed +83
-1
lines changed
packages/@ember/-internals/glimmer
tests/integration/components/link-to
3 files changed +83
-1
lines changed Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ class LinkTo extends InternalComponent implements DeprecatingInternalComponent {
138
138
return ;
139
139
}
140
140
141
- let element = event . target ;
141
+ let element = event . currentTarget ;
142
142
assert ( '[BUG] must be an <a> element' , element instanceof HTMLAnchorElement ) ;
143
143
144
144
let isSelf = element . target === '' || element . target === '_self' ;
Original file line number Diff line number Diff line change @@ -92,6 +92,47 @@ moduleFor(
92
92
) ;
93
93
}
94
94
95
+ async [ '@test [GH#19546] it navigates into the named route when containing other elements' ] (
96
+ assert
97
+ ) {
98
+ this . addTemplate (
99
+ 'about' ,
100
+ `
101
+ <h3 class="about">About</h3>
102
+ <LinkTo @route='index' id='home-link'><span id='inside'>Home</span></LinkTo>
103
+ <LinkTo @route='about' id='self-link'>Self</LinkTo>
104
+ `
105
+ ) ;
106
+
107
+ await this . visit ( '/about' ) ;
108
+
109
+ assert . equal ( this . $ ( 'h3.about' ) . length , 1 , 'The about template was rendered' ) ;
110
+ assert . equal (
111
+ this . $ ( '#self-link.active' ) . length ,
112
+ 1 ,
113
+ 'The self-link was rendered with active class'
114
+ ) ;
115
+ assert . equal (
116
+ this . $ ( '#home-link:not(.active)' ) . length ,
117
+ 1 ,
118
+ 'The other link was rendered without active class'
119
+ ) ;
120
+
121
+ await this . click ( '#inside' ) ;
122
+
123
+ assert . equal ( this . $ ( 'h3.home' ) . length , 1 , 'The home template was rendered' ) ;
124
+ assert . equal (
125
+ this . $ ( '#self-link.active' ) . length ,
126
+ 1 ,
127
+ 'The self-link was rendered with active class'
128
+ ) ;
129
+ assert . equal (
130
+ this . $ ( '#about-link:not(.active)' ) . length ,
131
+ 1 ,
132
+ 'The other link was rendered without active class'
133
+ ) ;
134
+ }
135
+
95
136
async [ `@test [DEPRECATED] it doesn't add an href when the tagName isn't 'a'` ] ( assert ) {
96
137
this . addTemplate (
97
138
'index' ,
Original file line number Diff line number Diff line change @@ -92,6 +92,47 @@ moduleFor(
92
92
) ;
93
93
}
94
94
95
+ async [ '@test [GH#19546] it navigates into the named route when containing other elements' ] (
96
+ assert
97
+ ) {
98
+ this . addTemplate (
99
+ 'about' ,
100
+ `
101
+ <h3 class="about">About</h3>
102
+ <div id="home-link">{{#link-to route='index'}}<span id='inside'>Home</span>{{/link-to}}</div>
103
+ <div id="self-link">{{#link-to route='about'}}Self{{/link-to}}</div>
104
+ `
105
+ ) ;
106
+
107
+ await this . visit ( '/about' ) ;
108
+
109
+ assert . equal ( this . $ ( 'h3.about' ) . length , 1 , 'The about template was rendered' ) ;
110
+ assert . equal (
111
+ this . $ ( '#self-link > a.active' ) . length ,
112
+ 1 ,
113
+ 'The self-link was rendered with active class'
114
+ ) ;
115
+ assert . equal (
116
+ this . $ ( '#home-link > a:not(.active)' ) . length ,
117
+ 1 ,
118
+ 'The other link was rendered without active class'
119
+ ) ;
120
+
121
+ await this . click ( '#inside' ) ;
122
+
123
+ assert . equal ( this . $ ( 'h3.home' ) . length , 1 , 'The home template was rendered' ) ;
124
+ assert . equal (
125
+ this . $ ( '#self-link > a.active' ) . length ,
126
+ 1 ,
127
+ 'The self-link was rendered with active class'
128
+ ) ;
129
+ assert . equal (
130
+ this . $ ( '#about-link > a:not(.active)' ) . length ,
131
+ 1 ,
132
+ 'The other link was rendered without active class'
133
+ ) ;
134
+ }
135
+
95
136
async [ `@test [DEPRECATED] it doesn't add an href when the tagName isn't 'a'` ] ( assert ) {
96
137
this . addTemplate (
97
138
'index' ,
You can’t perform that action at this time.
0 commit comments