Skip to content

Commit f5d1fa6

Browse files
committed
fix: support v-slot #1058
1 parent 3406cec commit f5d1fa6

File tree

13 files changed

+62
-47
lines changed

13 files changed

+62
-47
lines changed

antd-tools/gulpfile.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,14 @@ function tag() {
145145
execSync(`git config --global user.name ${process.env.GITHUB_USER_NAME}`);
146146
execSync(`git tag ${version}`);
147147
execSync(
148-
`git push https://${process.env.GITHUB_TOKEN}@github.com/vueComponent/ant-design-vue.git ${version}:${version}`,
148+
`git push https://${
149+
process.env.GITHUB_TOKEN
150+
}@github.com/vueComponent/ant-design-vue.git ${version}:${version}`,
149151
);
150152
execSync(
151-
`git push https://${process.env.GITHUB_TOKEN}@github.com/vueComponent/ant-design-vue.git master:master`,
153+
`git push https://${
154+
process.env.GITHUB_TOKEN
155+
}@github.com/vueComponent/ant-design-vue.git master:master`,
152156
);
153157
console.log('tagged');
154158
}

components/_util/props-util.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ const filterProps = (props, propsData = {}) => {
4444
});
4545
return res;
4646
};
47+
48+
const getScopedSlots = ele => {
49+
return (ele.data && ele.data.scopedSlots) || {};
50+
};
51+
4752
const getSlots = ele => {
4853
let componentOptions = ele.componentOptions || {};
4954
if (ele.$vnode) {
@@ -58,8 +63,9 @@ const getSlots = ele => {
5863
slots[name].push(child);
5964
}
6065
});
61-
return slots;
66+
return { ...slots, ...getScopedSlots(ele) };
6267
};
68+
6369
const getAllChildren = ele => {
6470
let componentOptions = ele.componentOptions || {};
6571
if (ele.$vnode) {

components/table/Table.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,8 +765,9 @@ export default {
765765
const key = this.getColumnKey(column, i);
766766
let filterDropdown;
767767
let sortButton;
768+
let sortTitle;
768769
let customHeaderCell = column.customHeaderCell;
769-
const sortTitle = this.getColumnTitle(column.title, {}) || locale.sortTitle;
770+
const title = this.renderColumnTitle(column.title);
770771
const isSortColumn = this.isSortColumn(column);
771772
if ((column.filters && column.filters.length > 0) || column.filterDropdown) {
772773
const colFilters = key in filters ? filters[key] : [];
@@ -785,6 +786,9 @@ export default {
785786
);
786787
}
787788
if (column.sorter) {
789+
sortTitle =
790+
this.getColumnTitle(Array.isArray(title) ? filterEmpty(title)[0] : title, {}) ||
791+
locale.sortTitle;
788792
const isAscend = isSortColumn && sortOrder === 'ascend';
789793
const isDescend = isSortColumn && sortOrder === 'descend';
790794
sortButton = (
@@ -836,7 +840,7 @@ export default {
836840
title={sortTitleString}
837841
class={sortButton ? `${prefixCls}-column-sorters` : undefined}
838842
>
839-
{this.renderColumnTitle(column.title)}
843+
{title}
840844
{sortButton}
841845
</div>,
842846
filterDropdown,

components/table/index.en-US.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ Follow [Vue jsx](https://github.com/vuejs/babel-plugin-transform-vue-jsx) syntax
8686
xxxx...
8787
},
8888
};
89-
}}
89+
)}
9090
customHeaderRow={(column) => {
9191
return {
9292
on: {
9393
click: () => {}, // click header row
9494
},
9595
};
96-
}}
96+
)}
9797
/>
9898
```
9999

components/table/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const Table = {
3939
column.key = key;
4040
}
4141
if (getSlotOptions(element).__ANT_TABLE_COLUMN_GROUP) {
42-
column.children = this.normalize(children);
42+
column.children = this.normalize(typeof children === 'function' ? children() : children);
4343
} else {
4444
const customRender =
4545
element.data && element.data.scopedSlots && element.data.scopedSlots.default;

components/table/index.zh-CN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ const columns = [{
8888
},
8989

9090
};
91-
}}
91+
)}
9292
customHeaderRow={(column) => {
9393
return {
9494
on: {
9595
click: () => {}, // 点击表头行
9696
}
9797
};
98-
}}
98+
)}
9999
/>
100100
```
101101

components/tree/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function traverseNodesKey(rootChildren, callback) {
1515
const { key } = node;
1616
const children = getSlots(node).default;
1717
if (callback(key) !== false) {
18-
traverseNodesKey(children, callback);
18+
traverseNodesKey(typeof children === 'function' ? children() : children, callback);
1919
}
2020
}
2121

components/vc-select/Select.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,8 @@ const Select = {
11351135
} else if (!label && key) {
11361136
label = key;
11371137
}
1138-
const childChildren = getSlots(child).default;
1138+
let childChildren = getSlots(child).default;
1139+
childChildren = typeof childChildren === 'function' ? childChildren() : childChildren;
11391140
// Match option group label
11401141
if (inputValue && this._filterOption(inputValue, child)) {
11411142
const innerItems = childChildren.map(subChild => {

components/vc-slick/src/slider.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ export default {
110110
if (settings.centerMode) {
111111
if (settings.slidesToScroll > 1 && process.env.NODE_ENV !== 'production') {
112112
console.warn(
113-
`slidesToScroll should be equal to 1 in centerMode, you are using ${settings.slidesToScroll}`,
113+
`slidesToScroll should be equal to 1 in centerMode, you are using ${
114+
settings.slidesToScroll
115+
}`,
114116
);
115117
}
116118
settings.slidesToScroll = 1;
@@ -119,12 +121,16 @@ export default {
119121
if (settings.fade) {
120122
if (settings.slidesToShow > 1 && process.env.NODE_ENV !== 'production') {
121123
console.warn(
122-
`slidesToShow should be equal to 1 when fade is true, you're using ${settings.slidesToShow}`,
124+
`slidesToShow should be equal to 1 when fade is true, you're using ${
125+
settings.slidesToShow
126+
}`,
123127
);
124128
}
125129
if (settings.slidesToScroll > 1 && process.env.NODE_ENV !== 'production') {
126130
console.warn(
127-
`slidesToScroll should be equal to 1 when fade is true, you're using ${settings.slidesToScroll}`,
131+
`slidesToScroll should be equal to 1 when fade is true, you're using ${
132+
settings.slidesToScroll
133+
}`,
128134
);
129135
}
130136
settings.slidesToShow = 1;

components/vc-table/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const Table = {
4040
column.key = key;
4141
}
4242
if (getSlotOptions(element).isTableColumnGroup) {
43-
column.children = this.normalize(children);
43+
column.children = this.normalize(typeof children === 'function' ? children() : children);
4444
} else {
4545
const customRender =
4646
element.data && element.data.scopedSlots && element.data.scopedSlots.default;

0 commit comments

Comments
 (0)