Skip to content

Commit 36db959

Browse files
Replace deepmerge with lodash mergeWith
1 parent ecd7d54 commit 36db959

13 files changed

+149
-56
lines changed

changelog.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
## 1.0.0-beta.7 (2022-10-24)
2+
3+
* Replace underscore with lodash
4+
* Replace deepmerge with lodash method `mergeWith`
5+
* Added merge customizer via options for lodash method `mergeWith`
6+
17
## 1.0.0-beta.6 (2022-10-24)
28

3-
* Fix $slots context
9+
* Fix `$slots` context
410

511
## 1.0.0-beta.5 (2022-10-24)
612

docs/docs.html

+23
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,23 @@ <h2 id="options" tabindex="-1">
546546
</td>
547547
<td style="text-align:left">Boolean value for enable or disable throw an exception.</td>
548548
</tr>
549+
<tr>
550+
<td style="text-align:center">
551+
<strong>mergeCustomizer</strong>
552+
</td>
553+
<td style="text-align:center">
554+
<code>function</code>
555+
</td>
556+
<td style="text-align:left">
557+
Function callback passed to lodash
558+
<code>mergeWith</code>
559+
for attribute
560+
<code>locals</code>
561+
and
562+
<code>merge:attribute</code>
563+
. By default it's used to concat array.
564+
</td>
565+
</tr>
549566
</tbody>
550567
</table>
551568
<h2 id="features" tabindex="-1">
@@ -1087,6 +1104,12 @@ <h3 id="props" tabindex="-1">
10871104
<code>class</code>
10881105
attribute of the first node. Let's see in next section more about this.
10891106
</p>
1107+
<p>
1108+
You can change how attributes are merged by passing via options a callback function used by lodash method
1109+
<a href="https://lodash.com/docs/4.17.15#mergeWith">mergeWith</a>
1110+
.
1111+
By default, it's used to concat array.
1112+
</p>
10901113
<h3 id="attributes" tabindex="-1">
10911114
<a class="header-anchor" href="#attributes">#</a>
10921115
Attributes

examples/dist/docs.html

+23
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,23 @@ <h2 id="options" tabindex="-1">
546546
</td>
547547
<td style="text-align:left">Boolean value for enable or disable throw an exception.</td>
548548
</tr>
549+
<tr>
550+
<td style="text-align:center">
551+
<strong>mergeCustomizer</strong>
552+
</td>
553+
<td style="text-align:center">
554+
<code>function</code>
555+
</td>
556+
<td style="text-align:left">
557+
Function callback passed to lodash
558+
<code>mergeWith</code>
559+
for attribute
560+
<code>locals</code>
561+
and
562+
<code>merge:attribute</code>
563+
. By default it's used to concat array.
564+
</td>
565+
</tr>
549566
</tbody>
550567
</table>
551568
<h2 id="features" tabindex="-1">
@@ -1087,6 +1104,12 @@ <h3 id="props" tabindex="-1">
10871104
<code>class</code>
10881105
attribute of the first node. Let's see in next section more about this.
10891106
</p>
1107+
<p>
1108+
You can change how attributes are merged by passing via options a callback function used by lodash method
1109+
<a href="https://lodash.com/docs/4.17.15#mergeWith">mergeWith</a>
1110+
.
1111+
By default, it's used to concat array.
1112+
</p>
10901113
<h3 id="attributes" tabindex="-1">
10911114
<a class="header-anchor" href="#attributes">#</a>
10921115
Attributes

examples/src/md/changelog.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
## 1.0.0-beta.7 (2022-10-24)
2+
3+
* Replace underscore with lodash
4+
* Replace deepmerge with lodash method `mergeWith`
5+
* Added merge customizer via options for lodash method `mergeWith`
6+
17
## 1.0.0-beta.6 (2022-10-24)
28

3-
* Fix $slots context
9+
* Fix `$slots` context
410

511
## 1.0.0-beta.5 (2022-10-24)
612

examples/src/md/introduction.md

+26-22
Original file line numberDiff line numberDiff line change
@@ -88,28 +88,29 @@ See also the `examples` folder. You can run `npm run build-examples` to compile
8888

8989
## Options
9090

