Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

Commit

Permalink
v0.1.4
Browse files Browse the repository at this point in the history
- Allow directives to be passed as node's config
- Fix map() method issue related to mapping numbers and objects
  • Loading branch information
areknawo committed Apr 11, 2020
1 parent 50f3d8d commit 32902ab
Show file tree
Hide file tree
Showing 17 changed files with 402 additions and 348 deletions.
14 changes: 9 additions & 5 deletions dist/isotope.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* @isotope/core v0.1.3
* @isotope/core v0.1.4
* (c) Arek Nawo <[email protected]> (areknawo.com)
* Released under the MIT License.
*/
Expand All @@ -24,7 +24,7 @@
if (typeof config === "string") {
this.element.textContent = config;
}
else if (config) {
else if (typeof config === "object" && !Array.isArray(config)) {
if (config.attach) {
this.childIndex = 0;
}
Expand All @@ -41,6 +41,9 @@
callback(this, config);
});
}
else if (config) {
this.$(config);
}
this.process();
}
/**
Expand Down Expand Up @@ -245,7 +248,7 @@
*/
getElement(element, config) {
if (typeof element === "string") {
if (typeof config === "object" && config.namespace) {
if (typeof config === "object" && !Array.isArray(config) && config.namespace) {
if (this.customDOM) {
return this.customDOM.createElement(element, config.namespace);
}
Expand Down Expand Up @@ -765,10 +768,11 @@
*/
const fill = ({ changes, targetInput }) => {
changes.forEach((change) => {
const { id, type } = change;
const id = `${change.id}`;
const { type } = change;
if (type === "add" || type === "move") {
const index = targetInput.findIndex((item) => {
return typeof item === "object" ? item.id === id : item === id;
return typeof item === "object" ? `${item.id}` === id : `${item}` === id;
});
if (type === "add") {
change.item = targetInput[index];
Expand Down
4 changes: 2 additions & 2 deletions dist/isotope.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/isotope.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/nodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const childNode = view.child("div");

- `tag: string` - HTML tag for the DOM Element of the node.

- `config?: string | object` - Optional text content string or config object.
- `config?: string | object | function | function[]` - Optional text content string, config object, [directive](./directives.md) or an array of them.

- `namespace?: string` - Namespace URI used to create the DOM Element. See [SVG section](./svg.md) for example with SVG elements.
- `autoLink?: boolean` - If all future children of the created node should be automatically **linked**. See [reactivity section](./reactivity.md) for more details about linking.
Expand Down
8 changes: 4 additions & 4 deletions lib/node.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ declare class IsotopeNode<S extends Indexable = any, C extends Indexable = any>
* @param element - The Node's HTML element or tag.
* @param config - The Node's configuration.
*/
constructor(element: string | CustomElement | Element, config?: IsotopeNodeConfig<S, C> | string);
constructor(element: string | CustomElement | Element, config?: IsotopeNodeConfig<S, C> | string | Directive<S, C, void> | Array<Directive<S, C, void>>);
/**
* Executes the provided directive(s).
*
Expand All @@ -46,7 +46,7 @@ declare class IsotopeNode<S extends Indexable = any, C extends Indexable = any>
* @param config - Child Node's configuration.
* @returns - The created child Node.
*/
child<S2 extends Indexable = Indexable, C2 extends Indexable = Indexable>(tag: string, config?: IsotopeNodeConfig<S2, Partial<C> & C2> | string): IsotopeNode<S2, Partial<C> & C2>;
child<S2 extends Indexable = Indexable, C2 extends Indexable = Indexable>(tag: string, config?: IsotopeNodeConfig<S2, Partial<C> & C2> | string | Directive<S2, Partial<C> & C2, void> | Array<Directive<S2, Partial<C> & C2, void>>): IsotopeNode<S2, Partial<C> & C2>;
/**
* Cleans the Node's child tree.
*
Expand Down Expand Up @@ -134,10 +134,10 @@ declare class IsotopeNode<S extends Indexable = any, C extends Indexable = any>
* @param config - The Node's configuration.
* @returns - Retrieved element.
*/
protected getElement(element: string | CustomElement | Element, config?: IsotopeNodeConfig<S, C> | string): CustomElement;
protected getElement(element: string | CustomElement | Element, config?: IsotopeNodeConfig<S, C> | string | Directive<S, C, void> | Array<Directive<S, C, void>>): CustomElement;
/**
* Processes and renders the Node.
*/
protected process(): void;
}
export { IsotopeNode, IsotopeNodeConfig };
export { Directive, IsotopeNode, IsotopeNodeConfig };
7 changes: 5 additions & 2 deletions lib/node.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/node.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/nodes/html/register.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IsotopeNode, IsotopeNodeConfig } from "../../node";
import { Directive, IsotopeNode, IsotopeNodeConfig } from "../../node";
import { Indexable } from "../../declarations";
declare type Child = <S extends Indexable = any, C extends Indexable = any>(config?: IsotopeNodeConfig<S, C> | string) => IsotopeNode<S, C>;
declare type Child = <S extends Indexable = any, C extends Indexable = any>(config?: IsotopeNodeConfig<S, C> | string | Directive<S, C, void> | Array<Directive<S, C, void>>) => IsotopeNode<S, C>;
/**
* Registers new Node child function.
*
Expand Down
2 changes: 1 addition & 1 deletion lib/nodes/html/register.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 32902ab

Please sign in to comment.