Skip to content
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
be5a41e
fix(perf): avoid useless re-render on parent update
jacobmllr95 Feb 25, 2020
c1ddd4c
Merge branch 'dev' into fix-perf-avoid-re-renders
tmorehouse Feb 25, 2020
76fd7db
Update bind-attrs.js
jacobmllr95 Feb 25, 2020
b885e02
Merge branch 'dev' into fix-perf-avoid-re-renders
tmorehouse Feb 26, 2020
8623bb1
Merge branch 'dev' into fix-perf-avoid-re-renders
jacobmllr95 Feb 27, 2020
ff85621
Make sure `bindAttrsMixin` is always the first mixin
jacobmllr95 Feb 27, 2020
cfe7f69
Update form-input.js
jacobmllr95 Feb 27, 2020
deb2333
Merge branch 'dev' into fix-perf-avoid-re-renders
tmorehouse Feb 27, 2020
9c43146
Merge branch 'dev' into fix-perf-avoid-re-renders
tmorehouse Feb 28, 2020
ab2164f
Merge branch 'dev' into fix-perf-avoid-re-renders
tmorehouse Mar 2, 2020
1b7f555
Merge branch 'dev' into fix-perf-avoid-re-renders
tmorehouse Mar 5, 2020
666a233
Merge branch 'dev' into fix-perf-avoid-re-renders
tmorehouse Mar 10, 2020
e81f405
Merge branch 'dev' into fix-perf-avoid-re-renders
tmorehouse Mar 10, 2020
b87a25b
Merge branch 'dev' into fix-perf-avoid-re-renders
tmorehouse Mar 23, 2020
81d228c
Merge branch 'dev' into fix-perf-avoid-re-renders
jacobmllr95 Apr 1, 2020
d92f872
Merge branch 'dev' into fix-perf-avoid-re-renders
tmorehouse Apr 7, 2020
d678bc0
Update link.js
tmorehouse Apr 7, 2020
602d4ca
Merge branch 'dev' into fix-perf-avoid-re-renders
tmorehouse Apr 8, 2020
cfd941b
Merge branch 'dev' into fix-perf-avoid-re-renders
tmorehouse Apr 15, 2020
11d3fb6
Merge branch 'dev' into fix-perf-avoid-re-renders
tmorehouse Apr 15, 2020
e859a41
Merge remote-tracking branch 'origin/dev' into fix-perf-avoid-re-renders
jacobmllr95 May 8, 2020
e4df097
Merge branch 'dev' into fix-perf-avoid-re-renders
jacobmllr95 May 8, 2020
71ba13e
Separate `$attrs` and `$listeners` cache mixins
jacobmllr95 May 8, 2020
a762b78
Further performance optimizations
jacobmllr95 May 8, 2020
db125d4
Update form-input.js
jacobmllr95 May 8, 2020
d0e5ec1
Update form-textarea.js
jacobmllr95 May 8, 2020
daa8877
Create attrs.spec.js
tmorehouse May 8, 2020
12a8f61
Update attrs.spec.js
tmorehouse May 8, 2020
ae9d204
Update attrs.spec.js
tmorehouse May 9, 2020
da1a39b
Merge branch 'dev' into fix-perf-avoid-re-renders
tmorehouse May 9, 2020
f8a1b4d
Update attrs.spec.js
tmorehouse May 9, 2020
e15a45a
Merge branch 'dev' into fix-perf-avoid-re-renders
jacobmllr95 May 9, 2020
3f07b97
Update attrs.spec.js
jacobmllr95 May 10, 2020
745f75c
Update attrs.spec.js
jacobmllr95 May 10, 2020
303ad84
Update attrs.spec.js
jacobmllr95 May 10, 2020
5ce982f
Update attrs.spec.js
jacobmllr95 May 10, 2020
cb098c6
Update attrs.spec.js
jacobmllr95 May 10, 2020
91ad2e0
Create listeners.spec.js
jacobmllr95 May 10, 2020
a33febf
Update listeners.spec.js
jacobmllr95 May 10, 2020
e57c038
Merge branch 'dev' into fix-perf-avoid-re-renders
jacobmllr95 May 10, 2020
69e760e
Merge branch 'dev' into fix-perf-avoid-re-renders
jacobmllr95 May 10, 2020
c282cdd
Merge branch 'dev' into fix-perf-avoid-re-renders
tmorehouse May 11, 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
79 changes: 53 additions & 26 deletions src/components/calendar/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { isLocaleRTL } from '../../utils/locale'
import { mathMax } from '../../utils/math'
import { toInteger } from '../../utils/number'
import { toString } from '../../utils/string'
import attrsMixin from '../../mixins/attrs'
import idMixin from '../../mixins/id'
import normalizeSlotMixin from '../../mixins/normalize-slot'
import {
Expand Down Expand Up @@ -56,7 +57,8 @@ export const STR_NARROW = 'narrow'
// @vue/component
export const BCalendar = Vue.extend({
name: NAME,
mixins: [idMixin, normalizeSlotMixin],
// Mixin order is important!
mixins: [attrsMixin, idMixin, normalizeSlotMixin],
model: {
// Even though this is the default that Vue assumes, we need
// to add it for the docs to reflect that this is the model
Expand Down Expand Up @@ -271,6 +273,27 @@ export const BCalendar = Vue.extend({
}
},
computed: {
valueId() {
return this.safeId()
},
widgetId() {
return this.safeId('_calendar-wrapper_')
},
navId() {
return this.safeId('_calendar-nav_')
},
gridId() {
return this.safeId('_calendar-grid_')
},
gridCaptionId() {
return this.safeId('_calendar-grid-caption_')
},
gridHelpId() {
return this.safeId('_calendar-grid-help_')
},
activeId() {
return this.activeYMD ? this.safeId(`_cell-${this.activeYMD}_`) : null
},
// TODO: Use computed props to convert `YYYY-MM-DD` to `Date` object
selectedDate() {
// Selected as a `Date` object
Expand Down Expand Up @@ -771,24 +794,28 @@ export const BCalendar = Vue.extend({
}
},
render(h) {
// If hidden prop is set, render just a placeholder node
// If `hidden` prop is set, render just a placeholder node
if (this.hidden) {
return h()
}

const { isLive, isRTL, activeYMD, selectedYMD, safeId } = this
const {
valueId,
widgetId,
navId,
gridId,
gridCaptionId,
gridHelpId,
activeId,
isLive,
isRTL,
activeYMD,
selectedYMD,
safeId
} = this
const hideDecadeNav = !this.showDecadeNav
const todayYMD = formatYMD(this.getToday())
const highlightToday = !this.noHighlightToday
// Pre-compute some IDs
// This should be computed props
const idValue = safeId()
const idWidget = safeId('_calendar-wrapper_')
const idNav = safeId('_calendar-nav_')
const idGrid = safeId('_calendar-grid_')
const idGridCaption = safeId('_calendar-grid-caption_')
const idGridHelp = safeId('_calendar-grid-help_')
const idActive = activeYMD ? safeId(`_cell-${activeYMD}_`) : null

// Header showing current selected date
let $header = h(
Expand All @@ -797,8 +824,8 @@ export const BCalendar = Vue.extend({
staticClass: 'form-control form-control-sm text-center',
class: { 'text-muted': this.disabled, readonly: this.readonly || this.disabled },
attrs: {
id: idValue,
for: idGrid,
id: valueId,
for: gridId,
role: 'status',
tabindex: this.disabled ? null : '-1',
// Mainly for testing purposes, as we do not know
Expand Down Expand Up @@ -885,11 +912,11 @@ export const BCalendar = Vue.extend({
{
staticClass: 'b-calendar-nav d-flex',
attrs: {
id: idNav,
id: navId,
role: 'group',
'aria-hidden': this.disabled ? 'true' : null,
'aria-label': this.labelNav || null,
'aria-controls': idGrid
'aria-controls': gridId
}
},
[
Expand Down Expand Up @@ -957,7 +984,7 @@ export const BCalendar = Vue.extend({
staticClass: 'b-calendar-grid-caption text-center font-weight-bold',
class: { 'text-muted': this.disabled },
attrs: {
id: idGridCaption,
id: gridCaptionId,
'aria-live': isLive ? 'polite' : null,
'aria-atomic': isLive ? 'true' : null
}
Expand Down Expand Up @@ -1077,7 +1104,7 @@ export const BCalendar = Vue.extend({
{
staticClass: 'b-calendar-grid-help border-top small text-muted text-center bg-light',
attrs: {
id: idGridHelp
id: gridHelpId
}
},
[h('div', { staticClass: 'small' }, this.labelHelp)]
Expand All @@ -1089,18 +1116,18 @@ export const BCalendar = Vue.extend({
ref: 'grid',
staticClass: 'b-calendar-grid form-control h-auto text-center',
attrs: {
id: idGrid,
id: gridId,
role: 'application',
tabindex: this.disabled ? null : '0',
'data-month': activeYMD.slice(0, -3), // `YYYY-MM`, mainly for testing
'aria-roledescription': this.labelCalendar || null,
'aria-labelledby': idGridCaption,
'aria-describedby': idGridHelp,
'aria-labelledby': gridCaptionId,
'aria-describedby': gridHelpId,
// `aria-readonly` is not considered valid on `role="application"`
// https://www.w3.org/TR/wai-aria-1.1/#aria-readonly
// 'aria-readonly': this.readonly && !this.disabled ? 'true' : null,
'aria-disabled': this.disabled ? 'true' : null,
'aria-activedescendant': idActive
'aria-activedescendant': activeId
},
on: {
keydown: this.onKeydownGrid,
Expand All @@ -1121,7 +1148,7 @@ export const BCalendar = Vue.extend({
staticClass: 'b-calendar-inner',
style: this.block ? {} : { width: this.width },
attrs: {
id: idWidget,
id: widgetId,
dir: isRTL ? 'rtl' : 'ltr',
lang: this.computedLocale || null,
role: 'group',
Expand All @@ -1133,9 +1160,9 @@ export const BCalendar = Vue.extend({
'aria-describedby': [
// Should the attr (if present) go last?
// Or should this attr be a prop?
this.$attrs['aria-describedby'],
idValue,
idGridHelp
this.bvAttrs['aria-describedby'],
valueId,
gridHelpId
]
.filter(identity)
.join(' ')
Expand Down
20 changes: 13 additions & 7 deletions src/components/dropdown/dropdown-item-button.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Vue from '../../utils/vue'
import attrsMixin from '../../mixins/attrs'
import normalizeSlotMixin from '../../mixins/normalize-slot'

export const props = {
Expand Down Expand Up @@ -27,14 +28,24 @@ export const props = {
// @vue/component
export const BDropdownItemButton = /*#__PURE__*/ Vue.extend({
name: 'BDropdownItemButton',
mixins: [normalizeSlotMixin],
mixins: [attrsMixin, normalizeSlotMixin],
inheritAttrs: false,
inject: {
bvDropdown: {
default: null
}
},
props,
computed: {
computedAttrs() {
return {
...this.bvAttrs,
role: 'menuitem',
type: 'button',
disabled: this.disabled
}
}
},
methods: {
closeDropdown() {
if (this.bvDropdown) {
Expand All @@ -59,12 +70,7 @@ export const BDropdownItemButton = /*#__PURE__*/ Vue.extend({
[`text-${this.variant}`]: this.variant && !(this.active || this.disabled)
}
],
attrs: {
...this.$attrs,
role: 'menuitem',
type: 'button',
disabled: this.disabled
},
attrs: this.computedAttrs,
on: { click: this.onClick },
ref: 'button'
},
Expand Down
13 changes: 11 additions & 2 deletions src/components/dropdown/dropdown-item.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Vue from '../../utils/vue'
import { requestAF } from '../../utils/dom'
import attrsMixin from '../../mixins/attrs'
import normalizeSlotMixin from '../../mixins/normalize-slot'
import { BLink, propsFactory as linkPropsFactory } from '../link/link'

Expand All @@ -8,7 +9,7 @@ export const props = linkPropsFactory()
// @vue/component
export const BDropdownItem = /*#__PURE__*/ Vue.extend({
name: 'BDropdownItem',
mixins: [normalizeSlotMixin],
mixins: [attrsMixin, normalizeSlotMixin],
inheritAttrs: false,
inject: {
bvDropdown: {
Expand All @@ -26,6 +27,14 @@ export const BDropdownItem = /*#__PURE__*/ Vue.extend({
default: null
}
},
computed: {
computedAttrs() {
return {
...this.bvAttrs,
role: 'menuitem'
}
}
},
methods: {
closeDropdown() {
// Close on next animation frame to allow <b-link> time to process
Expand Down Expand Up @@ -53,7 +62,7 @@ export const BDropdownItem = /*#__PURE__*/ Vue.extend({
[`text-${this.variant}`]: this.variant && !(this.active || this.disabled)
}
],
attrs: { ...this.$attrs, role: 'menuitem' },
attrs: this.computedAttrs,
on: { click: this.onClick },
ref: 'item'
},
Expand Down
34 changes: 19 additions & 15 deletions src/components/form-file/form-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { isFile, isFunction, isUndefinedOrNull } from '../../utils/inspect'
import { File } from '../../utils/safe-types'
import { toString } from '../../utils/string'
import { warn } from '../../utils/warn'
import attrsMixin from '../../mixins/attrs'
import formCustomMixin from '../../mixins/form-custom'
import formMixin from '../../mixins/form'
import formStateMixin from '../../mixins/form-state'
Expand All @@ -26,7 +27,7 @@ const isValidValue = value => isFile(value) || (isArray(value) && value.every(v
// @vue/component
export const BFormFile = /*#__PURE__*/ Vue.extend({
name: NAME,
mixins: [idMixin, formMixin, formStateMixin, formCustomMixin, normalizeSlotMixin],
mixins: [attrsMixin, idMixin, formMixin, formStateMixin, formCustomMixin, normalizeSlotMixin],
inheritAttrs: false,
model: {
prop: 'value',
Expand Down Expand Up @@ -127,6 +128,22 @@ export const BFormFile = /*#__PURE__*/ Vue.extend({
? toString(this.fileNameFormatter(files))
: files.map(file => file.name).join(', ')
}
},
computedAttrs() {
return {
...this.bvAttrs,
type: 'file',
id: this.safeId(),
name: this.name,
disabled: this.disabled,
required: this.required,
form: this.form || null,
capture: this.capture || null,
accept: this.accept || null,
multiple: this.multiple,
webkitdirectory: this.directory,
'aria-required': this.required ? 'true' : null
}
}
},
watch: {
Expand Down Expand Up @@ -290,20 +307,7 @@ export const BFormFile = /*#__PURE__*/ Vue.extend({
},
this.stateClass
],
attrs: {
...this.$attrs,
type: 'file',
id: this.safeId(),
name: this.name,
disabled: this.disabled,
required: this.required,
form: this.form || null,
capture: this.capture || null,
accept: this.accept || null,
multiple: this.multiple,
webkitdirectory: this.directory,
'aria-required': this.required ? 'true' : null
},
attrs: this.computedAttrs,
on: {
change: this.onFileChange,
focusin: this.focusHandler,
Expand Down
Loading