Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
IDOM,
IExpressionParser,
IInstructionRenderer,
instructionRenderer,
IObserverLocator,
IRenderContext,
IsBindingBehavior,
LifecycleFlags
} from '@aurelia/runtime';
import { TranslationBinding } from './translation-binding';
export const TranslationParametersInstructionType = 'tpt';
// `.bind` part is needed here only for vCurrent compliance
const attribute = 't-params.bind';
@attributePattern({ pattern: attribute, symbols: '' })
export class TranslationParametersAttributePattern {
public [attribute](rawName: string, rawValue: string, parts: string[]): AttrSyntax {
return new AttrSyntax(rawName, rawValue, '', attribute);
}
}
export class TranslationParametersBindingInstruction {
public readonly type: string = TranslationParametersInstructionType;
public mode: BindingMode.toView = BindingMode.toView;
public constructor(
public from: IsBindingBehavior,
public to: string,
) {}
}
it(`parse [${defs.map(d => d.pattern)}] -> interpret [${value}] -> match=[${match}]`, function () {
let receivedRawName: string;
let receivedRawValue: string;
let receivedParts: string[];
@attributePattern(...defs)
class ThePattern {}
for (const { pattern } of defs) {
ThePattern.prototype[pattern] = (rawName, rawValue, parts) => {
receivedRawName = rawName;
receivedRawValue = rawValue;
receivedParts = parts;
};
}
const container = DI.createContainer();
container.register(ThePattern as any);
const interpreter = container.get(ISyntaxInterpreter);
const attrPattern = container.get(IAttributePattern);
interpreter.add(attrPattern.$patternDefs);
const result = interpreter.interpret(value);
if (match != null) {
public ['PART.style'](rawName: string, rawValue: string, parts: string[]): AttrSyntax {
return new AttrSyntax(rawName, rawValue, parts[0], 'style');
}
}
/**
* Class syntax pattern recognizer, helps Aurelia understand template:
* ```html
* <div></div>
* <div></div>
* <div></div>
* <div></div>
* ```
*/
@attributePattern(
{ pattern: 'class.PART', symbols: '.' },
{ pattern: 'PART.class', symbols: '.' }
)
export class ClassAttributePattern {
public ['class.PART'](rawName: string, rawValue: string, parts: string[]): AttrSyntax {
return new AttrSyntax(rawName, rawValue, parts[1], 'class');
}
public ['PART.class'](rawName: string, rawValue: string, parts: string[]): AttrSyntax {
return new AttrSyntax(rawName, rawValue, parts[0], 'class');
}
}
}
/**
* Style syntax pattern recognizer, helps Aurelia understand template:
* ```html
* <div></div>
* <div></div>
* <div></div>
* <div></div>
* <div></div>
* <div></div>
* <div></div>
* <div></div>
* ```
*/
@attributePattern(
{ pattern: 'style.PART', symbols: '.' },
{ pattern: 'PART.style', symbols: '.' }
)
export class StyleAttributePattern {
public ['style.PART'](rawName: string, rawValue: string, parts: string[]): AttrSyntax {
return new AttrSyntax(rawName, rawValue, parts[1], 'style');
}
public ['PART.style'](rawName: string, rawValue: string, parts: string[]): AttrSyntax {
return new AttrSyntax(rawName, rawValue, parts[0], 'style');
}
}
/**
* Class syntax pattern recognizer, helps Aurelia understand template:
* ```html
import { attributePattern, AttrSyntax } from '@aurelia/jit';
/**
* Attribute syntax pattern recognizer, helping Aurelia understand template:
* ```html
* <div></div>
* <div></div>
* ````
*/
@attributePattern(
{ pattern: 'attr.PART', symbols: '.' },
{ pattern: 'PART.attr', symbols: '.' }
)
export class AttrAttributePattern {
public ['attr.PART'](rawName: string, rawValue: string, parts: string[]): AttrSyntax {
return new AttrSyntax(rawName, rawValue, parts[1], 'attr');
}
public ['PART.attr'](rawName: string, rawValue: string, parts: string[]): AttrSyntax {
return new AttrSyntax(rawName, rawValue, parts[0], 'attr');
}
}
/**
* Style syntax pattern recognizer, helps Aurelia understand template:
* ```html