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
919f74b3
Commit
919f74b3
authored
Aug 21, 2016
by
Leopoldthecoder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
switch itemSelected into a computed property
parent
139a3074
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
16 deletions
+18
-16
packages/select/src/option.vue
packages/select/src/option.vue
+18
-16
No files found.
packages/select/src/option.vue
View file @
919f74b3
...
...
@@ -4,7 +4,7 @@
@
click.stop=
"selectOptionClick"
class=
"el-select-dropdown__item"
v-show=
"queryPassed"
:class=
"
{ 'selected': itemSelected
()
, 'is-disabled': disabled, 'hover': parent.hoverIndex === index }">
:class=
"
{ 'selected': itemSelected, 'is-disabled': disabled, 'hover': parent.hoverIndex === index }">
<slot>
<span>
{{
label
}}
</span>
</slot>
...
...
@@ -13,7 +13,6 @@
<
script
type=
"text/babel"
>
import
emitter
from
'
main/mixins/emitter
'
;
const
toString
=
Object
.
prototype
.
toString
;
export
default
{
mixins
:
[
emitter
],
...
...
@@ -39,7 +38,6 @@
data
()
{
return
{
parent
:
null
,
index
:
-
1
,
queryPassed
:
true
,
hitState
:
false
...
...
@@ -47,8 +45,24 @@
},
computed
:
{
parent
()
{
let
result
=
this
.
$parent
;
while
(
!
result
.
isSelect
)
{
result
=
result
.
$parent
;
}
return
result
;
},
itemSelected
()
{
if
(
Object
.
prototype
.
toString
.
call
(
this
.
parent
.
selected
)
===
'
[object Object]
'
)
{
return
this
===
this
.
parent
.
selected
;
}
else
if
(
Array
.
isArray
(
this
.
parent
.
selected
))
{
return
this
.
parent
.
value
.
indexOf
(
this
.
value
)
>
-
1
;
}
},
currentSelected
()
{
return
this
.
selected
||
(
this
.
$parent
.
multiple
?
this
.
$parent
.
value
.
indexOf
(
this
.
value
)
>
-
1
:
this
.
$
parent
.
value
===
this
.
value
);
return
this
.
selected
||
(
this
.
parent
.
multiple
?
this
.
parent
.
value
.
indexOf
(
this
.
value
)
>
-
1
:
this
.
parent
.
value
===
this
.
value
);
}
},
...
...
@@ -77,14 +91,6 @@
}
},
itemSelected
()
{
if
(
toString
.
call
(
this
.
parent
.
selected
)
===
'
[object Object]
'
)
{
return
this
===
this
.
parent
.
selected
;
}
else
if
(
toString
.
call
(
this
.
parent
.
selected
)
===
'
[object Array]
'
)
{
return
this
.
parent
.
value
.
indexOf
(
this
.
value
)
>
-
1
;
}
},
queryChange
(
query
)
{
this
.
queryPassed
=
new
RegExp
(
query
,
'
i
'
).
test
(
this
.
label
);
if
(
!
this
.
queryPassed
)
{
...
...
@@ -100,10 +106,6 @@
},
created
()
{
this
.
parent
=
this
.
$parent
;
while
(
!
this
.
parent
.
isSelect
)
{
this
.
parent
=
this
.
parent
.
$parent
;
}
this
.
label
=
this
.
label
||
((
typeof
this
.
value
===
'
string
'
||
typeof
this
.
value
===
'
number
'
)
?
this
.
value
:
''
);
this
.
parent
.
options
.
push
(
this
);
this
.
parent
.
optionsCount
++
;
...
...
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