diff --git a/src/html-to-ast.js b/src/html-to-ast.js
index 18617eb..0d1e900 100644
--- a/src/html-to-ast.js
+++ b/src/html-to-ast.js
@@ -78,6 +78,10 @@ export function parse(html) {
node.range = range;
node.raw = html.slice(range[0], range[1]);
}
+ // map `url` to Link node
+ if (node.type === "Link" && typeof node.properties.href !== "undefined") {
+ node.url = node.properties.href;
+ }
}
removeUnusedProperties(node);
});
diff --git a/test/ast-test-case/element-attributes/index.html b/test/ast-test-case/element-attributes/index.html
index 7c695da..14f1b73 100644
--- a/test/ast-test-case/element-attributes/index.html
+++ b/test/ast-test-case/element-attributes/index.html
@@ -93,3 +93,7 @@
+
+
+
+placeholder
diff --git a/test/ast-test-case/element-attributes/index.json b/test/ast-test-case/element-attributes/index.json
index 421f461..fda376c 100644
--- a/test/ast-test-case/element-attributes/index.json
+++ b/test/ast-test-case/element-attributes/index.json
@@ -42,6 +42,7 @@
{
"type": "Link",
"tagName": "a",
+ "url": "http://alpha.com",
"properties": {
"href": "http://alpha.com",
"className": [
@@ -2136,22 +2137,120 @@
},
{
"type": "Str",
- "value": "\n",
+ "value": "\n\n",
"loc": {
"start": {
"line": 95,
"column": 63
},
"end": {
- "line": 96,
+ "line": 97,
"column": 0
}
},
"range": [
1405,
- 1406
+ 1407
],
- "raw": "\n"
+ "raw": "\n\n"
+ },
+ {
+ "loc": {
+ "end": {
+ "column": 19,
+ "line": 97
+ },
+ "start": {
+ "column": 0,
+ "line": 97
+ }
+ },
+ "range": [
+ 1407,
+ 1426
+ ],
+ "raw": "",
+ "type": "Comment",
+ "value": "placeholder:"
+ },
+ {
+ "loc": {
+ "end": {
+ "column": 0,
+ "line": 99
+ },
+ "start": {
+ "column": 19,
+ "line": 97
+ }
+ },
+ "range": [
+ 1426,
+ 1428
+ ],
+ "raw": "\n\n",
+ "type": "Str",
+ "value": "\n\n"
+ },
+ {
+ "children": [
+ {
+ "loc": {
+ "end": {
+ "column": 14,
+ "line": 99
+ },
+ "start": {
+ "column": 3,
+ "line": 99
+ }
+ },
+ "range": [
+ 1431,
+ 1442
+ ],
+ "raw": "placeholder",
+ "type": "Str",
+ "value": "placeholder"
+ }
+ ],
+ "loc": {
+ "end": {
+ "column": 18,
+ "line": 99
+ },
+ "start": {
+ "column": 0,
+ "line": 99
+ }
+ },
+ "properties": {},
+ "range": [
+ 1428,
+ 1446
+ ],
+ "raw": "placeholder",
+ "tagName": "a",
+ "type": "Link"
+ },
+ {
+ "loc": {
+ "end": {
+ "column": 0,
+ "line": 100
+ },
+ "start": {
+ "column": 18,
+ "line": 99
+ }
+ },
+ "range": [
+ 1446,
+ 1447
+ ],
+ "raw": "\n",
+ "type": "Str",
+ "value": "\n"
}
],
"loc": {
@@ -2160,13 +2259,13 @@
"column": 0
},
"end": {
- "line": 96,
+ "line": 100,
"column": 0
}
},
"range": [
0,
- 1406
+ 1447
],
- "raw": "\n\n\n\n\n\n
\n\n\n\n\n\n\n\nng-whatevs.\n\n\n\n\n\n\n\n
\n\n
\n\n
\n\n
\n\n\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\n\n\n\n\n"
+ "raw": "\n\n\n\n\n\n\n\n\n\n\n\n\n\nng-whatevs.\n\n\n\n\n\n\n\n
\n\n
\n\n
\n\n
\n\n\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\n\n\n\n\n\n\n\nplaceholder\n"
}
\ No newline at end of file