/* eslint-disable compat/compat */ import { AttrInfo, AttrSyntax, BindableInfo, IAttributeParser, BindingCommandInstance, ResourceModel, SymbolFlags, Char, } from '@aurelia/jit'; import { camelCase, } from '@aurelia/kernel'; import { AnyBindingExpression, BindingMode, BindingType, IDOM, IExpressionParser } from '@aurelia/runtime'; import { NodeType, } from '@aurelia/runtime-html'; import { IAttrSyntaxTransformer } from './attribute-syntax-transformer'; import { BindingSymbol, CustomAttributeSymbol, CustomElementSymbol, ElementSymbol, LetElementSymbol, ParentNodeSymbol, PlainAttributeSymbol, PlainElementSymbol, ReplacePartSymbol, ResourceAttributeSymbol, SymbolWithMarker, TemplateControllerSymbol, TextSymbol, } from './semantic-model'; const invalidSurrogateAttribute = Object.assign(Object.create(null), { 'id': true, 'replace': true }) as Record; const attributesToIgnore = Object.assign(Object.create(null), { 'as-element': true, 'replace': true }) as Record; function hasInlineBindings(rawValue: string): boolean { const len = rawValue.length; let ch = 0; for (let i = 0; i < len; ++i) { ch = rawValue.charCodeAt(i); if (ch === Char.Backslash) { ++i; // Ignore whatever comes next because it's escaped } else if (ch === Char.Colon) { return true; } else if (ch === Char.Dollar && rawValue.charCodeAt(i + 1) === Char.OpenBrace) { return false; } } return false; } function processInterpolationText(symbol: TextSymbol): void { const node = symbol.physicalNode; const parentNode = node.parentNode!; while (node.nextSibling !== null && node.nextSibling.nodeType === NodeType.Text) { parentNode.removeChild(node.nextSibling); } node.textContent = ''; parentNode.insertBefore(symbol.marker, node); } function isTemplateControllerOf(proxy: ParentNodeSymbol, manifest: ElementSymbol): proxy is TemplateControllerSymbol { return proxy !== manifest; } /** * A (temporary) standalone function that purely does the DOM processing (lifting) related to template controllers. * It's a first refactoring step towards separating DOM parsing/binding from mutations. */ function processTemplateControllers(dom: IDOM, manifestProxy: ParentNodeSymbol, manifest: ElementSymbol): void { const manifestNode = manifest.physicalNode as HTMLElement; let current = manifestProxy; let currentTemplate: HTMLTemplateElement; while (isTemplateControllerOf(current, manifest)) { if (current.template === manifest) { // the DOM linkage is still in its original state here so we can safely assume the parentNode is non-null manifestNode.parentNode!.replaceChild(current.marker, manifestNode); // if the manifest is a template element (e.g.