File tree 3 files changed +40
-1
lines changed
src/compiler/compile/render_dom/wrappers/Element
test/runtime/samples/spread-element-select-multiple-with-other-attr
3 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -671,7 +671,11 @@ export default class ElementWrapper extends Wrapper {
671
671
// handle edge cases for elements
672
672
if ( this . node . name === 'select' ) {
673
673
const dependencies = new Set < string > ( ) ;
674
- for ( const attr of this . attributes ) {
674
+ const value_or_spread = this . attributes . filter ( attr =>
675
+ attr . node . type === 'Spread' || attr . node . name === 'value'
676
+ ) ;
677
+
678
+ for ( const attr of value_or_spread ) {
675
679
for ( const dep of attr . node . dependencies ) {
676
680
dependencies . add ( dep ) ;
677
681
}
Original file line number Diff line number Diff line change
1
+ export default {
2
+ solo : true ,
3
+ async test ( { assert, component, target } ) {
4
+ const select = target . querySelector ( 'select' ) ;
5
+ const [ option1 , option2 ] = select . childNodes ;
6
+
7
+ let selections = Array . from ( select . selectedOptions ) ;
8
+ assert . equal ( selections . length , 2 ) ;
9
+ assert . ok ( selections . includes ( option1 ) ) ;
10
+ assert . ok ( selections . includes ( option2 ) ) ;
11
+
12
+ component . required = true ;
13
+ selections = Array . from ( select . selectedOptions ) ;
14
+ assert . equal ( selections . length , 2 , 'required' ) ;
15
+ assert . ok ( selections . includes ( option1 ) ) ;
16
+ assert . ok ( selections . includes ( option2 ) ) ;
17
+ assert . ok ( select . required ) ;
18
+
19
+ component . spread = { id : 'id' } ;
20
+ selections = Array . from ( select . selectedOptions ) ;
21
+ assert . equal ( selections . length , 2 , 'spread' ) ;
22
+ assert . ok ( selections . includes ( option1 ) ) ;
23
+ assert . ok ( selections . includes ( option2 ) ) ;
24
+ }
25
+ } ;
Original file line number Diff line number Diff line change
1
+ <script >
2
+ export let value = [' Hello' , ' World' ];
3
+ export let spread = {};
4
+ export let required;
5
+ </script >
6
+
7
+ <select multiple {required } {value } {...spread }>
8
+ <option >Hello</option >
9
+ <option >World</option >
10
+ </select >
You can’t perform that action at this time.
0 commit comments