jsx-framework-test-pb 0.0.2 → 0.0.3
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/dist/index.d.ts +3 -2
- package/dist/index.js +15 -0
- package/dist/jsx-dev-runtime.d.ts +2 -1
- package/dist/jsx-dev-runtime.js +1 -0
- package/dist/jsx-runtime.d.ts +2 -1
- package/dist/jsx-runtime.js +1 -0
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Element } from './types';
|
|
2
2
|
export declare function isElement(value: any): value is Element;
|
|
3
3
|
export declare function render(element: any, container: HTMLElement): void;
|
|
4
|
-
|
|
4
|
+
export type { Element, ElementProps, ElementChild } from './types';
|
|
5
|
+
export { Fragment } from './jsx-runtime';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const ELEMENT_TYPE = Symbol.for('your.framework.element');
|
|
2
|
+
const FRAGMENT_TYPE = Symbol.for('your.framework.fragment');
|
|
2
3
|
export function isElement(value) {
|
|
3
4
|
return value && value.$$typeof === ELEMENT_TYPE;
|
|
4
5
|
}
|
|
@@ -31,6 +32,19 @@ function createElement(element) {
|
|
|
31
32
|
return null;
|
|
32
33
|
}
|
|
33
34
|
const { type, props } = element;
|
|
35
|
+
if (type === FRAGMENT_TYPE) {
|
|
36
|
+
const fragment = document.createDocumentFragment();
|
|
37
|
+
const children = Array.isArray(props.children)
|
|
38
|
+
? props.children
|
|
39
|
+
: [props.children];
|
|
40
|
+
children.forEach(child => {
|
|
41
|
+
const childNode = createElement(child);
|
|
42
|
+
if (childNode) {
|
|
43
|
+
fragment.appendChild(childNode);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return fragment;
|
|
47
|
+
}
|
|
34
48
|
if (typeof type === 'function') {
|
|
35
49
|
const result = type(props);
|
|
36
50
|
return createElement(result);
|
|
@@ -67,3 +81,4 @@ function createElement(element) {
|
|
|
67
81
|
}
|
|
68
82
|
return null;
|
|
69
83
|
}
|
|
84
|
+
export { Fragment } from './jsx-runtime';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DevElement, ElementProps } from './types';
|
|
2
|
-
export declare
|
|
2
|
+
export declare const Fragment: unique symbol;
|
|
3
|
+
export declare function jsxDEV(type: string | Function | symbol, props: ElementProps, key?: string, isStaticChildren?: boolean, source?: {
|
|
3
4
|
fileName: string;
|
|
4
5
|
lineNumber: number;
|
|
5
6
|
columnNumber: number;
|
package/dist/jsx-dev-runtime.js
CHANGED
package/dist/jsx-runtime.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { Element, ElementProps } from './types';
|
|
2
|
-
export declare
|
|
2
|
+
export declare const Fragment: unique symbol;
|
|
3
|
+
export declare function jsx(type: string | Function | symbol, props: ElementProps, key?: string): Element;
|
|
3
4
|
export declare const jsxs: typeof jsx;
|
package/dist/jsx-runtime.js
CHANGED
package/dist/types.d.ts
CHANGED