Skip to content

Commit

Permalink
fix(cache): avoid stack overflow because of vue reusing elements
Browse files Browse the repository at this point in the history
  • Loading branch information
pdanpdan committed May 12, 2023
1 parent aac906e commit a5c6d5f
Show file tree
Hide file tree
Showing 36 changed files with 94 additions and 7 deletions.
3 changes: 3 additions & 0 deletions ui/src/components/btn-dropdown/QBtnDropdown.js
Expand Up @@ -106,6 +106,7 @@ export default Vue.extend({

this.disableDropdown !== true && Arrow.push(
h(QMenu, {
key: 'menu',
ref: 'menu',
attrs: {
id: this.targetUid
Expand Down Expand Up @@ -148,6 +149,7 @@ export default Vue.extend({

if (this.split === false) {
return h(QBtn, {
key: 'nonSpl',
class: 'q-btn-dropdown q-btn-dropdown--simple',
props: {
...this.$props,
Expand All @@ -171,6 +173,7 @@ export default Vue.extend({
}

const Btn = h(QBtn, {
key: 'spl',
class: 'q-btn-dropdown--current',
props: {
...this.$props,
Expand Down
6 changes: 3 additions & 3 deletions ui/src/components/carousel/QCarousel.js
Expand Up @@ -156,7 +156,7 @@ export default Vue.extend({
const fn = this.$scopedSlots['navigation-icon'] !== void 0
? this.$scopedSlots['navigation-icon']
: opts => h(QBtn, {
key: 'nav' + opts.name,
key: 'nav#' + opts.name,
class: `q-carousel__navigation-icon q-carousel__navigation-icon--${opts.active === true ? '' : 'in'}active`,
props: opts.btnProps,
on: cache(this, 'nav#' + opts.name, { click: opts.onClick })
Expand Down Expand Up @@ -206,10 +206,10 @@ export default Vue.extend({
if (this.infinite === true || this.panelIndex > 0) {
node.push(
h('div', {
key: 'prev',
staticClass: `q-carousel__control q-carousel__arrow q-carousel__prev-arrow q-carousel__prev-arrow--${this.direction} absolute flex flex-center`
}, [
h(QBtn, {
key: 'prev',
props: { icon: this.arrowIcons[0], ...this.controlProps },
on: cache(this, 'prev', { click: this.previous })
})
Expand All @@ -220,10 +220,10 @@ export default Vue.extend({
if (this.infinite === true || this.panelIndex < this.panels.length - 1) {
node.push(
h('div', {
key: 'next',
staticClass: `q-carousel__control q-carousel__arrow q-carousel__next-arrow q-carousel__next-arrow--${this.direction} absolute flex flex-center`
}, [
h(QBtn, {
key: 'next',
props: { icon: this.arrowIcons[1], ...this.controlProps },
on: cache(this, 'next', { click: this.next })
})
Expand Down
2 changes: 2 additions & 0 deletions ui/src/components/chip/QChip.js
Expand Up @@ -173,6 +173,7 @@ export default Vue.extend({

this.removable === true && child.push(
h(QIcon, {
key: 'non',
staticClass: 'q-chip__icon q-chip__icon--remove cursor-pointer',
props: { name: this.removeIcon },
attrs: this.attrs.remove,
Expand All @@ -197,6 +198,7 @@ export default Vue.extend({
}

this.isClickable === true && Object.assign(data, {
key: 'click',
attrs: this.attrs.chip,
on: cache(this, 'click', {
click: this.__onClick,
Expand Down
15 changes: 15 additions & 0 deletions ui/src/components/color/QColor.js
Expand Up @@ -236,6 +236,7 @@ export default Vue.extend({

this.noHeaderTabs !== true && child.push(
h(QTabs, {
key: 'topVTab',
class: 'q-color-picker__header-tabs',
props: {
value: this.topView,
Expand Down Expand Up @@ -269,6 +270,7 @@ export default Vue.extend({
staticClass: 'q-color-picker__header-banner row flex-center no-wrap'
}, [
h('input', {
key: 'topIn',
staticClass: 'fit',
domProps: { value: this.model[this.topView] },
attrs: this.editable !== true ? {
Expand Down Expand Up @@ -336,6 +338,7 @@ export default Vue.extend({
staticClass: 'q-color-picker__footer relative-position overflow-hidden'
}, [
h(QTabs, {
key: 'ftIn',
staticClass: 'absolute-full',
props: {
value: this.view,
Expand Down Expand Up @@ -376,6 +379,7 @@ export default Vue.extend({
__getSpectrumTab (h) {
return [
h('div', {
key: 'spectrT',
ref: 'spectrum',
staticClass: 'q-color-picker__spectrum non-selectable relative-position cursor-pointer',
style: this.spectrumStyle,
Expand Down Expand Up @@ -413,6 +417,7 @@ export default Vue.extend({
staticClass: 'q-color-picker__sliders'
}, [
h(QSlider, {
key: 'hueSlide',
staticClass: 'q-color-picker__hue non-selectable',
props: {
value: this.model.h,
Expand All @@ -432,6 +437,7 @@ export default Vue.extend({

this.hasAlpha === true
? h(QSlider, {
key: 'alphaSlide',
staticClass: 'q-color-picker__alpha non-selectable',
props: {
value: this.model.a,
Expand Down Expand Up @@ -467,6 +473,7 @@ export default Vue.extend({
h('div', { staticClass: 'row items-center no-wrap' }, [
h('div', ['R']),
h(QSlider, {
key: 'rSlide',
props: {
value: this.model.r,
min: 0,
Expand All @@ -481,6 +488,7 @@ export default Vue.extend({
})
}),
h('input', {
key: 'rIn',
domProps: { value: this.model.r },
attrs,
on: cache(this, 'rIn', {
Expand All @@ -494,6 +502,7 @@ export default Vue.extend({
h('div', { staticClass: 'row items-center no-wrap' }, [
h('div', ['G']),
h(QSlider, {
key: 'gSlide',
props: {
value: this.model.g,
min: 0,
Expand All @@ -508,6 +517,7 @@ export default Vue.extend({
})
}),
h('input', {
key: 'gIn',
domProps: { value: this.model.g },
attrs,
on: cache(this, 'gIn', {
Expand All @@ -521,6 +531,7 @@ export default Vue.extend({
h('div', { staticClass: 'row items-center no-wrap' }, [
h('div', ['B']),
h(QSlider, {
key: 'bSlide',
props: {
value: this.model.b,
min: 0,
Expand All @@ -535,6 +546,7 @@ export default Vue.extend({
})
}),
h('input', {
key: 'bIn',
domProps: { value: this.model.b },
attrs,
on: cache(this, 'bIn', {
Expand All @@ -548,6 +560,7 @@ export default Vue.extend({
this.hasAlpha === true ? h('div', { staticClass: 'row items-center no-wrap' }, [
h('div', ['A']),
h(QSlider, {
key: 'aSlide',
props: {
value: this.model.a,
color: 'grey',
Expand All @@ -560,6 +573,7 @@ export default Vue.extend({
})
}),
h('input', {
key: 'aIn',
domProps: { value: this.model.a },
attrs,
on: cache(this, 'aIn', {
Expand All @@ -580,6 +594,7 @@ export default Vue.extend({
? 'q-color-picker__palette-rows--editable'
: ''
}, this.computedPalette.map(color => h('div', {
key: 'palette#' + color,
staticClass: 'q-color-picker__cube col-auto',
style: { backgroundColor: color },
on: this.editable === true ? cache(this, 'palette#' + color, {
Expand Down
14 changes: 12 additions & 2 deletions ui/src/components/date/QDate.js
Expand Up @@ -863,6 +863,7 @@ export default Vue.extend({
]),

this.todayBtn === true ? h(QBtn, {
key: 'today',
staticClass: 'q-date__header-today self-start',
props: {
icon: this.$q.iconSet.datetime.today,
Expand All @@ -883,6 +884,7 @@ export default Vue.extend({
staticClass: 'row items-center q-date__arrow'
}, [
h(QBtn, {
key: 'go-#' + view,
props: {
round: true,
dense: true,
Expand All @@ -906,6 +908,7 @@ export default Vue.extend({
}, [
h('div', { key }, [
h(QBtn, {
key: 'view#' + view,
props: {
flat: true,
dense: true,
Expand All @@ -923,6 +926,7 @@ export default Vue.extend({
staticClass: 'row items-center q-date__arrow'
}, [
h(QBtn, {
key: 'go+#' + view,
props: {
round: true,
dense: true,
Expand Down Expand Up @@ -983,6 +987,7 @@ export default Vue.extend({
}, this.daysOfWeek.map(day => h('div', { staticClass: 'q-date__calendar-item' }, [ h('div', [ day ]) ]))),

h('div', {
key: 'kNavC',
staticClass: 'q-date__calendar-days-container relative-position overflow-hidden',
directives: cache(this, 'kNavC', [{
name: 'key-group-navigation',
Expand All @@ -1000,6 +1005,7 @@ export default Vue.extend({
}, this.days.map(day => h('div', { staticClass: day.classes }, [
day.in === true
? h(QBtn, {
key: calCachePrefix + day.i,
staticClass: day.today === true ? 'q-date__today' : null,
ref: viewTarget === day.i ? 'viewTarget' : void 0,
props: {
Expand Down Expand Up @@ -1045,6 +1051,7 @@ export default Vue.extend({
staticClass: 'q-date__months-item flex flex-center'
}, [
h(QBtn, {
key: 'month#' + i,
staticClass: currentYear === true && this.today.month === i + 1 ? 'q-date__today' : null,
ref: this.viewModel.month === i + 1 ? 'viewTarget' : void 0,
props: Object.assign(
Expand Down Expand Up @@ -1077,7 +1084,7 @@ export default Vue.extend({
)

return h('div', {
key: 'months-view',
key: 'kNavYM',
staticClass: 'q-date__view q-date__months flex flex-center',
directives: cache(this, 'kNavYM', [{
name: 'key-group-navigation',
Expand Down Expand Up @@ -1114,7 +1121,7 @@ export default Vue.extend({
staticClass: 'q-date__years-item flex flex-center'
}, [
h(QBtn, {
key: 'yr' + i,
key: 'yr#' + i,
staticClass: this.today.year === i ? 'q-date__today' : null,
ref: viewTarget === i ? 'viewTarget' : void 0,
props: {
Expand All @@ -1140,6 +1147,7 @@ export default Vue.extend({
staticClass: 'col-auto'
}, [
h(QBtn, {
key: 'y-',
props: {
round: true,
dense: true,
Expand All @@ -1153,6 +1161,7 @@ export default Vue.extend({
]),

h('div', {
key: 'kNavYM',
staticClass: 'q-date__years-content col self-stretch row items-center',
directives: cache(this, 'kNavYM', [{
name: 'key-group-navigation',
Expand All @@ -1164,6 +1173,7 @@ export default Vue.extend({
staticClass: 'col-auto'
}, [
h(QBtn, {
key: 'y+',
props: {
round: true,
dense: true,
Expand Down
1 change: 1 addition & 0 deletions ui/src/components/dialog-bottom-sheet/BottomSheet.js
Expand Up @@ -166,6 +166,7 @@ export default Vue.extend({
)

return h(QDialog, {
key: 'dialog',
ref: 'dialog',
props: this.dialogProps,
on: cache(this, 'hide', {
Expand Down
5 changes: 5 additions & 0 deletions ui/src/components/dialog-plugin/DialogPlugin.js
Expand Up @@ -148,6 +148,7 @@ export default Vue.extend({
getPrompt (h) {
return [
h(QInput, {
key: 'prompt',
props: {
value: this.prompt.model,
type: this.prompt.type,
Expand Down Expand Up @@ -192,6 +193,7 @@ export default Vue.extend({
getOptions (h) {
return [
h(QOptionGroup, {
key: 'opts',
props: {
value: this.options.model,
type: this.options.type,
Expand All @@ -211,12 +213,14 @@ export default Vue.extend({
const child = []

this.cancel && child.push(h(QBtn, {
key: 'cancel',
props: this.cancelProps,
attrs: { 'data-autofocus': this.focus === 'cancel' && this.hasForm !== true },
on: cache(this, 'cancel', { click: this.onCancel })
}))

this.ok && child.push(h(QBtn, {
key: 'ok',
props: this.okProps,
attrs: { 'data-autofocus': this.focus === 'ok' && this.hasForm !== true },
on: cache(this, 'ok', { click: this.onOk })
Expand Down Expand Up @@ -303,6 +307,7 @@ export default Vue.extend({
}

return h(QDialog, {
key: 'dialog',
ref: 'dialog',

props: {
Expand Down
2 changes: 2 additions & 0 deletions ui/src/components/expansion-item/QExpansionItem.js
Expand Up @@ -208,6 +208,7 @@ export default Vue.extend({

if (this.activeToggleIcon === true) {
Object.assign(data, {
key: 'inpExt',
attrs: {
tabindex: 0,
...this.toggleAriaAttrs
Expand Down Expand Up @@ -305,6 +306,7 @@ export default Vue.extend({
this.__getHeader(h),

h(QSlideTransition, {
key: 'slide',
props: { duration: this.duration },
on: cache(this, 'slide', {
show: () => { this.$emit('after-show') },
Expand Down
1 change: 1 addition & 0 deletions ui/src/components/fab/QFab.js
Expand Up @@ -143,6 +143,7 @@ export default Vue.extend({
on: { ...this.qListeners }
}, [
h(QBtn, {
key: 'tog',
ref: 'trigger',
class: this.formClass,
props: {
Expand Down
4 changes: 3 additions & 1 deletion ui/src/components/file/QFile.js
Expand Up @@ -166,6 +166,7 @@ export default Vue.extend({

__getControl (h) {
const data = {
key: 'target',
ref: 'target',
staticClass: 'q-field__native row items-center cursor-pointer',
attrs: {
Expand Down Expand Up @@ -215,7 +216,7 @@ export default Vue.extend({
return this.innerValue.length === 0
? this.__getFiller(h)
: this.innerValue.map((file, i) => h(QChip, {
key: 'file-' + i,
key: 'rem#' + i,
props: {
removable: this.editable,
dense: true,
Expand Down Expand Up @@ -252,6 +253,7 @@ export default Vue.extend({

__getInput (h) {
const data = {
key: 'input',
ref: 'input',
staticClass: 'q-field__input fit absolute-full cursor-pointer',
attrs: this.inputAttrs,
Expand Down
1 change: 1 addition & 0 deletions ui/src/components/footer/QFooter.js
Expand Up @@ -150,6 +150,7 @@ export default Vue.extend({
render (h) {
const child = mergeSlot([
h(QResizeObserver, {
key: 'resize',
props: { debounce: 0 },
on: cache(this, 'resize', { resize: this.__onResize })
})
Expand Down

0 comments on commit a5c6d5f

Please sign in to comment.