Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(carousel): convert templates to render functions (#1339)
* [carousel-slide] convert to render function * Delete carousel-slide.vue * [carousel] convert to render function * Delete carousel.vue
- Loading branch information
1 parent
49bc50b
commit 13f429f
Showing
4 changed files
with
592 additions
and
538 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,126 @@ | ||
import bCarouselSlide from './carousel-slide.vue'; | ||
import bImg from '../image/img'; | ||
import { warn } from '../../utils'; | ||
import { idMixin } from '../../mixins'; | ||
|
||
export default bCarouselSlide; | ||
export default { | ||
components: { bImg }, | ||
mixins: [ idMixin ], | ||
render(h) { | ||
const t = this; | ||
const $slots = t.$slots; | ||
|
||
let img = $slots.img; | ||
if (!img && (t.imgSrc || t.imgBlank)) { | ||
img = h( | ||
'b-img', | ||
{ | ||
props: { | ||
fluidGrow: true, | ||
block: true, | ||
src: t.imgSrc, | ||
blank: t.imgBlank, | ||
blankColor: t.imgBlankColor, | ||
width: t.computedWidth, | ||
height: t.computedHeight, | ||
alt: t.imgAlt | ||
} | ||
} | ||
); | ||
} | ||
|
||
const content = h( | ||
t.contentTag, | ||
{ class: t.contentClasses }, | ||
[ | ||
t.caption ? h(t.captionTag, { domProps: { innerHTML: t.caption } }) : h(false), | ||
t.text ? h(t.textTag, { domProps: { innerHTML: t.text } }) : h(false), | ||
$slots.default | ||
] | ||
); | ||
|
||
return h( | ||
'div', | ||
{ | ||
class: [ 'carousel-item' ], | ||
style: { background: t.background }, | ||
attrs: { id: t.safeId(), role: 'listitem' }, | ||
}, | ||
[ img, content ] | ||
); | ||
}, | ||
props: { | ||
imgSrc: { | ||
type: String, | ||
default() { | ||
if (this && this.src) { | ||
// Deprecate src | ||
warn("b-carousel-slide: prop 'src' has been deprecated. Use 'img-src' instead"); | ||
return this.src; | ||
} | ||
return null; | ||
} | ||
}, | ||
src: { | ||
// Deprecated: use img-src instead | ||
type: String | ||
}, | ||
imgAlt: { | ||
type: String | ||
}, | ||
imgWidth: { | ||
type: [Number, String] | ||
}, | ||
imgHeight: { | ||
type: [Number, String] | ||
}, | ||
imgBlank: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
imgBlankColor: { | ||
type: String, | ||
default: 'transparent' | ||
}, | ||
contentVisibleUp: { | ||
type: String | ||
}, | ||
contentTag: { | ||
type: String, | ||
default: "div" | ||
}, | ||
caption: { | ||
type: String | ||
}, | ||
captionTag: { | ||
type: String, | ||
default: "h3" | ||
}, | ||
text: { | ||
type: String | ||
}, | ||
textTag: { | ||
type: String, | ||
default: "p" | ||
}, | ||
background: { | ||
type: String | ||
} | ||
}, | ||
computed: { | ||
contentClasses() { | ||
return [ | ||
'carousel-caption', | ||
this.contentVisibleUp ? 'd-none' : '', | ||
this.contentVisibleUp ? `d-${this.contentVisibleUp}-block` : '' | ||
]; | ||
}, | ||
computedWidth() { | ||
// Use local width, or try parent width | ||
return this.imgWidth || this.$parent.imgWidth; | ||
}, | ||
computedHeight() { | ||
// Use local height, or try parent height | ||
return this.imgHeight || this.$parent.imgHeight; | ||
} | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.