-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow namespaced html tag attributes
- Loading branch information
1 parent
1cfd27a
commit ad02286
Showing
10 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@marko/compat-v4": patch | ||
"marko-widgets": patch | ||
--- | ||
|
||
Allow namespace native tag attributes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/compat-v4/src/migrate/native-tag-namespaced-attribute.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { types as t } from "@marko/compiler"; | ||
import { diagnosticDeprecate, isNativeTag } from "@marko/babel-utils"; | ||
|
||
export default { | ||
MarkoAttribute(attr) { | ||
const { | ||
node: { modifier }, | ||
} = attr; | ||
|
||
switch (modifier) { | ||
case null: | ||
case undefined: | ||
case "scoped": | ||
case "no-update": | ||
return; | ||
} | ||
|
||
if (!isNativeTag(attr.parentPath as t.NodePath<t.MarkoTag>)) return; | ||
|
||
diagnosticDeprecate(attr, { | ||
label: "Namespaced attributes are deprecated.", | ||
}); | ||
attr.node.name += `:${modifier}`; | ||
attr.node.modifier = null; | ||
}, | ||
} satisfies t.Visitor; |
3 changes: 3 additions & 0 deletions
3
...tures-class/namespaced-attr-native-tag/__snapshots__/auto-migrate.expected/template.marko
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve"> | ||
<use xlink:href="#test"/> | ||
</svg> |
13 changes: 13 additions & 0 deletions
13
tests/fixtures-class/namespaced-attr-native-tag/__snapshots__/dom.expected.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Render | ||
```html | ||
<svg | ||
version="1.1" | ||
xml:space="preserve" | ||
xmlns="http://www.w3.org/2000/svg" | ||
xmlns:xlink="http://www.w3.org/1999/xlink" | ||
> | ||
<use | ||
href="#test" | ||
/> | ||
</svg> | ||
``` |
26 changes: 26 additions & 0 deletions
26
tests/fixtures-class/namespaced-attr-native-tag/__snapshots__/dom.expected/template.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { t as _t } from "marko/src/runtime/vdom/index.js"; | ||
const _marko_componentType = "<fixture-dir>/template.marko", | ||
_marko_template = _t(_marko_componentType); | ||
export default _marko_template; | ||
import _marko_renderer from "marko/src/runtime/components/renderer.js"; | ||
import { r as _marko_registerComponent } from "marko/src/runtime/components/registry"; | ||
_marko_registerComponent(_marko_componentType, () => _marko_template); | ||
const _marko_component = {}; | ||
_marko_template._ = _marko_renderer(function (input, out, _componentDef, _component, state, $global) { | ||
out.be("svg", { | ||
"version": "1.1", | ||
"xmlns": "http://www.w3.org/2000/svg", | ||
"xmlns:xlink": "http://www.w3.org/1999/xlink", | ||
"xml:space": "preserve" | ||
}, "0", _component, null, 0); | ||
out.e("use", { | ||
"xlink:href": "#test" | ||
}, "1", _component, 0, 0); | ||
out.ee(); | ||
}, { | ||
t: _marko_componentType, | ||
i: true, | ||
d: true | ||
}, _marko_component); | ||
import _marko_defineComponent from "marko/src/runtime/components/defineComponent.js"; | ||
_marko_template.Component = _marko_defineComponent(_marko_component, _marko_template._); |
16 changes: 16 additions & 0 deletions
16
tests/fixtures-class/namespaced-attr-native-tag/__snapshots__/html.expected.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Write | ||
<svg version=1.1 xmlns=http://www.w3.org/2000/svg xmlns:xlink=http://www.w3.org/1999/xlink xml:space=preserve><use xlink:href=#test /></svg> | ||
|
||
# Render | ||
```html | ||
<svg | ||
version="1.1" | ||
xml:space="preserve" | ||
xmlns="http://www.w3.org/2000/svg" | ||
xmlns:xlink="http://www.w3.org/1999/xlink" | ||
> | ||
<use | ||
xlink:href="#test" | ||
/> | ||
</svg> | ||
``` |
15 changes: 15 additions & 0 deletions
15
tests/fixtures-class/namespaced-attr-native-tag/__snapshots__/html.expected/template.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { t as _t } from "marko/src/runtime/html/index.js"; | ||
const _marko_componentType = "<fixture-dir>/template.marko", | ||
_marko_template = _t(_marko_componentType); | ||
export default _marko_template; | ||
import _marko_renderer from "marko/src/runtime/components/renderer.js"; | ||
const _marko_component = {}; | ||
_marko_template._ = _marko_renderer(function (input, out, _componentDef, _component, state, $global) { | ||
out.w("<svg version=1.1 xmlns=http://www.w3.org/2000/svg xmlns:xlink=http://www.w3.org/1999/xlink xml:space=preserve>"); | ||
out.w("<use xlink:href=#test />"); | ||
out.w("</svg>"); | ||
}, { | ||
t: _marko_componentType, | ||
i: true, | ||
d: true | ||
}, _marko_component); |
13 changes: 13 additions & 0 deletions
13
tests/fixtures-class/namespaced-attr-native-tag/__snapshots__/hydrate.expected.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Render | ||
```html | ||
<svg | ||
version="1.1" | ||
xml:space="preserve" | ||
xmlns="http://www.w3.org/2000/svg" | ||
xmlns:xlink="http://www.w3.org/1999/xlink" | ||
> | ||
<use | ||
xlink:href="#test" | ||
/> | ||
</svg> | ||
``` |
3 changes: 3 additions & 0 deletions
3
tests/fixtures-class/namespaced-attr-native-tag/template.marko
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve"> | ||
<use xlink:href="#test" /> | ||
</svg> |