File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 4141 "@phosphor/virtualdom" : " ^1.2.0" ,
4242 "@phosphor/widgets" : " ^1.9.0" ,
4343 "react" : " ~16.8.4" ,
44+ "react-dom" : " ~16.8.4" ,
4445 "typestyle" : " ^2.0.1"
4546 },
4647 "devDependencies" : {
4748 "@types/react" : " ~16.8.18" ,
49+ "@types/react-dom" : " ^16.8.4" ,
4850 "@types/webpack-env" : " ^1.13.9" ,
4951 "rimraf" : " ~2.6.2" ,
5052 "typedoc" : " ^0.14.2" ,
Original file line number Diff line number Diff line change 11import React from 'react' ;
2+ import ReactDOM from 'react-dom' ;
23import { classes } from 'typestyle' ;
34import { iconStyle , IIconStyle } from '../style/icon' ;
45
@@ -10,10 +11,11 @@ export class JLIcon {
1011 ) { }
1112
1213 resolveSvg ( title ?: string ) : HTMLElement | null {
13- const svgElement = new DOMParser ( ) . parseFromString (
14+ const svgDoc = new DOMParser ( ) . parseFromString (
1415 this . svgstr ,
1516 'image/svg+xml'
16- ) . documentElement ;
17+ ) ;
18+ const svgElement = svgDoc . documentElement ;
1719
1820 if ( svgElement . getElementsByTagName ( 'parsererror' ) . length > 0 ) {
1921 const errmsg = `SVG HTML was malformed for icon name: ${ name } ` ;
@@ -61,6 +63,13 @@ export class JLIcon {
6163 return container ;
6264 }
6365
66+ phosphor ( props : JLIcon . IProps ) : JLIcon . IPhosphor {
67+ return {
68+ render : ( host : HTMLElement ) =>
69+ ReactDOM . render ( < this . react { ...props } /> , host )
70+ } ;
71+ }
72+
6473 protected _initReact ( ) {
6574 const component = React . forwardRef (
6675 (
@@ -124,6 +133,10 @@ export namespace JLIcon {
124133 */
125134 title ?: string ;
126135 }
136+
137+ export interface IPhosphor {
138+ render : ( host : HTMLElement ) => void ;
139+ }
127140}
128141
129142namespace Private {
You can’t perform that action at this time.
0 commit comments