91-
| Option | Default | Description |
92-
|:----------------------:|:----------------------------:|:----------------------------------------------------------------------------------------------------------------------|
93-
| **root** | `'./'` | String value as root path for components lookup. |
94-
| **folders** | `['']` | Array of additional multi folders path from `options.root` or any defined namespaces root, fallback or custom. |
95-
| **tagPrefix** | `x-` | String for tag prefix. The plugin will use RegExp with this string. |
96-
| **tag** | `false` | String or boolean value for component tag. Use this with `options.attribute`. Boolean only false. |
97-
| **attribute** | `src` | String value for component attribute for set path. |
98-
| **namespaces** | `[]` | Array of namespace's root path, fallback path and custom path for override. |
99-
| **namespaceSeparator** | `::` | String value for namespace separator to be used with tag name. Example `<x-namespace::button>` |
100-
| **fileExtension** | `html` | String value for file extension of the components used for retrieve x-tag file. |
101-
| **yield** | `yield` | String value for `<yield>` tag name. Where main content of component is injected. |
102-
| **slot** | `slot` | String value for `<slot>` tag name. Used with RegExp by appending `:` (example `<slot:slot-name>`). |
103-
| **fill** | `fill` | String value for `<fill>` tag name. Used with RegExp by appending `:` (example `<fill:slot-name>`). |
104-
| **slotSeparator** | `:` | String value used for separate `<slot>` and `<fill>` tag from their names. |
105-
| **push** | `push` | String value for `<push>` tag name. |
106-
| **stack** | `stack` | String value for `<stack>` tag name. |
107-
| **localsAttr** | `props` | String value used in `<script props>` parsed by the plugin to retrieve locals in the components. |
108-
| **expressions** | `{}` | Object to configure `posthtml-expressions`. You can pre-set locals or customize the delimiters for example. |
109-
| **plugins** | `[]` | PostHTML plugins to apply for every parsed components. |
110-
| **matcher** | `[{tag: options.tagPrefix}]` | Array of object used to match the tags. |
111-
| **attrsParserRules** | `{}` | Additional rules for attributes parser plugin. |
112-
| **strict** | `true` | Boolean value for enable or disable throw an exception. |
91+
| Option | Default | Description |
92+
|:----------------------:|:----------------------------:|:-----------------------------------------------------------------------------------------------------------------------------------|
93+
| **root** | `'./'` | String value as root path for components lookup. |
94+
| **folders** | `['']` | Array of additional multi folders path from `options.root` or any defined namespaces root, fallback or custom. |
95+
| **tagPrefix** | `x-` | String for tag prefix. The plugin will use RegExp with this string. |
96+
| **tag** | `false` | String or boolean value for component tag. Use this with `options.attribute`. Boolean only false. |
97+
| **attribute** | `src` | String value for component attribute for set path. |
98+
| **namespaces** | `[]` | Array of namespace's root path, fallback path and custom path for override. |
99+
| **namespaceSeparator** | `::` | String value for namespace separator to be used with tag name. Example `<x-namespace::button>` |
100+
| **fileExtension** | `html` | String value for file extension of the components used for retrieve x-tag file. |
101+
| **yield** | `yield` | String value for `<yield>` tag name. Where main content of component is injected. |
102+
| **slot** | `slot` | String value for `<slot>` tag name. Used with RegExp by appending `:` (example `<slot:slot-name>`). |
103+
| **fill** | `fill` | String value for `<fill>` tag name. Used with RegExp by appending `:` (example `<fill:slot-name>`). |
104+
| **slotSeparator** | `:` | String value used for separate `<slot>` and `<fill>` tag from their names. |
105+
| **push** | `push` | String value for `<push>` tag name. |
106+
| **stack** | `stack` | String value for `<stack>` tag name. |
107+
| **localsAttr** | `props` | String value used in `<script props>` parsed by the plugin to retrieve locals in the components. |
108+
| **expressions** | `{}` | Object to configure `posthtml-expressions`. You can pre-set locals or customize the delimiters for example. |
109+
| **plugins** | `[]` | PostHTML plugins to apply for every parsed components. |
110+
| **matcher** | `[{tag: options.tagPrefix}]` | Array of object used to match the tags. |
111+
| **attrsParserRules** | `{}` | Additional rules for attributes parser plugin. |
112+
| **strict** | `true` | Boolean value for enable or disable throw an exception. |
113+
| **mergeCustomizer** | `function` | Function callback passed to lodash `mergeWith` for attribute `locals` and `merge:attribute`. By default it's used to concat array. |
113114

114115
## Features
115116

@@ -597,6 +598,9 @@ So the prop `size` is not override since we prepend `computed:` to the attribute
597598
And the prop `items` is merged and not override.
598599
You can also notice how the `class` attribute is merged with `class` attribute of the first node. Let's see in next section more about this.
599600

601+
You can change how attributes are merged by passing via options a callback function used by lodash method [mergeWith](https://lodash.com/docs/4.17.15#mergeWith).
602+
By default, it's used to concat array.
603+
600604
### Attributes
601605

602606
Your can pass any attributes to your components and this will be added to the first node of your component, or to the node with an attribute named `attributes`.

examples/src/pages/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ <h1 class="display-1 fw-bold mb-4">Build the web with PostHTML</h1>
1414
</div>
1515

1616
<p class="text-muted">
17-
Currently <strong>v1.0.0-beta.6</strong>
17+
Currently <strong>v1.0.0-beta.7</strong>
1818
<span class="px-1">·</span>
1919
<a href="#" class="link-secondary" data-bs-toggle="modal" data-bs-target="#modalWithComponents">Changelog</a>
2020
</p>

package-lock.json

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "posthtml-component",
3-
"version": "1.0.0-beta.6",
3+
"version": "1.0.0-beta.7",
44
"description": "PostHTML Components Blade-like with slots, attributes as props and custom tag",
55
"license": "MIT",
66
"repository": "thewebartisan7/posthtml-components",
77
"author": "Damir Grgic <damir@tuta.io> (https://github.com/thewebartisan7)",
88
"main": "src",
99
"engines": {
10-
"node": ">=12"
10+
"node": ">=10"
1111
},
1212
"scripts": {
1313
"version": "conventional-changelog -i changelog.md -s -r 0 && git add changelog.md",
@@ -23,7 +23,6 @@
2323
"html"
2424
],
2525
"dependencies": {
26-
"deepmerge": "^4.2.2",
2726
"lodash": "^4.17.21",
2827
"posthtml-attrs-parser": "^0.1.1",
2928
"posthtml-expressions": "^1.9.0",

0 commit comments

Comments
 (0)