8000 fix: properly handle HTML props render order (closes #5363) by jacobmllr95 · Pull Request #5365 · bootstrap-vue/bootstrap-vue · GitHub
[go: up one dir, main page]

Skip to content

fix: properly handle HTML props render order (closes #5363) #5365

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 42 commits into from
May 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
a26e0bc
fix(jumbatron): fix html props and ensure correct render order
jacobmllr95 May 13, 2020
8d0d28e
Update html.js
jacobmllr95 May 13, 2020
be57e4c
Update visible.js
jacobmllr95 May 13, 2020
174e130
Update dropdown.js
jacobmllr95 May 13, 2020
cbb29fa
Update modal.js
jacobmllr95 May 13, 2020
ae41c82
Update modal.spec.js
jacobmllr95 May 13, 2020
e58989b
Update carousel-slide.js
jacobmllr95 May 13, 2020
0baa352
Update card.js
jacobmllr95 May 13, 2020
da963db
Update carousel-slide.js
jacobmllr95 May 13, 2020
8000 c9782b4
Update jumbotron.js
jacobmllr95 May 13, 2020
91c8bb2
Update card-footer.js
jacobmllr95 May 14, 2020
63be09b
Update card-header.js
jacobmllr95 May 14, 2020
63126a0
Update input-group.js
jacobmllr95 May 14, 2020
1a7fabc
Update progress-bar.js
jacobmllr95 May 14, 2020
a54fda9
Update mixin-caption.js
jacobmllr95 May 14, 2020
decea56
Update mixin-empty.js
jacobmllr95 May 14, 2020
4829f82
Update mixin-thead.js
jacobmllr95 May 14, 2020
e84fef6
Unify prop utils
jacobmllr95 May 14, 2020
fbaf5d0
Update props.js
jacobmllr95 May 14, 2020
b9568a5
Merge remote-tracking branch 'origin/dev' into fix-jumbatron-html-props
jacobmllr95 May 14, 2020
217cda1
Merge remote-tracking branch 'origin/dev' into fix-jumbatron-html-props
jacobmllr95 May 14, 2020
b17d75b
Update dropdown.spec.js
tmorehouse May 14, 2020
8650ee0
Update dropdown.spec.js
tmorehouse May 14, 2020
46b11b4
Update dropdown.spec.js
tmorehouse May 14, 2020
f836c37
Update dropdown.spec.js
tmorehouse May 14, 2020
ae61077
Update modal.spec.js
tmorehouse May 14, 2020
eadcab5
Update modal.spec.js
jacobmllr95 May 14, 2020
86e0d30
Merge branch 'dev' into fix-jumbatron-html-props
jacobmllr95 May 14, 2020
d841532
Update breadcrumb-link.js
jacobmllr95 May 14, 2020
4420db5
Update card-footer.js
jacobmllr95 May 14, 2020
d95f9e7
Update card-header.js
jacobmllr95 May 14, 2020
27fbd68
Update form-select-option-group.js
jacobmllr95 May 14, 2020
acfc6d5
Update form-datalist.js
jacobmllr95 May 14, 2020
6a55bfe
Merge branch 'fix-jumbatron-html-props' of https://github.com/bootstr…
jacobmllr95 May 14, 2020
1695c66
Update test.yml
jacobmllr95 May 14, 2020
eae4b8c
Merge remote-tracking branch 'origin/dev' into fix-jumbatron-html-props
jacobmllr95 May 14, 2020
a7bdc49
Merge remote-tracking branch 'origin/dev' into fix-jumbatron-html-props
jacobmllr95 May 14, 2020
bdae479
Update toast.js
jacobmllr95 May 14, 2020
058a3dd
Update form-select.js
jacobmllr95 May 15, 2020
9a0998e
Update form-radio-check-group.js
jacobmllr95 May 15, 2020
abedd27
Update mixin-thead.js
jacobmllr95 May 15, 2020
09d5f75
Merge branch 'dev' into fix-jumbatron-html-props
jacobmllr95 May 15, 2020
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
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,3 @@ jobs:
run: yarn run bundlewatch
env:
BUNDLEWATCH_GITHUB_TOKEN: "${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}"
CI_BRANCH_BASE: "${{ github.base_ref }}"
2 changes: 1 addition & 1 deletion src/components/avatar/avatar.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Vue from '../../utils/vue' 6D4E
import pluckProps from '../../utils/pluck-props'
import { getComponentConfig } from '../../utils/config'
import { isNumber, isString, isUndefinedOrNull } from '../../utils/inspect'
import { toFloat } from '../../utils/number'
import { omit } from '../../utils/object'
import { pluckProps } from '../../utils/props'
import { isLink } from '../../utils/router'
import { BButton } from '../button/button'
import { BLink, props as BLinkProps } from '../link/link'
Expand Down
4 changes: 2 additions & 2 deletions src/components/badge/badge.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Vue from '../../utils/vue'
import pluckProps from '../../utils/pluck-props'
import { mergeData } from 'vue-functional-data-merge'
import Vue from '../../utils/vue'
import { getComponentConfig } from '../../utils/config'
import { omit } from '../../utils/object'
import { pluckProps } from '../../utils/props'
import { isLink } from '../../utils/router'
import { BLink, props as BLinkProps } from '../link/link'

Expand Down
14 changes: 9 additions & 5 deletions src/components/breadcrumb/breadcrumb-link.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { mergeData } from 'vue-functional-data-merge'
import Vue from '../../utils/vue'
import pluckProps from '../../utils/pluck-props'
import { htmlOrText } from '../../utils/html'
import { omit } from '../../utils/object'
import { pluckProps } from '../../utils/props'
import { BLink, props as BLinkProps } from '../link/link'

// --- Props ---

export const props = {
text: {
type: String,
Expand All @@ -21,17 +23,19 @@ export const props = {
...omit(BLinkProps, ['event', 'routerTag'])
}

// --- Main component ---
// @vue/component
export const BBreadcrumbLink = /*#__PURE__*/ Vue.extend({
name: 'BBreadcrumbLink',
functional: true,
props,
render(h, { props: suppliedProps, data, children }) {
const tag = suppliedProps.active ? 'span' : BLink
const { active } = suppliedProps
const tag = active ? 'span' : BLink

const componentData = { props: pluckProps(props, suppliedProps) }
if (suppliedProps.active) {
componentData.attrs = { 'aria-current': suppliedProps.ariaCurrent }
const componentData = {
attrs: { 'aria-current': active ? suppliedProps.ariaCurrent : null },
props: pluckProps(props, suppliedProps)
}

if (!children) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/button/button.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import Vue from '../../utils/vue'
import { mergeData } from 'vue-functional-data-merge'
import Vue from '../../utils/vue'
import KeyCodes from '../../utils/key-codes'
import pluckProps from '../../utils/pluck-props'
import { concat } from '../../utils/array'
import { getComponentConfig } from '../../utils/config'
import { addClass, isTag, removeClass } from '../../utils/dom'
import { isBoolean, isEvent, isFunction } from '../../utils/inspect'
import { omit } from '../../utils/object'
import { pluckProps } from '../../utils/props'
import { isLink as isLinkStrict } from '../../utils/router'
import { BLink, props as BLinkProps } from '../link/link'

Expand Down
6 changes: 2 additions & 4 deletions src/components/card/card-body.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import Vue from '../../utils/vue'
import { mergeData } from 'vue-functional-data-merge'
import prefixPropName from '../../utils/prefix-prop-name'
import copyProps from '../../utils/copy-props'
import pluckProps from '../../utils/pluck-props'
import Vue from '../../utils/vue'
import { copyProps, pluckProps, prefixPropName } from '../../utils/props'
import cardMixin from '../../mixins/card'
import { BCardTitle, props as titleProps } from './card-title'
import { BCardSubTitle, props as subTitleProps } from './card-sub-title'
Expand Down
22 changes: 13 additions & 9 deletions src/components/card/card-footer.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Vue from '../../utils/vue'
import { mergeData } from 'vue-functional-data-merge'

import prefixPropName from '../../utils/prefix-prop-name'
import copyProps from '../../utils/copy-props'
import Vue from '../../utils/vue'
import { htmlOrText } from '../../utils/html'
import { copyProps, prefixPropName } from '../../utils/props'
import cardMixin from '../../mixins/card'

// --- Props ---

export const props = {
...copyProps(cardMixin.props, prefixPropName.bind(null, 'footer')),
footer: {
Expand All @@ -22,26 +22,30 @@ export const props = {
}
}

// --- Main component ---
// @vue/component
export const BCardFooter = /*#__PURE__*/ Vue.extend({
name: 'BCardFooter',
functional: true,
props,
render(h, { props, data, children }) {
const { footerBgVariant, footerBorderVariant, footerTextVariant } = props

return h(
props.footerTag,
mergeData(data, {
staticClass: 'card-footer',
class: [
props.footerClass,
{
[`bg-${props.footerBgVariant}`]: props.footerBgVariant,
[`border-${props.footerBorderVariant}`]: props.footerBorderVariant,
[`text-${props.footerTextVariant}`]: props.footerTextVariant
[`bg-${footerBgVariant}`]: footerBgVariant,
[`border-${footerBorderVariant}`]: footerBorderVariant,
[`text-${footerTextVariant}`]: footerTextVariant
}
]
],
domProps: children ? {} : htmlOrText(props.footerHtml, props.footer)
}),
children || [h('div', { domProps: htmlOrText(props.footerHtml, props.footer) })]
children
)
}
})
21 changes: 13 additions & 8 deletions src/components/card/card-header.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import Vue from '../../utils/vue'
import { mergeData } from 'vue-functional-data-merge'
import prefixPropName from '../../utils/prefix-prop-name'
import copyProps from '../../utils/copy-props'
import Vue from '../../utils/vue'
import { htmlOrText } from '../../utils/html'
import { copyProps, prefixPropName } from '../../utils/props'
import cardMixin from '../../mixins/card'

// --- Props ---

export const props = {
...copyProps(cardMixin.props, prefixPropName.bind(null, 'header')),
header: {
Expand All @@ -21,26 +22,30 @@ export const props = {
}
}

// --- Main component ---
// @vue/component
export const BCardHeader = /*#__PURE__*/ Vue.extend({
name: 'BCardHeader',
functional: true,
props,
render(h, { props, data, children }) {
const { headerBgVariant, headerBorderVariant, headerTextVariant } = props

return h(
props.headerTag,
mergeData(data, {
staticClass: 'card-header',
class: [
props.headerClass,
{
[`bg-${props.headerBgVariant}`]: props.headerBgVariant,
[`border-${props.headerBorderVariant}`]: props.headerBorderVariant,
[`text-${props.headerTextVariant}`]: props.headerTextVariant
[`bg-${headerBgVariant}`]: headerBgVariant,
[`border-${headerBorderVariant}`]: headerBorderVariant,
[`text-${headerTextVariant}`]: headerTextVariant
}
]
],
domProps: children ? {} : htmlOrText(props.headerHtml, props.header)
}),
children || [h('div', { domProps: htmlOrText(props.headerHtml, props.header) })]
children
)
}
})
90 changes: 53 additions & 37 deletions src/components/card/card.js
C84D
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import Vue from '../../utils/vue'
import { mergeData } from 'vue-functional-data-merge'
import prefixPropName from '../../utils/prefix-prop-name'
import unPrefixPropName from '../../utils/unprefix-prop-name'
import copyProps from '../../utils/copy-props'
import pluckProps from '../../utils/pluck-props'
import Vue from '../../utils/vue'
import { htmlOrText } from '../../utils/html'
import { hasNormalizedSlot, normalizeSlot } from '../../utils/normalize-slot'
import { copyProps, pluckProps, prefixPropName, unprefixPropName } from '../../utils/props'
import cardMixin from '../../mixins/card'
import { BCardBody, props as bodyProps } from './card-body'
import { BCardHeader, props as headerProps } from './card-header'
Expand Down Expand Up @@ -36,49 +34,68 @@ export const BCard = /*#__PURE__*/ Vue.extend({
functional: true,
props,
render(h, { props, data, slots, scopedSlots }) {
const $slots = slots()
// Vue < 2.6.x may return undefined for scopedSlots
const {
imgLeft,
imgRight,
imgStart,
imgEnd,
header,
headerHtml,
footer,
footerHtml,
align,
textVariant,
bgVariant,
borderVariant
} = props
const $scopedSlots = scopedSlots || {}
const $slots = slots()
const slotScope = {}

// Create placeholder elements for each section
let imgFirst = h()
let header = h()
let content = h()
let footer = h()
let imgLast = h()

let $imgFirst = h()
let $imgLast = h()
if (props.imgSrc) {
const img = h(BCardImg, {
props: pluckProps(cardImgProps, props, unPrefixPropName.bind(null, 'img'))
const $img = h(BCardImg, {
props: pluckProps(cardImgProps, props, unprefixPropName.bind(null, 'img'))
})

if (props.imgBottom) {
imgLast = img
$imgLast = $img
} else {
imgFirst = img
$imgFirst = $img
}
}

if (props.header || props.headerHtml || hasNormalizedSlot('header', $scopedSlots, $slots)) {
header = h(
let $header = h()
const hasHeaderSlot = hasNormalizedSlot('header', $scopedSlots, $slots)
if (hasHeaderSlot || header || headerHtml) {
$header = h(
BCardHeader,
{ props: pluckProps(headerProps, props) },
normalizeSlot('header', {}, $scopedSlots, $slots)
{
props: pluckProps(headerProps, props),
domProps: hasHeaderSlot ? {} : htmlOrText(headerHtml, header)
},
normalizeSlot('header', slotScope, $scopedSlots, $slots)
)
}

content = normalizeSlot('default', {}, $scopedSlots, $slots) || []
let $content = normalizeSlot('default', slotScope, $scopedSlots, $slots)

// Wrap content in <card-body> when `noBody` prop set
if (!props.noBody) {
// Wrap content in card-body
content = [h(BCardBody, { props: pluckProps(bodyProps, props) }, [...content])]
$content = h(BCardBody, { props: pluckProps(bodyProps, props) }, $content)
}

if (props.footer || props.footerHtml || hasNormalizedSlot('footer', $scopedSlots, $slots)) {
footer = h(
let $footer = h()
const hasFooterSlot = hasNormalizedSlot('footer', $scopedSlots, $slots)
if (hasFooterSlot || footer || footerHtml) {
$footer = h(
BCardFooter,
{
props: pluckProps(footerProps, props)
props: pluckProps(footerProps, props),
domProps: hasHeaderSlot ? {} : htmlOrText(footerHtml, footer)
},
normalizeSlot('footer', {}, $scopedSlots, $slots)
normalizeSlot('footer', slotScope, $scopedSlots, $slots)
)
}

Expand All @@ -87,16 +104,15 @@ export const BCard = /*#__PURE__*/ Vue.extend({
mergeData(data, {
staticClass: 'card',
class: {
'flex-row': props.imgLeft || props.imgStart,
'flex-row-reverse':
(props.imgRight || props.imgEnd) && !(props.imgLeft || props.imgStart),
[`text-${props.align}`]: props.align,
[`bg-${props.bgVariant}`]: props.bgVariant,
[`border-${props.borderVariant}`]: props.borderVariant,
[`text-${props.textVariant}`]: props.textVariant
'flex-row': imgLeft || imgStart,
'flex-row-reverse': (imgRight || imgEnd) && !(imgLeft || imgStart),
[`text-${align}`]: align,
[`bg-${bgVariant}`]: bgVariant,
[`border-${borderVariant}`]: borderVariant,
[`text-${textVariant}`]: textVariant
}
}),
[imgFirst, header, ...content, footer, imgLast]
[$imgFirst, $header, $content, $footer, $imgLast]
)
}
})
Loading
0