-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
π Fix block variables not being prepared properly
- Loading branch information
Showing
4 changed files
with
140 additions
and
18 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 |
---|---|---|
|
@@ -127,6 +127,27 @@ Blocks.setMethod(function toDry() { | |
return result; | ||
}); | ||
|
||
/** | ||
* Prepare this for cloning | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 2.3.16 | ||
* @version 2.3.16 | ||
* | ||
* @param {Renderer} renderer | ||
*/ | ||
Blocks.setMethod(function _prepareClone(renderer, wm, custom_method) { | ||
|
||
let blocks = new Blocks(); | ||
|
||
for (let [key, entry] of this.values) { | ||
entry = Bound.JSON.clone(entry, custom_method || 'toHawkejs', null, wm); | ||
blocks.values.set(key, entry); | ||
} | ||
|
||
return blocks; | ||
}); | ||
|
||
/** | ||
* Copy over blocks if this isntance doesn't have them | ||
* | ||
|
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 |
---|---|---|
|
@@ -821,19 +821,21 @@ Renderer.setMethod(function toJSON() { | |
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 2.2.11 | ||
* @version 2.2.20 | ||
* @version 2.3.16 | ||
*/ | ||
Renderer.setMethod(function _prepareClone(wm, custom_method) { | ||
|
||
if (!wm) { | ||
wm = new WeakMap(); | ||
} | ||
|
||
let blocks = this.blocks._prepareClone(this, wm, custom_method); | ||
|
||
const result = { | ||
variables : this._prepareVariables(this.variables, wm, custom_method), | ||
expose_to_scene : this._prepareVariables(this.expose_to_scene, wm, custom_method), | ||
request : this.request, | ||
blocks : this.blocks, | ||
blocks : blocks, | ||
page_title : this.page_title, | ||
last_template : this.last_template, | ||
focus_block : this.focus_block, | ||
|
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 |
---|---|---|
|
@@ -49,7 +49,8 @@ Variables.setStatic(function cast(value, renderer) { | |
}); | ||
|
||
/** | ||
* Get the amount of variables | ||
* Get the amount of variables in this instance. | ||
* This ignores the parent's variables. | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 2.2.13 | ||
|
@@ -77,12 +78,16 @@ Variables.setMethod(function getOwnDict() { | |
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 2.2.13 | ||
* @version 2.2.13 | ||
* @version 2.3.16 | ||
* | ||
* @param {symbol} clone_name | ||
*/ | ||
Variables.setMethod(function getExistingCloneIfValid(clone_name) { | ||
|
||
if (!Object.hasOwn(this, clone_name)) { | ||
return; | ||
} | ||
|
||
let result = this[clone_name]; | ||
|
||
if (!result) { | ||
|
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