@mintjamsinc/ichigojs 0.1.57 → 0.1.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/dist/ichigo.cjs +8 -0
- package/dist/ichigo.cjs.map +1 -1
- package/dist/ichigo.esm.js +8 -0
- package/dist/ichigo.esm.js.map +1 -1
- package/dist/ichigo.esm.min.js +1 -1
- package/dist/ichigo.min.cjs +1 -1
- package/dist/ichigo.umd.js +8 -0
- package/dist/ichigo.umd.js.map +1 -1
- package/dist/ichigo.umd.min.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -219,6 +219,37 @@ List rendering:
|
|
|
219
219
|
</ul>
|
|
220
220
|
```
|
|
221
221
|
|
|
222
|
+
##### Using `<template>` as a fragment
|
|
223
|
+
|
|
224
|
+
`v-for` and `v-if` can be placed on a `<template>` element to render
|
|
225
|
+
multiple nodes per iteration without introducing a wrapper element:
|
|
226
|
+
|
|
227
|
+
```html
|
|
228
|
+
<dl>
|
|
229
|
+
<template v-for="item in items" :key="item.id">
|
|
230
|
+
<dt>{{ item.term }}</dt>
|
|
231
|
+
<dd>{{ item.description }}</dd>
|
|
232
|
+
</template>
|
|
233
|
+
</dl>
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
`<template>` supports **either** `v-for` **or** `v-if` per element, but
|
|
237
|
+
**not both on the same `<template>`**. If you need both, either:
|
|
238
|
+
|
|
239
|
+
1. Nest them on separate `<template>` / element levels:
|
|
240
|
+
```html
|
|
241
|
+
<template v-for="item in items" :key="item.id">
|
|
242
|
+
<div v-if="item.visible">{{ item.name }}</div>
|
|
243
|
+
</template>
|
|
244
|
+
```
|
|
245
|
+
2. Use a regular element instead of `<template>`:
|
|
246
|
+
```html
|
|
247
|
+
<div v-for="item in items" v-if="item.visible" :key="item.id">...</div>
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Combining `v-for` and `v-if` on the same element works for all
|
|
251
|
+
non-`<template>` tags (v-for is evaluated first, v-if per iteration).
|
|
252
|
+
|
|
222
253
|
#### v-show
|
|
223
254
|
|
|
224
255
|
Toggle visibility:
|
package/dist/ichigo.cjs
CHANGED
|
@@ -8653,6 +8653,14 @@
|
|
|
8653
8653
|
// Other directives (@click, :class, etc.) will be processed on the cloned/rendered elements.
|
|
8654
8654
|
const attributes = [];
|
|
8655
8655
|
if (element.hasAttribute(StandardDirectiveName.V_FOR)) {
|
|
8656
|
+
// <template v-for v-if> is not supported: v-for clones .content (a
|
|
8657
|
+
// DocumentFragment), so the v-if attribute on the <template> itself
|
|
8658
|
+
// is lost. Warn the developer so silent failure is avoided.
|
|
8659
|
+
if (element instanceof HTMLTemplateElement && element.hasAttribute(StandardDirectiveName.V_IF)) {
|
|
8660
|
+
console.warn('[ichigo.js] <template> cannot combine v-for and v-if. ' +
|
|
8661
|
+
'The v-if will be ignored. Move v-if to an inner element, ' +
|
|
8662
|
+
'or replace <template> with a regular element.', element);
|
|
8663
|
+
}
|
|
8656
8664
|
// For v-for template element: only process v-for and :key
|
|
8657
8665
|
// Other attributes will be processed when child VNodes are created for cloned elements
|
|
8658
8666
|
attributes.push(element.getAttributeNode(StandardDirectiveName.V_FOR));
|