Skip to content

Commit 6e0e7e8

Browse files
committed
Fixes #108
1 parent c80a80d commit 6e0e7e8

File tree

7 files changed

+78
-67
lines changed

7 files changed

+78
-67
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 8.1.5
2+
- Fixes #108: Class components are now differentiated from functional components by `.isComponent` instead of `.prototype.isReactComponent`, fixing an issue with terser.
3+
4+
# 8.1.4
5+
- Fixes #104: Class Components do not populate their ref attribute.
6+
17
# 8.1.3
28
- Merged #101.
39

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jsx-dom",
3-
"version": "8.1.4",
3+
"version": "8.1.5",
44
"description": "JSX to document.createElement.",
55
"main": "index.js",
66
"module": "index.js",
@@ -25,7 +25,7 @@
2525
"build"
2626
],
2727
"resolutions": {
28-
"@babel/types": "^7.21.0"
28+
"@babel/types": "^7.25.4"
2929
},
3030
"devDependencies": {
3131
"@babel/core": "^7.25.2",

pnpm-lock.yaml

Lines changed: 44 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/jsx-dom.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,15 @@ export function Fragment(attr: { children: (JSX.Element | JSX.Element)[] }) {
118118
}
119119

120120
export class Component {
121+
static isComponent = true
122+
121123
constructor(readonly props: any) {}
122124

123125
render() {
124126
return null
125127
}
126128
}
127129

128-
/* @__PURE__ */ Object.defineProperties(Component.prototype, {
129-
isReactComponent: {
130-
value: true,
131-
},
132-
})
133-
134130
function initComponentClass(Class: ComponentClass, attr, children) {
135131
attr = { ...attr, children }
136132
const instance = new Class(attr)
@@ -208,7 +204,7 @@ export function attachRef<T = Node>(ref: any | undefined, node: T) {
208204
}
209205

210206
function appendChild(
211-
child: any[] | string | number | ShadowRootContainer | null | Element,
207+
child: any[] | string | number | ShadowRootContainer | null | Element | DocumentFragment,
212208
node: Node
213209
) {
214210
if (isArrayLike(child)) {

src/util.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ export function isFunction(val: any): val is Function {
3030
return typeof val === "function"
3131
}
3232

33-
export function isComponentClass(Component: Function): Component is ComponentClass {
34-
const { prototype } = Component
35-
return !!(prototype && prototype.isReactComponent)
33+
export function isComponentClass(
34+
Component: Function & { isComponent?: boolean }
35+
): Component is ComponentClass {
36+
return !!(Component && Component.isComponent)
3637
}
3738

3839
export function isArrayLike(obj: any): obj is ArrayLike<any> {

0 commit comments

Comments
 (0)