Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(options: TestEnvironmentOptions = {}) {
// let document = options.document || window.document;
// let appendOperations = options.appendOperations || new DOMTreeConstruction(document);
super({
appendOperations: options.appendOperations || new DOMTreeConstruction(options.document as Document || window.document),
updateOperations: new DOMChanges((options.document || window.document) as Document)
});
// recursive field, so "unsafely" set one half late (but before the resolver is actually used)
this.resolver['options'] = this.compileOptions;
this.lookup = new LookupResolver(this.resolver);
let document = options.document || window.document;
this.uselessAnchor = document.createElement('a') as HTMLAnchorElement;
this.registerHelper("if", ([cond, yes, no]) => cond ? yes : no);
this.registerHelper("unless", ([cond, yes, no]) => cond ? no : yes);
this.registerInternalHelper("-get-dynamic-var", getDynamicVar);
this.registerModifier("action", new InertModifierManager());
this.registerInternalHelper("hash", (_vm: VM, args: Arguments) => args.capture().named);
}
constructor(options?: EnvironmentOptions) {
if (!options) {
let document = window.document;
let appendOperations = new DOMTreeConstruction(document);
let updateOperations = new DOMChanges(document as HTMLDocument);
options = { appendOperations, updateOperations };
}
super(options);
}
}
function testOptions(options: Maybe) {
let document: Maybe = options ? options.document : undefined;
let appendOperations: Maybe = options && options.appendOperations;
let updateOperations: Maybe = options && options.updateOperations;
if (!document) document = window.document as SimpleDocument;
if (!appendOperations) {
appendOperations = new DOMTreeConstruction(document);
}
if (!updateOperations) {
updateOperations = new DOMChanges(document);
}
return { appendOperations, updateOperations };
}
constructor(options?: EnvironmentOptions) {
if (!options) {
let document = window.document as SimpleDocument;
let appendOperations = new DOMTreeConstruction(document);
let updateOperations = new DOMChanges(document);
options = { appendOperations, updateOperations };
}
super(options);
}
}
function testOptions(options: Maybe) {
let document: Maybe = options ? options.document : undefined;
let appendOperations: Maybe = options && options.appendOperations;
let updateOperations: Maybe = options && options.updateOperations;
if (!document) document = window.document;
if (!appendOperations) {
appendOperations = new DOMTreeConstruction(document);
}
if (!updateOperations) {
updateOperations = new DOMChanges(document as HTMLDocument);
}
return { appendOperations, updateOperations };
}
static create(options: Partial = {}) {
options.document = options.document || self.document;
options.appendOperations =
options.appendOperations || new DOMTreeConstruction(options.document as SimpleDocument);
return new EnvironmentImpl(options as EnvironmentOptions);
}