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 CHANGED
@@ -1,4 +1,5 @@
1
- export type { Element, ElementProps, ElementChild, DevElement } from './types';
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
- import type { Element } from './types';
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 function jsxDEV(type: string | Function, props: ElementProps, key?: string, isStaticChildren?: boolean, source?: {
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;
@@ -1,4 +1,5 @@
1
1
  const ELEMENT_TYPE = Symbol.for('your.framework.element');
2
+ export const Fragment = Symbol.for('your.framework.fragment');
2
3
  export function jsxDEV(type, props, key, isStaticChildren, source, self) {
3
4
  return {
4
5
  $$typeof: ELEMENT_TYPE,
@@ -1,3 +1,4 @@
1
1
  import type { Element, ElementProps } from './types';
2
- export declare function jsx(type: string | Function, props: ElementProps, key?: string): Element;
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;
@@ -1,4 +1,5 @@
1
1
  const ELEMENT_TYPE = Symbol.for('your.framework.element');
2
+ export const Fragment = Symbol.for('your.framework.fragment');
2
3
  export function jsx(type, props, key) {
3
4
  return {
4
5
  $$typeof: ELEMENT_TYPE,
package/dist/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export interface Element {
2
2
  $$typeof: symbol;
3
- type: string | Function;
3
+ type: string | Function | symbol;
4
4
  props: ElementProps;
5
5
  key: string | null;
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsx-framework-test-pb",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",