Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion packages/utils.jsx/src/jsx.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

import { attr } from '@tko/binding.core/src/attr'
import {
isObservable, unwrap
} from '@tko/observable'
Expand Down Expand Up @@ -45,10 +46,21 @@ export function getOriginalJsxForNode (node) {
* @param {...string|object} c children of the element
*/
export function createElement (elementName, attributes, ...children) {
const internalAttributes = attributes || {};
if(internalAttributes.hasOwnProperty('children')) {
console.error(
"%s: `children` cannot be used as an attribute. It gets automatically bound to the child elements of this component. " +
"If you want to access the same value within the child component, you should pass it as a different attribute.",
elementName
);
}

internalAttributes.children = [...children] || []

return elementName === Fragment ? children
: {
elementName: elementName,
attributes: attributes || {},
attributes: internalAttributes,
children: [...children]
}
}
Expand Down