Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add renderMode param for i-block template which allows to control vnode attributes hoisting #1120

Merged
merged 9 commits into from
Feb 8, 2024
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ _Note: Gaps between patch versions are faulty, broken or test releases._

* Fixed errors when using the tree as a functional component `bTree`

#### :house: Internal

* Create `mono` template in `i-block` for dynamic mono components. It disables
vnode attributes hoisting.

## v4.0.0-beta.54 (2024-02-06)

#### :bug: Bug Fix
Expand Down
7 changes: 7 additions & 0 deletions src/components/super/i-block/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ Changelog
> - :house: [Internal]
> - :nail_care: [Polish]

## v4.0.0-beta.?? (2024-02-??)

#### :house: Internal

* Create `mono` template in `i-block` for dynamic mono components. It disables
vnode attributes hoisting.

## v4.0.0-beta.54 (2024-02-06)

#### :bug: Bug Fix
Expand Down
15 changes: 15 additions & 0 deletions src/components/super/i-block/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,21 @@ If set to false, the component will generate a special markup to allow it to not
- ssrRendering = false
```

#### [renderMode = `component`]

If set to `'component'` some optimizations will be applied to hoist vnode attributes.
If your template is used with `v-render` then renderMode must be set to `'mono'` or
you can extend from `mono` template in `i-block` namespace:

```
- namespace [%fileName%]

- include 'components/super/i-block'|b as placeholder

- template index() extends ['i-block'].mono
/// ...
```

### Methods

#### slot
Expand Down
21 changes: 19 additions & 2 deletions src/components/super/i-block/i-block.ss
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@
*/
- ssrRendering = true

/**
* Should be set to 'component' for components with runtime,
* for dynamic mono components use 'mono'.
* If set to 'component' some optimizations will be applied to hoist
* vnode attributes.
*/
- renderMode = 'component'

/**
* Returns the component name
* @param {string} [name] - the custom template name
Expand Down Expand Up @@ -180,10 +188,16 @@
- else
? rootAttrs[':class'] = value


- rootClass = {'data-cached-dynamic-class': '["call", "provide.componentClasses", "' + self.name() + '", ["get", "mods"]]'}

- if renderMode == 'mono'
? rootClass = {':class': '[...provide.componentClasses("' + self.name() + '", mods)]'}

- rootAttrs = { &
class: 'i-block-helper',
'data-cached-dynamic-class': '["call", "provide.componentClasses", "' + self.name() + '", ["get", "mods"]]',
'v-async-target': '!ssrRendering'
'v-async-target': '!ssrRendering',
...rootClass
} .

- if teleport
Expand Down Expand Up @@ -266,3 +280,6 @@

- else
+= self.renderRootContent()

- template mono() extends ['i-block'].index
- renderMode = 'mono'
Loading