Skip to content

Commit 79784ae

Browse files
authored
fix: clean up props inheritance (#6265)
1 parent dca9518 commit 79784ae

File tree

7 files changed

+34
-32
lines changed

7 files changed

+34
-32
lines changed

src/components/collapse/helpers/bv-collapse.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
// in-place after the transition completes
88
import { Vue, mergeData } from '../../../vue'
99
import { NAME_COLLAPSE_HELPER } from '../../../constants/components'
10+
import { PROP_TYPE_BOOLEAN } from '../../../constants/props'
1011
import { getBCR, reflow, removeStyle, requestAF, setStyle } from '../../../utils/dom'
12+
import { makeProp } from '../../../utils/props'
1113

1214
// --- Helper methods ---
1315

@@ -62,17 +64,18 @@ const TRANSITION_HANDLERS = {
6264

6365
// --- Main component ---
6466

67+
export const props = {
68+
// // If `true` (and `visible` is `true` on mount), animate initially visible
69+
appear: makeProp(PROP_TYPE_BOOLEAN, false)
70+
}
71+
72+
// --- Main component ---
73+
6574
// @vue/component
6675
export const BVCollapse = /*#__PURE__*/ Vue.extend({
6776
name: NAME_COLLAPSE_HELPER,
6877
functional: true,
69-
props: {
70-
appear: {
71-
// If `true` (and `visible` is `true` on mount), animate initially visible
72-
type: Boolean,
73-
default: false
74-
}
75-
},
78+
props,
7679
render(h, { props, data, children }) {
7780
return h(
7881
'transition',

src/components/dropdown/dropdown-item.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ import { EVENT_NAME_CLICK } from '../../constants/events'
44
import { PROP_TYPE_ARRAY_OBJECT_STRING, PROP_TYPE_STRING } from '../../constants/props'
55
import { requestAF } from '../../utils/dom'
66
import { omit, sortKeys } from '../../utils/object'
7-
import { makeProp, makePropsConfigurable } from '../../utils/props'
7+
import { makeProp, makePropsConfigurable, pluckProps } from '../../utils/props'
88
import { attrsMixin } from '../../mixins/attrs'
99
import { normalizeSlotMixin } from '../../mixins/normalize-slot'
1010
import { BLink, props as BLinkProps } from '../link/link'
1111

1212
// --- Props ---
1313

14+
const linkProps = omit(BLinkProps, ['event', 'routerTag'])
15+
1416
export const props = makePropsConfigurable(
1517
sortKeys({
16-
...omit(BLinkProps, ['event', 'routerTag']),
18+
...linkProps,
1719
linkClass: makeProp(PROP_TYPE_ARRAY_OBJECT_STRING),
1820
variant: makeProp(PROP_TYPE_STRING)
1921
}),
@@ -69,7 +71,7 @@ export const BDropdownItem = /*#__PURE__*/ Vue.extend({
6971
{
7072
staticClass: 'dropdown-item',
7173
class: [linkClass, { [`text-${variant}`]: variant && !(active || disabled) }],
72-
props: this.$props,
74+
props: pluckProps(linkProps, this.$props),
7375
attrs: this.computedAttrs,
7476
on: { click: onClick },
7577
ref: 'item'

src/components/nav/nav-form.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ import { Vue, mergeData } from '../../vue'
22
import { NAME_NAV_FORM } from '../../constants/components'
33
import { PROP_TYPE_ARRAY_OBJECT_STRING } from '../../constants/props'
44
import { omit, sortKeys } from '../../utils/object'
5-
import { makeProp, makePropsConfigurable } from '../../utils/props'
5+
import { makeProp, makePropsConfigurable, pluckProps } from '../../utils/props'
66
import { BForm, props as BFormProps } from '../form/form'
77

88
// --- Props ---
99

10+
const formProps = omit(BFormProps, ['inline'])
11+
1012
export const props = makePropsConfigurable(
1113
sortKeys({
12-
...omit(BFormProps, ['inline']),
14+
...formProps,
1315
formClass: makeProp(PROP_TYPE_ARRAY_OBJECT_STRING)
1416
}),
1517
NAME_NAV_FORM
@@ -28,7 +30,7 @@ export const BNavForm = /*#__PURE__*/ Vue.extend({
2830
{
2931
class: props.formClass,
3032
props: {
31-
...props,
33+
...pluckProps(formProps, props),
3234
inline: true
3335
},
3436
attrs: data.attrs,

src/components/nav/nav-item.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ import { Vue, mergeData } from '../../vue'
22
import { NAME_NAV_ITEM } from '../../constants/components'
33
import { PROP_TYPE_ARRAY_OBJECT_STRING, PROP_TYPE_OBJECT } from '../../constants/props'
44
import { omit, sortKeys } from '../../utils/object'
5-
import { makeProp, makePropsConfigurable } from '../../utils/props'
5+
import { makeProp, makePropsConfigurable, pluckProps } from '../../utils/props'
66
import { BLink, props as BLinkProps } from '../link/link'
77

88
// --- Props ---
99

10+
const linkProps = omit(BLinkProps, ['event', 'routerTag'])
11+
1012
export const props = makePropsConfigurable(
1113
sortKeys({
12-
...omit(BLinkProps, ['event', 'routerTag']),
14+
...linkProps,
1315
linkAttrs: makeProp(PROP_TYPE_OBJECT, {}),
1416
linkClasses: makeProp(PROP_TYPE_ARRAY_OBJECT_STRING)
1517
}),
@@ -36,7 +38,7 @@ export const BNavItem = /*#__PURE__*/ Vue.extend({
3638
staticClass: 'nav-link',
3739
class: props.linkClasses,
3840
attrs: props.linkAttrs,
39-
props,
41+
props: pluckProps(linkProps, props),
4042
on: listeners
4143
},
4244
children

src/icons/helpers/make-icon.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { Vue, mergeData } from '../../vue'
2-
import { PROP_TYPE_BOOLEAN } from '../../constants/props'
32
import { omit } from '../../utils/object'
4-
import { makeProp } from '../../utils/props'
53
import { kebabCase, pascalCase, trim } from '../../utils/string'
64
import { BVIconBase, props as BVIconBaseProps } from './icon-base'
75

@@ -24,10 +22,7 @@ export const makeIcon = (name, content) => {
2422
return /*#__PURE__*/ Vue.extend({
2523
name: iconName,
2624
functional: true,
27-
props: {
28-
...omit(BVIconBaseProps, ['content', 'stacked']),
29-
stacked: makeProp(PROP_TYPE_BOOLEAN, false)
30-
},
25+
props: omit(BVIconBaseProps, ['content']),
3126
render(h, { data, props }) {
3227
return h(
3328
BVIconBase,

src/icons/icon.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Vue, mergeData } from '../vue'
22
import { NAME_ICON } from '../constants/components'
3-
import { PROP_TYPE_BOOLEAN, PROP_TYPE_STRING } from '../constants/props'
3+
import { PROP_TYPE_STRING } from '../constants/props'
44
import { RX_ICON_PREFIX } from '../constants/regex'
55
import { omit, sortKeys } from '../utils/object'
6-
import { makeProp, makePropsConfigurable } from '../utils/props'
6+
import { makeProp, makePropsConfigurable, pluckProps } from '../utils/props'
77
import { pascalCase, trim } from '../utils/string'
88
import { BIconBlank } from './icons'
99
import { props as BVIconBaseProps } from './helpers/icon-base'
@@ -21,11 +21,12 @@ const findIconComponent = (ctx, iconName) => {
2121

2222
// --- Props ---
2323

24+
const iconProps = omit(BVIconBaseProps, ['content'])
25+
2426
export const props = makePropsConfigurable(
2527
sortKeys({
26-
...omit(BVIconBaseProps, ['content', 'stacked']),
27-
icon: makeProp(PROP_TYPE_STRING),
28-
stacked: makeProp(PROP_TYPE_BOOLEAN, false)
28+
...iconProps,
29+
icon: makeProp(PROP_TYPE_STRING)
2930
}),
3031
NAME_ICON
3132
)
@@ -47,7 +48,7 @@ export const BIcon = /*#__PURE__*/ Vue.extend({
4748
// If not registered, we render a blank icon
4849
return h(
4950
icon ? findIconComponent(parent, `BIcon${icon}`) || BIconBlank : BIconBlank,
50-
mergeData(data, { props: { ...props, icon: null } })
51+
mergeData(data, { props: pluckProps(iconProps, props) })
5152
)
5253
}
5354
})

src/icons/iconstack.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ export const BIconstack = /*#__PURE__*/ Vue.extend({
2323
BVIconBase,
2424
mergeData(data, {
2525
staticClass: 'b-iconstack',
26-
props: {
27-
...props,
28-
stacked: false
29-
}
26+
props
3027
}),
3128
children
3229
)

0 commit comments

Comments
 (0)