Skip to content

Commit

Permalink
πŸ› Fix element variables not being a Variables instance
Browse files Browse the repository at this point in the history
  • Loading branch information
skerit committed Jul 25, 2024
1 parent d55a8fc commit 5ebdc06
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/element/custom_element.js
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ function renderContentsWithTemplate(element, template, variables, slot_data, ple
const doEarlyResolve = value => pledge.resolve(value);

if (element[Hawkejs.VARIABLES]) {
variables = element[Hawkejs.VARIABLES].overlay(variables);
variables = Hawkejs.Variables.cast(element[Hawkejs.VARIABLES], renderer).overlay(variables);
} else {
variables = renderer.prepareVariables(variables);
}
Expand Down
16 changes: 16 additions & 0 deletions test/02-variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,22 @@ describe('Variables', () => {
assert.strictEqual(vars.get('obj').a, 2);
assert.strictEqual(clone.get('obj').a, 2);
});

it('should work when being overlayed', () => {

let initial = Hawkejs.Variables.cast({alpha: 47, beta: 100}, renderer);

let base_variables = initial.overlay();
let shallow_clone = base_variables.getShallowClone();

let extra_variables = renderer.prepareVariables({beta: 48, gamma: 49});

let overlayed = shallow_clone.overlay(extra_variables);

assert.strictEqual(overlayed.get('alpha'), 47);
assert.strictEqual(overlayed.get('beta'), 48);
assert.strictEqual(overlayed.get('gamma'), 49);
});
});

describe('#getExistingCloneIfValied(symbol)', () => {
Expand Down

0 comments on commit 5ebdc06

Please sign in to comment.