@@ -382,7 +389,7 @@ describe('Portal spec', () => {
});
it('should reconcile portal children', () => {
- let portalContainer = document.createElement('div');
+ const portalContainer = document.createElement('div');
render(
{createPortal(
portal:1
, portalContainer)}
, container);
expect(portalContainer.innerHTML).toBe('
portal:1
');
@@ -592,22 +599,22 @@ describe('Portal spec', () => {
});
it('should pass portal context when rendering subtree elsewhere', () => {
- let portalContainer = document.createElement('div');
+ const portalContainer = document.createElement('div');
class Comp extends Component {
- render() {
+ public render() {
return
{this.context.foo}
;
}
}
class Parent extends Component {
- getChildContext() {
+ public getChildContext() {
return {
foo: 'bar'
};
}
- render() {
+ public render() {
return createPortal(
, portalContainer);
}
}
@@ -618,31 +625,31 @@ describe('Portal spec', () => {
});
it('should update portal context if it changes due to setState', () => {
- let portalContainer = document.createElement('div');
+ const portalContainer = document.createElement('div');
class Comp extends Component {
- render() {
+ public render() {
return
{this.context.foo + '-' + this.context.getFoo()}
;
}
}
class Parent extends Component {
- state = {
+ public state = {
bar: 'initial'
};
- getChildContext() {
+ public getChildContext() {
return {
foo: this.state.bar,
getFoo: () => this.state.bar
};
}
- render() {
+ public render() {
return createPortal(
, portalContainer);
}
}
- let instance = render(
, container);
+ const instance = render(
, container);
expect(portalContainer.innerHTML).toBe('
initial-initial
');
expect(container.innerHTML).toBe('');
@@ -658,23 +665,27 @@ describe('Portal spec', () => {
});
it('should update portal context if it changes due to re-render', () => {
- let portalContainer = document.createElement('div');
+ const portalContainer = document.createElement('div');
class Comp extends Component {
- render() {
+ public render() {
return
{this.context.foo + '-' + this.context.getFoo()}
;
}
}
- class Parent extends Component {
- getChildContext() {
+ interface ParentProps {
+ bar: string
+ }
+
+ class Parent extends Component
{
+ public getChildContext() {
return {
foo: this.props.bar,
getFoo: () => this.props.bar
};
}
- render() {
+ public render() {
return createPortal(, portalContainer);
}
}
@@ -693,21 +704,25 @@ describe('Portal spec', () => {
});
it('should update portal context if it changes due to re-render - functional comps', () => {
- let portalContainer = document.createElement('div');
+ const portalContainer = document.createElement('div');
- function Comp(props, { foo, getFoo }) {
+ function Comp(_, { foo, getFoo }) {
return {foo + '-' + getFoo()}
;
}
- class Parent extends Component {
- getChildContext() {
+ interface ParentProps {
+ bar: string
+ }
+
+ class Parent extends Component {
+ public getChildContext() {
return {
foo: this.props.bar,
getFoo: () => this.props.bar
};
}
- render() {
+ public render() {
return createPortal(, portalContainer);
}
}
@@ -726,7 +741,7 @@ describe('Portal spec', () => {
});
it('should update portal context if it changes due to re-render - functional comps #2', () => {
- let portalContainer = document.createElement('div');
+ const portalContainer = document.createElement('div');
function Comp({ foo }) {
return {foo}
;
@@ -751,7 +766,7 @@ describe('Portal spec', () => {
describe('Changing portal to other type of vNode', () => {
it('Should remove portal from its container when its replaced by div', () => {
- let portalContainer = document.createElement('div');
+ const portalContainer = document.createElement('div');
function Comp({ foo }) {
return {foo}
;
@@ -787,10 +802,10 @@ describe('Portal spec', () => {
});
it('Should remove portal from its container when its replaced by class component', () => {
- let portalContainer = document.createElement('div');
+ const portalContainer = document.createElement('div');
class Comp extends Component {
- render({ children }) {
+ public render({ children }) {
return {children}
;
}
}
@@ -829,7 +844,7 @@ describe('Portal spec', () => {
});
it('Should remove portal from its container when its replaced by functional component', () => {
- let portalContainer = document.createElement('div');
+ const portalContainer = document.createElement('div');
function Comp({ children }) {
return {children}
;
@@ -869,7 +884,7 @@ describe('Portal spec', () => {
});
it('Should remove portal from its container when its replaced by invalid node', () => {
- let portalContainer = document.createElement('div');
+ const portalContainer = document.createElement('div');
function Comp({ children }) {
return {children}
;
@@ -906,21 +921,21 @@ describe('Portal spec', () => {
describe('Multiple portals', () => {
it('#1', () => {
- let portalContainer = document.createElement('div');
+ const portalContainer = document.createElement('div');
let mountCount = 0;
let unMountCount = 0;
class Comp extends Component {
- componentWillMount() {
+ public componentWillMount() {
mountCount++;
}
- componentWillUnmount() {
+ public componentWillUnmount() {
unMountCount++;
}
- render({ children }) {
+ public render({ children }) {
return {children}
;
}
}
@@ -941,19 +956,19 @@ describe('Portal spec', () => {
return {innerContent}
;
}
- render(, container);
+ render(, container);
expect(portalContainer.innerHTML).toBe('');
expect(container.innerHTML).toBe('');
expect(mountCount).toBe(0);
expect(unMountCount).toBe(0);
- render(, container);
+ render(, container);
expect(portalContainer.innerHTML).toBe('1
2
3
');
expect(container.innerHTML).toBe('');
expect(mountCount).toBe(3);
expect(unMountCount).toBe(0);
- render(, container);
+ render(, container);
expect(portalContainer.innerHTML).toBe('');
expect(container.innerHTML).toBe('');
expect(mountCount).toBe(3);
@@ -967,26 +982,26 @@ describe('Portal spec', () => {
});
it('#2', () => {
- let portalContainer = document.createElement('div');
+ const portalContainer = document.createElement('div');
let mountCount = 0;
let unMountCount = 0;
class Comp extends Component {
- componentWillMount() {
+ public componentWillMount() {
mountCount++;
}
- componentWillUnmount() {
+ public componentWillUnmount() {
unMountCount++;
}
- render({ children }) {
+ public render({ children }) {
return {children}
;
}
}
- function Parent({ port, nothing }) {
+ function Parent({ port, nothing }: { port?: boolean, nothing?: boolean}) {
let innerContent;
if (!nothing) {
@@ -1008,19 +1023,19 @@ describe('Portal spec', () => {
return {innerContent}
;
}
- render(, container);
+ render(, container);
expect(portalContainer.innerHTML).toBe('');
expect(container.innerHTML).toBe('');
expect(mountCount).toBe(0);
expect(unMountCount).toBe(0);
- render(, container);
+ render(, container);
expect(portalContainer.innerHTML).toBe('1
2
3
');
expect(container.innerHTML).toBe('');
expect(mountCount).toBe(3);
expect(unMountCount).toBe(0);
- render(, container);
+ render(, container);
expect(portalContainer.innerHTML).toBe('1
3
5
');
expect(container.innerHTML).toBe('');
expect(mountCount).toBe(4); // 5 is new
@@ -1034,26 +1049,26 @@ describe('Portal spec', () => {
});
it('Should be possible to move nodes around portals #1', () => {
- let portalContainer = document.createElement('div');
+ const portalContainer = document.createElement('div');
let mountCount = 0;
let unMountCount = 0;
class Comp extends Component {
- componentWillMount() {
+ public componentWillMount() {
mountCount++;
}
- componentWillUnmount() {
+ public componentWillUnmount() {
unMountCount++;
}
- render({ children }) {
+ public render({ children }) {
return {children}
;
}
}
- function Parent({ port, nothing }) {
+ function Parent({ port }: { port?: boolean}) {
let innerContent;
if (port) {
@@ -1079,13 +1094,13 @@ describe('Portal spec', () => {
return {innerContent}
;
}
- render(, container);
+ render(, container);
expect(container.innerHTML).toBe('abc
');
expect(portalContainer.innerHTML).toBe('1
2
3
');
expect(mountCount).toBe(3);
expect(unMountCount).toBe(0);
- render(, container);
+ render(, container);
expect(portalContainer.innerHTML).toBe('1
3
5
');
expect(container.innerHTML).toBe('cab
');
expect(mountCount).toBe(4);
@@ -1099,26 +1114,26 @@ describe('Portal spec', () => {
});
it('Should be possible to move nodes around portals #2', () => {
- let portalContainer = document.createElement('div');
+ const portalContainer = document.createElement('div');
let mountCount = 0;
let unMountCount = 0;
class Comp extends Component {
- componentWillMount() {
+ public componentWillMount() {
mountCount++;
}
- componentWillUnmount() {
+ public componentWillUnmount() {
unMountCount++;
}
- render({ children }) {
+ public render({ children }) {
return {children}
;
}
}
- function Parent({ port, nothing }) {
+ function Parent({ port }: { port?: boolean }) {
let innerContent;
if (port) {
@@ -1160,27 +1175,27 @@ describe('Portal spec', () => {
});
it('Should be possible to move nodes around portals when portal is root node of component #1', () => {
- let portalContainer = document.createElement('div');
+ const portalContainer = document.createElement('div');
let mountCount = 0;
let unMountCount = 0;
class WrapPortal extends Component {
- render({ children }) {
+ public render({ children }) {
return createPortal({children}, portalContainer);
}
}
class Comp extends Component {
- componentWillMount() {
+ public componentWillMount() {
mountCount++;
}
- componentWillUnmount() {
+ public componentWillUnmount() {
unMountCount++;
}
- render({ children }) {
+ public render({ children }) {
return {children}
;
}
}
@@ -1231,27 +1246,27 @@ describe('Portal spec', () => {
});
it('Should be possible to move nodes around portals when portal is root node of component #2', () => {
- let portalContainer = document.createElement('div');
+ const portalContainer = document.createElement('div');
let mountCount = 0;
let unMountCount = 0;
class WrapPortal extends Component {
- render({ children }) {
+ public render({ children }) {
return createPortal({children}, portalContainer);
}
}
class Comp extends Component {
- componentWillMount() {
+ public componentWillMount() {
mountCount++;
}
- componentWillUnmount() {
+ public componentWillUnmount() {
unMountCount++;
}
- render({ children }) {
+ public render({ children }) {
return {children}
;
}
}
@@ -1316,27 +1331,27 @@ describe('Portal spec', () => {
});
it('Should be possible to patch portal non keyed', () => {
- let portalContainer = document.createElement('div');
+ const portalContainer = document.createElement('div');
let mountCount = 0;
let unMountCount = 0;
class WrapPortal extends Component {
- render({ children }) {
+ public render({ children }) {
return createPortal({children}, portalContainer);
}
}
class Comp extends Component {
- componentWillMount() {
+ public componentWillMount() {
mountCount++;
}
- componentWillUnmount() {
+ public componentWillUnmount() {
unMountCount++;
}
- render({ children }) {
+ public render({ children }) {
return {children}
;
}
}
@@ -1392,6 +1407,9 @@ describe('Portal spec', () => {
render(null, container);
expect(portalContainer.innerHTML).toBe('');
expect(container.innerHTML).toBe('');
+
+ expect(mountCount).toBe(12)
+ expect(unMountCount).toBe(12)
});
});
});
diff --git a/packages/inferno/src/core/types.ts b/packages/inferno/src/core/types.ts
index 23c5a6a98..e5d318e0c 100644
--- a/packages/inferno/src/core/types.ts
+++ b/packages/inferno/src/core/types.ts
@@ -2181,6 +2181,37 @@ declare global {
tspan: Inferno.SVGProps;
use: Inferno.SVGProps;
view: Inferno.SVGProps;
+
+ // MathML
+ maction: Inferno.DetailedHTMLProps, MathMLElement>;
+ math: Inferno.DetailedHTMLProps, MathMLElement>;
+ menclose: Inferno.DetailedHTMLProps, MathMLElement>;
+ merror: Inferno.DetailedHTMLProps, MathMLElement>;
+ mfenced: Inferno.DetailedHTMLProps, MathMLElement>;
+ mfrac: Inferno.DetailedHTMLProps, MathMLElement>;
+ mi: Inferno.DetailedHTMLProps, MathMLElement>;
+ mmultiscripts: Inferno.DetailedHTMLProps, MathMLElement>;
+ mn: Inferno.DetailedHTMLProps, MathMLElement>;
+ mo: Inferno.DetailedHTMLProps, MathMLElement>;
+ mover: Inferno.DetailedHTMLProps, MathMLElement>;
+ mpadded: Inferno.DetailedHTMLProps, MathMLElement>;
+ mphantom: Inferno.DetailedHTMLProps, MathMLElement>;
+ mroot: Inferno.DetailedHTMLProps, MathMLElement>;
+ mrow: Inferno.DetailedHTMLProps, MathMLElement>;
+ ms: Inferno.DetailedHTMLProps, MathMLElement>;
+ mspace: Inferno.DetailedHTMLProps, MathMLElement>;
+ msqrt: Inferno.DetailedHTMLProps, MathMLElement>;
+ mstyle: Inferno.DetailedHTMLProps, MathMLElement>;
+ msub: Inferno.DetailedHTMLProps, MathMLElement>;
+ msubsup: Inferno.DetailedHTMLProps, MathMLElement>;
+ msup: Inferno.DetailedHTMLProps, MathMLElement>;
+ mtable: Inferno.DetailedHTMLProps, MathMLElement>;
+ mtd: Inferno.DetailedHTMLProps, MathMLElement>;
+ mtext: Inferno.DetailedHTMLProps, MathMLElement>;
+ mtr: Inferno.DetailedHTMLProps, MathMLElement>;
+ munder: Inferno.DetailedHTMLProps, MathMLElement>;
+ munderover: Inferno.DetailedHTMLProps, MathMLElement>;
+ semantics: Inferno.DetailedHTMLProps, MathMLElement>;
}
}
}