diff --git a/packages/@react-facet/dom-fiber/src/setupHostConfig.spec.tsx b/packages/@react-facet/dom-fiber/src/setupHostConfig.spec.tsx
index 500e1b3b..3ae5a67a 100644
--- a/packages/@react-facet/dom-fiber/src/setupHostConfig.spec.tsx
+++ b/packages/@react-facet/dom-fiber/src/setupHostConfig.spec.tsx
@@ -128,6 +128,17 @@ describe('mount', () => {
})
describe('for svg', () => {
+ it('renders foreignObject and sets dimensions', () => {
+ render(
+ ,
+ )
+ expect(root?.innerHTML ?? '').toBe(
+ '',
+ )
+ })
+
it('sets the d', () => {
render()
expect(root?.innerHTML ?? '').toBe('')
@@ -517,6 +528,22 @@ describe('mount', () => {
})
describe('for svg', () => {
+ it('renders foreignObject and sets dimensions', () => {
+ const xFacet = createFacet({ initialValue: '50' })
+ const yFacet = createFacet({ initialValue: '100' })
+ const widthFacet = createFacet({ initialValue: '150' })
+ const heightFacet = createFacet({ initialValue: '200' })
+
+ render(
+ ,
+ )
+ expect(root?.innerHTML ?? '').toBe(
+ '',
+ )
+ })
+
it('sets the d', () => {
const dFacet = createFacet({ initialValue: 'M0,0 L0,10 Z' })
@@ -1213,6 +1240,48 @@ describe('update', () => {
})
describe('for svg', () => {
+ it('updates foreignObject dimensions', () => {
+ const MockComponent = () => {
+ const [xFacet, setXFacet] = useState('50')
+ const [yFacet, setYFacet] = useState('100')
+ const [widthFacet, setWidthFacet] = useState('150')
+ const [heightFacet, setHeightFacet] = useState('200')
+
+ useEffect(() => {
+ setTimeout(() => setXFacet('350'), 1)
+ setTimeout(() => setYFacet('400'), 2)
+ setTimeout(() => setWidthFacet('450'), 3)
+ setTimeout(() => setHeightFacet('500'), 4)
+ }, [])
+ return (
+
+ )
+ }
+
+ render()
+ expect(root?.innerHTML ?? '').toBe(
+ '',
+ )
+ jest.advanceTimersByTime(1)
+ expect(root?.innerHTML ?? '').toBe(
+ '',
+ )
+ jest.advanceTimersByTime(1)
+ expect(root?.innerHTML ?? '').toBe(
+ '',
+ )
+ jest.advanceTimersByTime(1)
+ expect(root?.innerHTML ?? '').toBe(
+ '',
+ )
+ jest.advanceTimersByTime(1)
+ expect(root?.innerHTML ?? '').toBe(
+ '',
+ )
+ })
+
it('updates d', () => {
const MockComponent = () => {
const [d, setD] = useState('M0,0 L0,10 Z')
diff --git a/packages/@react-facet/dom-fiber/src/setupHostConfig.ts b/packages/@react-facet/dom-fiber/src/setupHostConfig.ts
index 0eee5f40..ee74f965 100644
--- a/packages/@react-facet/dom-fiber/src/setupHostConfig.ts
+++ b/packages/@react-facet/dom-fiber/src/setupHostConfig.ts
@@ -1112,6 +1112,7 @@ const fastTypeMapSVG: Record = {
'fast-path': 'path',
'fast-rect': 'rect',
'fast-svg': 'svg',
+ 'fast-foreignObject': 'foreignObject',
'fast-use': 'use',
'fast-polyline': 'polyline',
'fast-polygon': 'polygon',
@@ -1127,6 +1128,7 @@ const fastTypeMapSVG: Record = {
path: 'path',
rect: 'rect',
svg: 'svg',
+ foreignObject: 'foreignObject',
symbol: 'symbol',
g: 'g',
use: 'use',
diff --git a/packages/@react-facet/dom-fiber/src/types.ts b/packages/@react-facet/dom-fiber/src/types.ts
index b2b1acce..65f2a9c4 100644
--- a/packages/@react-facet/dom-fiber/src/types.ts
+++ b/packages/@react-facet/dom-fiber/src/types.ts
@@ -28,6 +28,7 @@ export type TypeSVG =
| 'fast-path'
| 'fast-rect'
| 'fast-svg'
+ | 'fast-foreignObject'
| 'fast-use'
| 'fast-polyline'
| 'fast-polygon'
@@ -50,6 +51,7 @@ export type TypeSVG =
| 'polygon'
| 'linearGradient'
| 'radialGradient'
+ | 'foreignObject'
| 'stop'
| 'text'
| 'pattern'
@@ -289,6 +291,7 @@ export type FastPathProps = ElementProps
export type FastRectProps = ElementProps
export type FastSpanProps = ElementProps
export type FastSvgProps = ElementProps
+export type FastForeignOBjectProps = ElementProps
export type FastTextProps = TextProps
export type FastUseProps = ElementProps
export type FastPolylineProps = ElementProps
@@ -320,6 +323,7 @@ declare global {
'fast-span': FastSpanProps
'fast-text': FastTextProps
'fast-svg': FastSvgProps
+ 'fast-foreignObject': FastForeignOBjectProps
'fast-use': FastUseProps
'fast-polyline': FastPolylineProps
'fast-polygon': FastPolyGonProps