Skip to content

fix: clean up props inheritance #6265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/components/collapse/helpers/bv-collapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
// in-place after the transition completes
import { Vue, mergeData } from '../../../vue'
import { NAME_COLLAPSE_HELPER } from '../../../constants/components'
import { PROP_TYPE_BOOLEAN } from '../../../constants/props'
import { getBCR, reflow, removeStyle, requestAF, setStyle } from '../../../utils/dom'
import { makeProp } from '../../../utils/props'

// --- Helper methods ---

Expand Down Expand Up @@ -62,17 +64,18 @@ const TRANSITION_HANDLERS = {

// --- Main component ---

export const props = {
// // If `true` (and `visible` is `true` on mount), animate initially visible
appear: makeProp(PROP_TYPE_BOOLEAN, false)
}

// --- Main component ---

// @vue/component
export const BVCollapse = /*#__PURE__*/ Vue.extend({
name: NAME_COLLAPSE_HELPER,
functional: true,
props: {
appear: {
// If `true` (and `visible` is `true` on mount), animate initially visible
type: Boolean,
default: false
}
},
props,
render(h, { props, data, children }) {
return h(
'transition',
Expand Down
8 changes: 5 additions & 3 deletions src/components/dropdown/dropdown-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ import { EVENT_NAME_CLICK } from '../../constants/events'
import { PROP_TYPE_ARRAY_OBJECT_STRING, PROP_TYPE_STRING } from '../../constants/props'
import { requestAF } from '../../utils/dom'
import { omit, sortKeys } from '../../utils/object'
import { makeProp, makePropsConfigurable } from '../../utils/props'
import { makeProp, makePropsConfigurable, pluckProps } from '../../utils/props'
import { attrsMixin } from '../../mixins/attrs'
import { normalizeSlotMixin } from '../../mixins/normalize-slot'
import { BLink, props as BLinkProps } from '../link/link'

// --- Props ---

const linkProps = omit(BLinkProps, ['event', 'routerTag'])

export const props = makePropsConfigurable(
sortKeys({
...omit(BLinkProps, ['event', 'routerTag']),
...linkProps,
linkClass: makeProp(PROP_TYPE_ARRAY_OBJECT_STRING),
variant: makeProp(PROP_TYPE_STRING)
}),
Expand Down Expand Up @@ -69,7 +71,7 @@ export const BDropdownItem = /*#__PURE__*/ Vue.extend({
{
staticClass: 'dropdown-item',
class: [linkClass, { [`text-${variant}`]: variant && !(active || disabled) }],
props: this.$props,
props: pluckProps(linkProps, this.$props),
attrs: this.computedAttrs,
on: { click: onClick },
ref: 'item'
Expand Down
8 changes: 5 additions & 3 deletions src/components/nav/nav-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ import { Vue, mergeData } from '../../vue'
import { NAME_NAV_FORM } from '../../constants/components'
import { PROP_TYPE_ARRAY_OBJECT_STRING } from '../../constants/props'
import { omit, sortKeys } from '../../utils/object'
import { makeProp, makePropsConfigurable } from '../../utils/props'
import { makeProp, makePropsConfigurable, pluckProps } from '../../utils/props'
import { BForm, props as BFormProps } from '../form/form'

// --- Props ---

const formProps = omit(BFormProps, ['inline'])

export const props = makePropsConfigurable(
sortKeys({
...omit(BFormProps, ['inline']),
...formProps,
formClass: makeProp(PROP_TYPE_ARRAY_OBJECT_STRING)
}),
NAME_NAV_FORM
Expand All @@ -28,7 +30,7 @@ export const BNavForm = /*#__PURE__*/ Vue.extend({
{
class: props.formClass,
props: {
...props,
...pluckProps(formProps, props),
inline: true
},
attrs: data.attrs,
Expand Down
8 changes: 5 additions & 3 deletions src/components/nav/nav-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ import { Vue, mergeData } from '../../vue'
import { NAME_NAV_ITEM } from '../../constants/components'
import { PROP_TYPE_ARRAY_OBJECT_STRING, PROP_TYPE_OBJECT } from '../../constants/props'
import { omit, sortKeys } from '../../utils/object'
import { makeProp, makePropsConfigurable } from '../../utils/props'
import { makeProp, makePropsConfigurable, pluckProps } from '../../utils/props'
import { BLink, props as BLinkProps } from '../link/link'

// --- Props ---

const linkProps = omit(BLinkProps, ['event', 'routerTag'])

export const props = makePropsConfigurable(
sortKeys({
...omit(BLinkProps, ['event', 'routerTag']),
...linkProps,
linkAttrs: makeProp(PROP_TYPE_OBJECT, {}),
linkClasses: makeProp(PROP_TYPE_ARRAY_OBJECT_STRING)
}),
Expand All @@ -36,7 +38,7 @@ export const BNavItem = /*#__PURE__*/ Vue.extend({
staticClass: 'nav-link',
class: props.linkClasses,
attrs: props.linkAttrs,
props,
props: pluckProps(linkProps, props),
on: listeners
},
children
Expand Down
7 changes: 1 addition & 6 deletions src/icons/helpers/make-icon.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Vue, mergeData } from '../../vue'
import { PROP_TYPE_BOOLEAN } from '../../constants/props'
import { omit } from '../../utils/object'
import { makeProp } from '../../utils/props'
import { kebabCase, pascalCase, trim } from '../../utils/string'
import { BVIconBase, props as BVIconBaseProps } from './icon-base'

Expand All @@ -24,10 +22,7 @@ export const makeIcon = (name, content) => {
return /*#__PURE__*/ Vue.extend({
name: iconName,
functional: true,
props: {
...omit(BVIconBaseProps, ['content', 'stacked']),
stacked: makeProp(PROP_TYPE_BOOLEAN, false)
},
props: omit(BVIconBaseProps, ['content']),
render(h, { data, props }) {
return h(
BVIconBase,
Expand Down
13 changes: 7 additions & 6 deletions src/icons/icon.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Vue, mergeData } from '../vue'
import { NAME_ICON } from '../constants/components'
import { PROP_TYPE_BOOLEAN, PROP_TYPE_STRING } from '../constants/props'
import { PROP_TYPE_STRING } from '../constants/props'
import { RX_ICON_PREFIX } from '../constants/regex'
import { omit, sortKeys } from '../utils/object'
import { makeProp, makePropsConfigurable } from '../utils/props'
import { makeProp, makePropsConfigurable, pluckProps } from '../utils/props'
import { pascalCase, trim } from '../utils/string'
import { BIconBlank } from './icons'
import { props as BVIconBaseProps } from './helpers/icon-base'
Expand All @@ -21,11 +21,12 @@ const findIconComponent = (ctx, iconName) => {

// --- Props ---

const iconProps = omit(BVIconBaseProps, ['content'])

export const props = makePropsConfigurable(
sortKeys({
...omit(BVIconBaseProps, ['content', 'stacked']),
icon: makeProp(PROP_TYPE_STRING),
stacked: makeProp(PROP_TYPE_BOOLEAN, false)
...iconProps,
icon: makeProp(PROP_TYPE_STRING)
}),
NAME_ICON
)
Expand All @@ -47,7 +48,7 @@ export const BIcon = /*#__PURE__*/ Vue.extend({
// If not registered, we render a blank icon
return h(
icon ? findIconComponent(parent, `BIcon${icon}`) || BIconBlank : BIconBlank,
mergeData(data, { props: { ...props, icon: null } })
mergeData(data, { props: pluckProps(iconProps, props) })
)
}
})
5 changes: 1 addition & 4 deletions src/icons/iconstack.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ export const BIconstack = /*#__PURE__*/ Vue.extend({
BVIconBase,
mergeData(data, {
staticClass: 'b-iconstack',
props: {
...props,
stacked: false
}
props
}),
children
)
Expand Down