Skip to content

Commit

Permalink
Fix "TypeError: this.$slots.default is not a function" (#18, #20) (#25)
Browse files Browse the repository at this point in the history
* fix(lib): b-field-body wrapped text in b-field

- Fixes the bug that a horizontal `b-field-body` wrapped a simple text
  element with an extra `b-field`. It now returns a text element as is.

issue #5

* fix(lib): performance warning on FieldBody

- Removes a Vue runtime warning that indicated a potential performance
  issue related to how `FieldBody` gave the default slot to `Field`.
  Changes the third parameter of `h` function call to create a `Field`
  from a direct child `[element]` to a function slot `() => element`.

  This will address the issue pointed at in the comment:
  #1 (comment)

* fix(lib): remove unexpected tabindex (#9)

- Fixes the bug that `Table` ended up with `<table>` with an unexpected
  "tabindex" attribute. This bug was caused because Vue 3 no longer
  removes a boolean attribute if its value is "false". `Table` binds
  `undefined` instead of `false` to "tabindex" if `focusable` is `false`
  or not specified.

issue #8

* Publish Package @ntohq/buefy-next (#10)

* Removed CircleCi

* Created GitHub Action Workflow Files

* Added Workflow and Updated Package.json

* Update package.json (#11)

* Update Package Name to `@ntohq/buefy-next` For Publishing to NPM (#13)

* Update package.json

* Rename Package For Publishing to NPM

* Rename Package For Publishing to NPM

* Cleaned Up Workflow and Package.json

* Update package.json

* Renamed Workflow Folder

* Update npm_deploy.yml

* fix(lib): empty BMenuList crash (#21)

- Fixes the bug where an empty `BMenuList` crashed with "TypeError:
  slots.default is not a function". I found `slots.default` was
  `undefined` if `BMenuList` was empty. `BMenuList` makes sure
  `slots.default` is a function before calling it, otherwise returns
  `slots.default` as is.

issue #20

* fix(lib): empty FieldBody crash (#22)

- Fixes the bug where `FieldBody` crashed if no default slot was given.
  `FieldBody` makes sure that `this.$slots.default` is a function before
  calling it and not null before accesssing its fields. This is a
  potential cause of #18, but there might be other
  reasons.

issue #18

* chore: bump version to 0.1.1

---------

Co-authored-by: Wesley Ford <wes@wesdev.pro>
  • Loading branch information
kikuomax and Wesley Ford authored Aug 9, 2023
1 parent f0348bf commit 0d04c8f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ntohq/buefy-next",
"version": "0.1.0",
"version": "0.1.1",
"homepage": "https://buefy.org",
"description": "Lightweight UI components for Vue.js (v3) based on Bulma",
"author": "Rafael Beraldo <rafael.pimpa@gmail.com>",
Expand Down
8 changes: 5 additions & 3 deletions src/components/field/FieldBody.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@ export default {
let first = true
// wraps the default slot (children) with `b-field`.
// children may be given in a fragment and should be extracted.
let children = this.$slots.default()
if (children.length === 1 && children[0].type === Fragment) {
let children = typeof this.$slots.default === 'function'
? this.$slots.default()
: this.$slots.default
if (children != null && children.length === 1 && children[0].type === Fragment) {
children = children[0].children
}
return createElement(
'div',
{ class: 'field-body' },
{
default: () => {
return children.map((element) => {
return children != null && children.map((element) => {
// skip returns(?) and comments
if (element.type === Comment || element.type === Text) {
return element
Expand Down
2 changes: 1 addition & 1 deletion src/components/menu/MenuList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const BMenuList = (props, context) => {
class: 'menu-list',
role: props.ariaRole === 'menu' ? props.ariaRole : null
},
slots.default()
typeof slots.default === 'function' ? slots.default() : slots.default
)
return vlabel ? [vlabel, vnode] : vnode
}
Expand Down

0 comments on commit 0d04c8f

Please sign in to comment.