Skip to content

Commit

Permalink
fix(*): clean up vue-bind-once references [KHCP-14269]
Browse files Browse the repository at this point in the history
  • Loading branch information
portikM committed Dec 5, 2024
1 parent 555cc6b commit a04d660
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 21 deletions.
3 changes: 1 addition & 2 deletions cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { mount } from 'cypress/vue'
import { createMemoryHistory, createRouter } from 'vue-router/dist/vue-router.prod.cjs'
import type { RouteRecordRaw } from 'vue-router'
import type { App, ComputedOptions } from 'vue'
import { BindOncePlugin } from 'vue-bind-once'
import Chainable = Cypress.Chainable
import 'cypress-fail-fast'
// Import Kongponent styles
Expand Down Expand Up @@ -38,7 +37,7 @@ Cypress.Commands.add('mount', (component: ComputedOptions, options = {}): Chaina
app.use(options.router)
}
},
}, BindOncePlugin)
})

return mount(component, options)
})
Expand Down
9 changes: 1 addition & 8 deletions docs/guide/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ It's essential to choose context-aware and descriptive names. This practice ensu

#### Attributes

Sometimes you will need to generate a random string to be used as value for various attributes (e.g. accessibility-related attributes like `id`, `for`, `aria-labelledby`, etc.).
Sometimes you will need to generate a random string to be used as value for various attributes (e.g. accessibility-related attributes like `id`, `for`, `aria-labelledby`, etc.).

To generate a unique id so that it is safe for SSR, you **must** use the `useUniqueId` composable in your component:

Expand All @@ -230,13 +230,6 @@ const id = useUniqueId()
</script>
```

Then you must use the [`v-bind-once` directive](https://github.com/danielroe/vue-bind-once) to bind the unique id to element attributes (this prevents hydration issues in SSR apps):

```html
<label v-bind-once="{ for: id }">Label</label>
<input v-bind-once="{ id: id }" />
```

## Testing your component

You're free to play around with your component on the local instance of the docs site by running `pnpm docs:dev`; however, you may also want to test your local changes in a consuming application.
Expand Down
8 changes: 0 additions & 8 deletions docs/guide/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ Import and registration can be done individually in the app entry file (e.g. `ma
```ts
// main.ts (or Vue entry file)

// Kongponents rely on vue-bind-once directive to work properly
// The Kongponents bundle includes the vue-bind-once package so you won't need to install it separately, but it does need to be registered
import { BindOncePlugin } from 'vue-bind-once'
import { createApp } from 'vue'
import { KButton } from '@kong/kongponents'
import '@kong/kongponents/dist/style.css'
Expand All @@ -79,9 +76,6 @@ import '@kong/kongponents/dist/style.css'

const app = createApp(App)

// Register the vue-bind-once directive as a Vue Plugin
app.use(BindOncePlugin)

// Register an individual Kongponent
app.component('KButton', KButton)

Expand Down Expand Up @@ -115,8 +109,6 @@ this path instead: import '~@kong/kongponents/dist/style.css' */
</style>
```

When using Kongponents individually like this you will still need to register [`vue-bind-once` plugin](https://github.com/danielroe/vue-bind-once). Please refer to [global registration](#global-registration) section for example.

## TypeScript interfaces

:::tip NOTE
Expand Down
3 changes: 0 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { App } from 'vue'
import * as components from './components' // Import all components
import './styles/styles.scss' // Import all styles
import { BindOncePlugin } from 'vue-bind-once'

// Export Vue plugin
export default {
Expand All @@ -10,8 +9,6 @@ export default {
// @ts-ignore: key is a valid string
app.component(key, components[key])
}

app.use(BindOncePlugin)
},
}

Expand Down

0 comments on commit a04d660

Please sign in to comment.