This repository has been archived by the owner on Feb 11, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fix context initialization when working with config input directives.
- Loading branch information
Showing
9 changed files
with
121 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/*! | ||
* @isotope/core v0.2.1 | ||
* @isotope/core v0.2.2 | ||
* (c) Arek Nawo <[email protected]> (areknawo.com) | ||
* Released under the MIT License. | ||
*/ | ||
|
@@ -24,7 +24,7 @@ | |
if (typeof config === "string") { | ||
this.element.textContent = config; | ||
} | ||
else if (typeof config === "object" && !Array.isArray(config)) { | ||
else if (typeof config === "object") { | ||
if (config.attach) { | ||
this.childIndex = 0; | ||
} | ||
|
@@ -41,9 +41,6 @@ | |
callback(this, config); | ||
}); | ||
} | ||
else if (config) { | ||
this.$(config); | ||
} | ||
this.process(); | ||
} | ||
/** | ||
|
@@ -75,30 +72,28 @@ | |
*/ | ||
child(tag, config) { | ||
const shouldAttach = typeof this.childIndex !== "undefined"; | ||
const isConfigDirective = typeof config === "function" || Array.isArray(config); | ||
let element = tag; | ||
if (shouldAttach) { | ||
const attachTarget = this.element.children[this.childIndex || 0]; | ||
const index = this.childIndex || 0; | ||
const attachTarget = this.element.children[index]; | ||
if (attachTarget) { | ||
element = attachTarget; | ||
this.childIndex = (this.childIndex || 0) + 1; | ||
this.childIndex = index + 1; | ||
} | ||
} | ||
const node = new IsotopeNode(element, config); | ||
const node = new IsotopeNode(element, isConfigDirective ? {} : config); | ||
this.element.appendChild(node.element); | ||
if (shouldAttach && !node.childIndex) { | ||
node.childIndex = 0; | ||
} | ||
if (this.context) { | ||
if (node.context) { | ||
node.context = Object.assign(node.context, this.context); | ||
} | ||
else { | ||
node.context = this.context; | ||
} | ||
} | ||
this.passContext(node); | ||
if (this.autoLink) { | ||
this.link(node); | ||
} | ||
if (isConfigDirective) { | ||
this.$(config); | ||
} | ||
return node; | ||
} | ||
/** | ||
|
@@ -269,6 +264,21 @@ | |
} | ||
return element; | ||
} | ||
/** | ||
* Passes context to the child node. | ||
* | ||
* @param node - Node to pass the context to. | ||
*/ | ||
passContext(node) { | ||
if (this.context) { | ||
if (node.context) { | ||
node.context = Object.assign(node.context, this.context); | ||
} | ||
else { | ||
node.context = this.context; | ||
} | ||
} | ||
} | ||
/** | ||
* Processes and renders the Node. | ||
*/ | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.