Repository navigation
4th overload (name, ...children) is not working as expected #16
Copy link
Copy link
Closed as not planned
Labels
👎 phase/noPost cannot or will not be acted onPost cannot or will not be acted on🙋 no/questionThis does not need any changesThis does not need any changes
Description
Activity
- added👋 phase/newPost is being triaged automaticallyPost is being triaged automatically🤞 phase/openPost is being triaged manuallyPost is being triaged manuallyand removed👋 phase/newPost is being triaged automaticallyPost is being triaged automatically
on Oct 10, 2026 It's matched as
attributeswhich is expected.See also
Lines 150 to 161 in c1b6eca
function isAttributes(value) { if ( value === null || value === undefined || typeof value !== 'object' || Array.isArray(value) ) { return false } return true } So you can try array instead.
import { x } from "xastscript"; const ast = x("foo", [x("bar", "baz")]); console.log(JSON.stringify(ast, null, 2));
github-actions commented
on Oct 10, 2026 on Oct 10, 2026 – with GitHub Actions · Hidden as resolvedshow commentMore actions- added🙋 no/questionThis does not need any changesThis does not need any changes
on Oct 10, 2026 - added👎 phase/noPost cannot or will not be acted onPost cannot or will not be acted onand removed🤞 phase/openPost is being triaged manuallyPost is being triaged manually
on Oct 10, 2026 @JounQin then the TS type needs to be updated if this is not supported
From
(name: string, ...children: Array<Child>): Elementto(name: string, children: Array<Child>): Elementmaybe?@GauBen No, it's just
(name: string, attributes?: Attributes, ...children: Array<Child>): Elementbeen matched.x("bar", "baz")matchesAttributes, it's hard to distinguish a singleChildvsAttributesat runtime.
Metadata
Metadata
Assignees
Labels
👎 phase/noPost cannot or will not be acted onPost cannot or will not be acted on🙋 no/questionThis does not need any changesThis does not need any changes
Initial checklist
Affected package
xastscript
Steps to reproduce
Hi!
This overload:
xastscript/lib/index.js
Line 57 in c1b6eca
is not working as expected
Actual behavior
{ "type": "element", "name": "foo", "attributes": { "type": "element", "name": "bar", "attributes": "[object Object]", "children": "[object Object]" }, "children": [] }Expected behavior
{ "type": "element", "name": "foo", "attributes": {}, "children": [ { "type": "element", "name": "bar", "attributes": {}, "children": [ { "type": "text", "value": "baz" } ] } ] }Runtime
No response
Package manager
No response
Operating system
No response
Build and bundle tools
No response