Skip to content

Commit 2d8be7a

Browse files
committed
extract element definitions
1 parent 65bc52f commit 2d8be7a

File tree

2 files changed

+151
-143
lines changed

2 files changed

+151
-143
lines changed

src/analyser.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
import { parse } from "node-html-parser";
22
import { Diagnostic, DiagnosticSeverity } from "./diagnostic";
3-
4-
interface TypedAttribute {
5-
name: string;
6-
format: "json" | "number" | "string";
7-
}
8-
9-
type Definition = [string, TypedAttribute[]];
3+
import { ELEMENT_DEFINITIONS } from "./schema";
104

115
// Analyse Leaflet-HTML syntax
126
export const analyse = (text: string): Diagnostic[] => {
@@ -33,16 +27,9 @@ export const analyse = (text: string): Diagnostic[] => {
3327
}
3428
}
3529

36-
// Definition
37-
const definitions: Definition[] = [
38-
["l-map", [{name: "center", format: "json"}, {name: "zoom", format: "number"}]],
39-
["l-tile-layer", [{name: "url-template", format: "string"}]],
40-
["l-circle", [{name: "lat-lng", format: "json"}]],
41-
];
42-
4330
// HTML parser
4431
const document = parse(text);
45-
definitions.forEach(([tagName, attNames]) => {
32+
ELEMENT_DEFINITIONS.forEach(([tagName, attNames]) => {
4633
const els = document.querySelectorAll(tagName);
4734
els.forEach((el) => {
4835
attNames.forEach((att) => {

0 commit comments

Comments
 (0)