-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
66 lines (57 loc) · 1.87 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Attributes parser</title>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap-reboot.min.css"
/>
<style>
.content {
max-width: 760px;
margin: 0 auto;
padding: 3rem 1rem;
}
pre {
margin-bottom: 3rem;
padding: 1rem;
background-color: var(--bs-secondary-bg);
border-radius: 0.5rem;
}
</style>
</head>
<body>
<div class="content">
<h2>Input</h2>
<pre id="attr-input"></pre>
<h2>Parsed</h2>
<pre id="attr-parsed"></pre>
<h2><code>.toString()</code></h2>
<pre id="attr-tostring"></pre>
<h2><code>.getTokens()</code></h2>
<pre id="attr-tokens"></pre>
</div>
<script src="https://cdn.jsdelivr.net/npm/moo/moo.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/json-loose/dist/index.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/attributes-parser/dist/index.umd.js"></script>
<script>
const attr = `id="my-id" class='my-class' num=3.14 numNeg=-3.14 data-num="3.14" options=\'{"key": "value", "array": [1, 2, 3]}\' data-list="[1, 2, 3]" punc="a=b,c,d,e" checked=false checked=false data-checked="false" disabled`
const parsedAttr = parseAttrs(attr)
document.querySelector("#attr-input").textContent = attr
document.querySelector("#attr-parsed").textContent = JSON.stringify(
parsedAttr,
null,
2
)
document.querySelector("#attr-tostring").textContent =
parsedAttr.toString()
document.querySelector("#attr-tokens").textContent = JSON.stringify(
parsedAttr.getTokens(),
null,
2
)
</script>
</body>
</html>