vaderjs 1.9.0 → 1.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +13 -7
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -140,7 +140,7 @@ export const e = (element, props, ...children) => {
|
|
|
140
140
|
return instance.render(props);
|
|
141
141
|
case typeof element === "function":
|
|
142
142
|
instance = memoizeClassComponent(Component, element.name);
|
|
143
|
-
element = element.bind(instance);
|
|
143
|
+
element = element.bind(instance);
|
|
144
144
|
instance.render = (props) => element(props);
|
|
145
145
|
if (element.name.toLowerCase() == "default") {
|
|
146
146
|
throw new Error("Function name must be unique");
|
|
@@ -153,6 +153,7 @@ export const e = (element, props, ...children) => {
|
|
|
153
153
|
firstEl = { type: "div", props: { key: instance.key, ...props }, children };
|
|
154
154
|
firstEl.props = { key: instance.key, ...firstEl.props, ...props };
|
|
155
155
|
firstEl.props["idKey"] = instance.key;
|
|
156
|
+
instance.props = firstEl.props;
|
|
156
157
|
return firstEl;
|
|
157
158
|
default:
|
|
158
159
|
let el = { type: element, props: props || {}, children: children || [] };
|
|
@@ -185,8 +186,8 @@ interface SwitchProps {
|
|
|
185
186
|
// make children optional
|
|
186
187
|
export function Switch({ children = [] }: SwitchProps) {
|
|
187
188
|
for (let child of children) {
|
|
188
|
-
if (child
|
|
189
|
-
return child
|
|
189
|
+
if (child.props.when) {
|
|
190
|
+
return child
|
|
190
191
|
}
|
|
191
192
|
}
|
|
192
193
|
return { type: "div", props: {}, children: [] };
|
|
@@ -620,9 +621,13 @@ export class Component {
|
|
|
620
621
|
const handler = attributes[key];
|
|
621
622
|
this.eventRegistry.set(el, [...(this.eventRegistry.get(el) || []), { event: eventType, handler }]);
|
|
622
623
|
this.addEventListener(el, eventType, handler);
|
|
623
|
-
} else if (attributes[key] !== null && attributes[key] !== undefined
|
|
624
|
-
|
|
625
|
-
|
|
624
|
+
} else if (attributes[key] !== null && attributes[key] !== undefined &&
|
|
625
|
+
!key.includes(" ") || !key.includes("-") || !key.includes("_")) {
|
|
626
|
+
try {
|
|
627
|
+
el.setAttribute(key, attributes[key]);
|
|
628
|
+
} catch (error) {
|
|
629
|
+
|
|
630
|
+
}
|
|
626
631
|
}
|
|
627
632
|
}
|
|
628
633
|
|
|
@@ -636,7 +641,7 @@ export class Component {
|
|
|
636
641
|
// Handle functional components
|
|
637
642
|
let component = memoizeClassComponent(Component, child.name);
|
|
638
643
|
component.Mounted = true;
|
|
639
|
-
component.render = child;
|
|
644
|
+
component.render = (props) => child(props);
|
|
640
645
|
let componentElement = component.toElement();
|
|
641
646
|
el.appendChild(componentElement);
|
|
642
647
|
} else if (typeof child === "object") {
|
|
@@ -703,6 +708,7 @@ export function render(element, container) {
|
|
|
703
708
|
let memoizedInstance = memoizeClassComponent(Component, element.name);
|
|
704
709
|
memoizedInstance.Mounted = true;
|
|
705
710
|
element = element.bind(memoizedInstance);
|
|
711
|
+
|
|
706
712
|
memoizedInstance.render = (props) => element(props);
|
|
707
713
|
if (element.name == "default") {
|
|
708
714
|
throw new Error("Function name Must be a unique function name as it is used for a element key");
|