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
fff7dddd
Commit
fff7dddd
authored
May 02, 2017
by
cinwell.li
Committed by
baiyaaaaa
May 02, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Form: remove emitter (#4532)
parent
72b1bc3c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
36 deletions
+38
-36
packages/checkbox/src/checkbox-group.vue
packages/checkbox/src/checkbox-group.vue
+8
-4
packages/checkbox/src/checkbox.vue
packages/checkbox/src/checkbox.vue
+14
-22
packages/form/src/form-item.vue
packages/form/src/form-item.vue
+10
-10
packages/form/src/form.vue
packages/form/src/form.vue
+6
-0
No files found.
packages/checkbox/src/checkbox-group.vue
View file @
fff7dddd
<
script
>
import
Emitter
from
'
element-ui/src/mixins/emitter
'
;
export
default
{
name
:
'
ElCheckboxGroup
'
,
componentName
:
'
ElCheckboxGroup
'
,
mixins
:
[
Emitter
],
provide
()
{
return
{
ElCheckboxGroup
:
this
};
},
inject
:
[
'
ElFormItem
'
],
props
:
{
value
:
{},
...
...
@@ -19,7 +23,7 @@
watch
:
{
value
(
value
)
{
this
.
dispatch
(
'
ElFormItem
'
,
'
el.form.change
'
,
[
value
]
);
this
.
ElFormItem
.
$emit
(
'
el.form.change
'
,
value
);
}
}
};
...
...
packages/checkbox/src/checkbox.vue
View file @
fff7dddd
...
...
@@ -40,13 +40,9 @@
</label>
</template>
<
script
>
import
Emitter
from
'
element-ui/src/mixins/emitter
'
;
export
default
{
name
:
'
ElCheckbox
'
,
mixins
:
[
Emitter
],
componentName
:
'
ElCheckbox
'
,
data
()
{
...
...
@@ -56,6 +52,8 @@
};
},
inject
:
[
'
ElCheckboxGroup
'
],
computed
:
{
model
:
{
get
()
{
...
...
@@ -67,17 +65,16 @@
set
(
val
)
{
if
(
this
.
isGroup
)
{
let
isLimitExceeded
=
false
;
(
this
.
_checkboxG
roup
.
min
!==
undefined
&&
val
.
length
<
this
.
_checkboxG
roup
.
min
&&
(
this
.
g
roup
.
min
!==
undefined
&&
val
.
length
<
this
.
g
roup
.
min
&&
(
isLimitExceeded
=
true
));
(
this
.
_checkboxG
roup
.
max
!==
undefined
&&
val
.
length
>
this
.
_checkboxG
roup
.
max
&&
(
this
.
g
roup
.
max
!==
undefined
&&
val
.
length
>
this
.
g
roup
.
max
&&
(
isLimitExceeded
=
true
));
isLimitExceeded
===
false
&&
this
.
dispatch
(
'
ElCheckboxGroup
'
,
'
input
'
,
[
val
]);
this
.
group
.
$emit
(
'
input
'
,
val
);
}
else
if
(
this
.
value
!==
undefined
)
{
this
.
$emit
(
'
input
'
,
val
);
}
else
{
...
...
@@ -96,21 +93,16 @@
}
},
group
()
{
return
this
.
ElCheckboxGroup
;
},
isGroup
()
{
let
parent
=
this
.
$parent
;
while
(
parent
)
{
if
(
parent
.
$options
.
componentName
!==
'
ElCheckboxGroup
'
)
{
parent
=
parent
.
$parent
;
}
else
{
this
.
_checkboxGroup
=
parent
;
return
true
;
}
}
return
false
;
return
!!
this
.
group
;
},
store
()
{
return
this
.
_checkboxGroup
?
this
.
_checkboxG
roup
.
value
:
this
.
value
;
return
this
.
group
?
this
.
g
roup
.
value
:
this
.
value
;
}
},
...
...
@@ -140,7 +132,7 @@
this
.
$emit
(
'
change
'
,
ev
);
if
(
this
.
isGroup
)
{
this
.
$nextTick
(
_
=>
{
this
.
dispatch
(
'
ElCheckboxGroup
'
,
'
change
'
,
[
this
.
_checkboxGroup
.
value
]
);
this
.
group
.
$emit
(
'
change
'
,
this
.
group
.
value
);
});
}
}
...
...
packages/form/src/form-item.vue
View file @
fff7dddd
...
...
@@ -17,7 +17,6 @@
</
template
>
<
script
>
import
AsyncValidator
from
'
async-validator
'
;
import
emitter
from
'
element-ui/src/mixins/emitter
'
;
function
noop
()
{}
...
...
@@ -49,7 +48,13 @@
componentName
:
'
ElFormItem
'
,
mixins
:
[
emitter
],
provide
()
{
return
{
ElFormItem
:
this
};
},
inject
:
[
'
ElForm
'
],
props
:
{
label
:
String
,
...
...
@@ -93,11 +98,7 @@
return
ret
;
},
form
()
{
var
parent
=
this
.
$parent
;
while
(
parent
.
$options
.
componentName
!==
'
ElForm
'
)
{
parent
=
parent
.
$parent
;
}
return
parent
;
return
this
.
ElForm
;
},
fieldValue
:
{
cache
:
false
,
...
...
@@ -198,8 +199,7 @@
},
mounted
()
{
if
(
this
.
prop
)
{
this
.
dispatch
(
'
ElForm
'
,
'
el.form.addField
'
,
[
this
]);
this
.
ElForm
.
$emit
(
'
el.form.addField
'
,
this
);
let
initialValue
=
this
.
fieldValue
;
if
(
Array
.
isArray
(
initialValue
))
{
initialValue
=
[].
concat
(
initialValue
);
...
...
@@ -223,7 +223,7 @@
}
},
beforeDestroy
()
{
this
.
dispatch
(
'
ElForm
'
,
'
el.form.removeField
'
,
[
this
]
);
this
.
ElForm
.
$emit
(
'
el.form.removeField
'
,
this
);
}
};
</
script
>
packages/form/src/form.vue
View file @
fff7dddd
...
...
@@ -12,6 +12,12 @@
componentName
:
'
ElForm
'
,
provide
()
{
return
{
ElForm
:
this
};
},
props
:
{
model
:
Object
,
rules
:
Object
,
...
...
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