File tree Expand file tree Collapse file tree 2 files changed +30
-6
lines changed Expand file tree Collapse file tree 2 files changed +30
-6
lines changed Original file line number Diff line number Diff line change @@ -1644,22 +1644,27 @@ function ImportedElement({ model }) {
1644
1644
}
1645
1645
}
1646
1646
1647
- function RenderImportedElement ( ) {
1647
+ function RenderImportedElement ( { model , importSource } ) {
1648
1648
react . useContext ( LayoutConfigContext ) ;
1649
1649
const mountPoint = react . useRef ( null ) ;
1650
1650
const sourceBinding = react . useRef ( null ) ;
1651
1651
1652
1652
react . useEffect ( ( ) => {
1653
1653
sourceBinding . current = importSource . bind ( mountPoint . current ) ;
1654
- return ( ) => {
1655
- sourceBinding . current . unmount ( ) ;
1656
- } ;
1654
+ if ( ! importSource . data . unmountBeforeUpdate ) {
1655
+ return sourceBinding . current . unmount ;
1656
+ }
1657
1657
} , [ ] ) ;
1658
1658
1659
1659
// this effect must run every time in case the model has changed
1660
- react . useEffect ( ( ) => sourceBinding . current . render ( model ) ) ;
1661
-
1660
+ react . useEffect ( ( ) => {
1661
+ sourceBinding . current . render ( model ) ;
1662
+ if ( importSource . data . unmountBeforeUpdate ) {
1663
+ return sourceBinding . current . unmount ;
1664
+ }
1665
+ } ) ;
1662
1666
1667
+ return html `< div ref =${ mountPoint } / > ` ;
1663
1668
}
1664
1669
1665
1670
function elementChildren ( modelChildren ) {
@@ -1717,6 +1722,7 @@ function loadImportSource$1(config, importSource) {
1717
1722
. then ( ( module ) => {
1718
1723
if ( typeof module . bind == "function" ) {
1719
1724
return {
1725
+ data : importSource ,
1720
1726
bind : ( node ) => {
1721
1727
const binding = module . bind ( node , config ) ;
1722
1728
if (
Original file line number Diff line number Diff line change 4
4
import responses
5
5
6
6
from idom .web .utils import (
7
+ module_name_suffix ,
7
8
resolve_module_exports_from_file ,
8
9
resolve_module_exports_from_source ,
9
10
resolve_module_exports_from_url ,
13
14
JS_FIXTURES_DIR = Path (__file__ ).parent / "js_fixtures"
14
15
15
16
17
+ @pytest .mark .parametrize (
18
+ "name, suffix" ,
19
+ [
20
+ ("module" , ".js" ),
21
+ ("module.ext" , ".ext" ),
22
+ ("module@x.y.z" , ".js" ),
23
+ ("module.ext@x.y.z" , ".ext" ),
24
+ ("@namespace/module" , ".js" ),
25
+ ("@namespace/module.ext" , ".ext" ),
26
+ ("@namespace/module@x.y.z" , ".js" ),
27
+ ("@namespace/module.ext@x.y.z" , ".ext" ),
28
+ ],
29
+ )
30
+ def test_module_name_suffix (name , suffix ):
31
+ assert module_name_suffix (name ) == suffix
32
+
33
+
16
34
@responses .activate
17
35
def test_resolve_module_exports_from_file (caplog ):
18
36
responses .add (
You can’t perform that action at this time.
0 commit comments