()
| 1951 | // the released ones outweigh the open ones, so rebuilds are linear in the |
| 1952 | // input. |
| 1953 | private compact(): void { |
| 1954 | const bindings = new Map<string, Namespace | undefined>() |
| 1955 | const namespacesByName = new Map<string, Namespace>() |
| 1956 | for (const [prefix, namespace] of this.bindings) { |
| 1957 | if (namespace === undefined) continue |
| 1958 | bindings.set(prefix, namespace) |
| 1959 | namespacesByName.set(namespace.uri, namespace) |
| 1960 | } |
| 1961 | // A shadowed binding comes back into scope when its element closes |
| 1962 | for (const namespace of this.undoBindings) { |
| 1963 | if (namespace !== undefined) namespacesByName.set(namespace.uri, namespace) |
| 1964 | } |
| 1965 | this.bindings = bindings |
| 1966 | this.namespacesByName = namespacesByName |
| 1967 | this.releasedDeclarationSize = 0 |
| 1968 | } |
| 1969 | |
| 1970 | // A DTD can declare a prefix with a default attribute value, which is not |
| 1971 | // applied, so an undeclared prefix is a `Syntax` error only without a DOCTYPE |
no test coverage detected