Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
compileChildNodes(parent) {
if (parent.flags & 8192 /* hasChildNodes */) {
const { childNodes } = parent;
let childNode;
const ii = childNodes.length;
for (let i = 0; i < ii; ++i) {
childNode = childNodes[i];
if (childNode.flags & 128 /* isText */) {
this.instructionRows.push([new TextBindingInstruction(childNode.interpolation)]);
}
else if (childNode.flags & 32 /* isLetElement */) {
const bindings = childNode.bindings;
const instructions = [];
let binding;
const jj = bindings.length;
for (let j = 0; j < jj; ++j) {
binding = bindings[j];
instructions[j] = new LetBindingInstruction(binding.expression, binding.target);
}
this.instructionRows.push([new LetElementInstruction(instructions, childNode.toViewModel)]);
}
else {
this.compileParentNode(childNode);
}
}
describe('handles ITextBindingInstruction', function () {
for (const from of ['${foo}', new Interpolation(['', ''], [new AccessScope('foo')])] as any[]) {
const instruction = new TextBindingInstruction(from) as any;
it(_`instruction=${instruction}`, function () {
const { ctx, sut, dom, renderable, target, placeholder, wrapper, renderContext } = setup();
sut.instructionRenderers[instruction.type].render(LF.none, dom, renderContext, renderable, target, instruction);
expect(renderable.$componentHead).to.equal(null);
expect(renderable.$componentTail).to.equal(null);
expect(renderable.$bindingHead).to.be.a('object', 'renderable.$componentHead');
expect(renderable.$bindingHead).to.equal(renderable.$bindingTail);
const bindable = renderable.$bindingHead as InterpolationBinding;
expect(bindable.target).to.equal(placeholder);
expect(bindable.interpolation['expressions'][0]['name']).to.equal('foo');
expect(bindable.interpolation['parts'][0]).to.equal('');
expect(bindable.interpolation['parts'][1]).to.equal('');
expect(bindable.mode).to.equal(BindingMode.toView);
//expect(target.isConnected).to.equal(false);
strategy |= BindingStrategy.proxies;
}
const dom = this.$controller.context.get>(IDOM);
this.subject = createElement(
dom,
'table',
{
class: 'table is-fullwidth',
},
[
createElement(dom, 'thead', {}, [
createElement(dom, 'tr', {
$1: new HydrateTemplateController({
name: '',
template: ' ',
instructions: [[new TextBindingInstruction(`\${col | pascal}`)]],
strategy
},
'repeat',
[new IteratorBindingInstruction(this.keyedStrategy ? 'col of cols' : 'col of cols', 'items')]
)
})
]),
createElement(dom, 'tbody', {
$1: new HydrateTemplateController({
name: '',
template: '',
instructions: [[new HydrateTemplateController({
name: '',
template: ' ',
instructions: [[new TextBindingInstruction(`\${row[col]}`)]],
strategy
} = setup();
const flags = LF.none;
const ViewModel = createViewModel(
h(
'div',
null,
h('au-m', { class: 'au' }),
'',
h('au-m', { class: 'au' }),
),
[],
[
[
new TextBindingInstruction(parseExpression(`\${id&oneTime}`, BindingType.Interpolation)),
],
[
new HydrateTemplateController(
createDescription(
'if',
h('view-model', { class: 'au' }),
[],
[
[new HydrateElementInstruction('view-model', [])],
],
noHooks,
),
'if',
[new ToViewBindingInstruction(parseExpression('id===1&oneTime'), 'value')],
),
],
private compileChildNodes(parent: IElementSymbol): void {
if (parent.flags & SymbolFlags.hasChildNodes) {
const { childNodes } = parent;
let childNode: INodeSymbol;
const ii = childNodes.length;
for (let i = 0; i < ii; ++i) {
childNode = childNodes[i];
if (childNode.flags & SymbolFlags.isText) {
this.instructionRows.push([new TextBindingInstruction((childNode as TextSymbol).interpolation)]);
} else if (childNode.flags & SymbolFlags.isLetElement) {
const bindings = (childNode as LetElementSymbol).bindings;
const instructions: ILetBindingInstruction[] = [];
let binding: BindingSymbol;
const jj = bindings.length;
for (let j = 0; j < jj; ++j) {
binding = bindings[j];
instructions[j] = new LetBindingInstruction(binding.expression as IsBindingBehavior, binding.target);
}
this.instructionRows.push([new LetElementInstruction(instructions, (childNode as LetElementSymbol).toViewModel)]);
} else {
this.compileParentNode(childNode as IParentNodeSymbol);
}
}
}
}
private compileChildNodes(parent: IElementSymbol): void {
if (parent.flags & SymbolFlags.hasChildNodes) {
const { childNodes } = parent;
let childNode: INodeSymbol;
const ii = childNodes.length;
for (let i = 0; i < ii; ++i) {
childNode = childNodes[i];
if (childNode.flags & SymbolFlags.isText) {
this.instructionRows.push([new TextBindingInstruction((childNode as TextSymbol).interpolation)]);
} else if (childNode.flags & SymbolFlags.isLetElement) {
const bindings = (childNode as LetElementSymbol).bindings;
const instructions: ILetBindingInstruction[] = [];
let binding: BindingSymbol;
const jj = bindings.length;
for (let j = 0; j < jj; ++j) {
binding = bindings[j];
instructions[j] = new LetBindingInstruction(binding.expression as IsBindingBehavior, binding.target);
}
this.instructionRows.push([new LetElementInstruction(instructions, (childNode as LetElementSymbol).toViewModel)]);
} else {
this.compileParentNode(childNode as IParentNodeSymbol);
}
}
}
}