Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
daa4f83e
Commit
daa4f83e
authored
Jul 20, 2017
by
Leopoldthecoder
Committed by
杨奕
Jul 20, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add object-typed value test
parent
40a873e9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
3 deletions
+49
-3
packages/select/src/option.vue
packages/select/src/option.vue
+1
-1
packages/select/src/select.vue
packages/select/src/select.vue
+2
-2
test/unit/specs/select.spec.js
test/unit/specs/select.spec.js
+46
-0
No files found.
packages/select/src/option.vue
View file @
daa4f83e
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
computed
:
{
computed
:
{
isObject
()
{
isObject
()
{
const
type
=
typeof
this
.
value
;
const
type
=
typeof
this
.
value
;
return
type
!==
'
string
'
&&
type
!==
'
number
'
;
return
type
!==
'
string
'
&&
type
!==
'
number
'
&&
type
!==
'
boolean
'
;
},
},
currentLabel
()
{
currentLabel
()
{
...
...
packages/select/src/select.vue
View file @
daa4f83e
...
@@ -366,7 +366,7 @@
...
@@ -366,7 +366,7 @@
getOption
(
value
)
{
getOption
(
value
)
{
let
option
;
let
option
;
const
type
=
typeof
value
;
const
type
=
typeof
value
;
const
isObject
=
type
!==
'
string
'
&&
type
!==
'
number
'
;
const
isObject
=
type
!==
'
string
'
&&
type
!==
'
number
'
&&
type
!==
'
boolean
'
;
for
(
let
i
=
this
.
cachedOptions
.
length
-
1
;
i
>=
0
;
i
--
)
{
for
(
let
i
=
this
.
cachedOptions
.
length
-
1
;
i
>=
0
;
i
--
)
{
const
cachedOption
=
this
.
cachedOptions
[
i
];
const
cachedOption
=
this
.
cachedOptions
[
i
];
const
isEqual
=
isObject
const
isEqual
=
isObject
...
@@ -529,7 +529,7 @@
...
@@ -529,7 +529,7 @@
getValueIndex
(
arr
=
[],
value
)
{
getValueIndex
(
arr
=
[],
value
)
{
const
type
=
typeof
value
;
const
type
=
typeof
value
;
const
isObject
=
type
!==
'
string
'
&&
type
!==
'
number
'
;
const
isObject
=
type
!==
'
string
'
&&
type
!==
'
number
'
&&
type
!==
'
boolean
'
;
if
(
!
isObject
)
{
if
(
!
isObject
)
{
return
arr
.
indexOf
(
value
);
return
arr
.
indexOf
(
value
);
}
else
{
}
else
{
...
...
test/unit/specs/select.spec.js
View file @
daa4f83e
...
@@ -113,6 +113,7 @@ describe('Select', () => {
...
@@ -113,6 +113,7 @@ describe('Select', () => {
<el-option
<el-option
v-for="item in options"
v-for="item in options"
:label="item.label"
:label="item.label"
:key="item.value"
:value="item.value">
:value="item.value">
</el-option>
</el-option>
</el-select>
</el-select>
...
@@ -147,6 +148,7 @@ describe('Select', () => {
...
@@ -147,6 +148,7 @@ describe('Select', () => {
<el-option
<el-option
v-for="item in options"
v-for="item in options"
:label="item.label"
:label="item.label"
:key="item.value"
:value="item.value">
:value="item.value">
<p>{{item.label}} {{item.value}}</p>
<p>{{item.label}} {{item.value}}</p>
</el-option>
</el-option>
...
@@ -226,6 +228,7 @@ describe('Select', () => {
...
@@ -226,6 +228,7 @@ describe('Select', () => {
<el-option
<el-option
v-for="item in options"
v-for="item in options"
:label="item.label"
:label="item.label"
:key="item.value"
:value="item.value">
:value="item.value">
</el-option>
</el-option>
</el-select>
</el-select>
...
@@ -285,6 +288,44 @@ describe('Select', () => {
...
@@ -285,6 +288,44 @@ describe('Select', () => {
},
100
);
},
100
);
});
});
it
(
'
object typed value
'
,
done
=>
{
vm
=
createVue
({
template
:
`
<div>
<el-select v-model="value" value-key="id">
<el-option
v-for="item in options"
:label="item.label"
:key="item.id"
:value="item">
</el-option>
</el-select>
</div>
`
,
data
()
{
return
{
options
:
[{
id
:
1
,
label
:
'
label1
'
},
{
id
:
2
,
label
:
'
label2
'
}],
value
:
{
id
:
1
,
label
:
'
label1
'
}
};
}
},
true
);
setTimeout
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.el-input__inner
'
).
value
).
to
.
equal
(
'
label1
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.el-select-dropdown__item
'
).
classList
.
contains
(
'
selected
'
));
done
();
},
100
);
});
it
(
'
custom el-option template
'
,
()
=>
{
it
(
'
custom el-option template
'
,
()
=>
{
vm
=
createVue
({
vm
=
createVue
({
template
:
`
template
:
`
...
@@ -293,6 +334,7 @@ describe('Select', () => {
...
@@ -293,6 +334,7 @@ describe('Select', () => {
<el-option
<el-option
v-for="item in options"
v-for="item in options"
:label="item.label"
:label="item.label"
:key="item.value"
:value="item.value">
:value="item.value">
<p>{{item.label}} {{item.value}}</p>
<p>{{item.label}} {{item.value}}</p>
</el-option>
</el-option>
...
@@ -320,11 +362,13 @@ describe('Select', () => {
...
@@ -320,11 +362,13 @@ describe('Select', () => {
<el-select v-model="value">
<el-select v-model="value">
<el-option-group
<el-option-group
v-for="group in options"
v-for="group in options"
:key="group.label"
:disabled="group.disabled"
:disabled="group.disabled"
:label="group.label">
:label="group.label">
<el-option
<el-option
v-for="item in group.options"
v-for="item in group.options"
:label="item.label"
:label="item.label"
:key="item.value"
:value="item.value">
:value="item.value">
</el-option>
</el-option>
</el-option-group>
</el-option-group>
...
@@ -416,6 +460,7 @@ describe('Select', () => {
...
@@ -416,6 +460,7 @@ describe('Select', () => {
<el-option
<el-option
v-for="item in options"
v-for="item in options"
:label="item"
:label="item"
:key="item.value"
:value="item"
:value="item"
/>
/>
</el-select>
</el-select>
...
@@ -504,6 +549,7 @@ describe('Select', () => {
...
@@ -504,6 +549,7 @@ describe('Select', () => {
<el-option
<el-option
v-for="item in options"
v-for="item in options"
:label="item.label"
:label="item.label"
:key="item.value"
:value="item.value">
:value="item.value">
<p>{{item.label}} {{item.value}}</p>
<p>{{item.label}} {{item.value}}</p>
</el-option>
</el-option>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment