File tree 3 files changed +62
-1
lines changed
sap/ui/webcomponents/main/pages/base
3 files changed +62
-1
lines changed Original file line number Diff line number Diff line change @@ -85,10 +85,12 @@ class UI5Element extends HTMLElement {
85
85
return ;
86
86
}
87
87
88
+ // always register the observer before yielding control to the main thread (await)
89
+ this . _startObservingDOMChildren ( ) ;
90
+
88
91
await this . _processChildren ( ) ;
89
92
await RenderScheduler . renderImmediately ( this ) ;
90
93
this . _domRefReadyPromise . _deferredResolve ( ) ;
91
- this . _startObservingDOMChildren ( ) ;
92
94
if ( typeof this . onEnterDOM === "function" ) {
93
95
this . onEnterDOM ( ) ;
94
96
}
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+
4
+ < head >
5
+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge ">
6
+ < meta charset ="utf-8 ">
7
+
8
+ < title > DOMObserver</ title >
9
+ < meta name ="viewport " content ="width=device-width, initial-scale=1 ">
10
+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge ">
11
+ < meta charset ="utf-8 ">
12
+
13
+ < script src ="../../../../../../../webcomponentsjs/webcomponents-loader.js "> </ script >
14
+ < script src ="../../../../../../../resources/sap/ui/webcomponents/main/bundle.esm.js " type ="module "> </ script >
15
+ < script nomodule src ="../../../../../../../resources/sap/ui/webcomponents/main/bundle.es5.js "> </ script >
16
+
17
+ </ head >
18
+
19
+ < body >
20
+
21
+ </ body >
22
+
23
+ </ html >
Original file line number Diff line number Diff line change
1
+ const assert = require ( "chai" ) . assert ;
2
+
3
+ describe ( "DOMObserver" , ( ) => {
4
+ browser . url ( "http://localhost:8080/test-resources/sap/ui/webcomponents/main/pages/base/DOMObserver.html" ) ;
5
+
6
+ it ( "insertion order still fires DOMObserver" , ( ) => {
7
+
8
+ // prepare the table
9
+ browser . execute ( ( ) => {
10
+ const table = document . createElement ( "ui5-table" ) ;
11
+ const col1 = document . createElement ( "ui5-table-column" ) ;
12
+ col1 . slot = "columns" ;
13
+ col1 . appendChild ( document . createTextNode ( "Column 1" ) ) ;
14
+ table . appendChild ( col1 ) ;
15
+ document . body . appendChild ( table ) ;
16
+ } ) ;
17
+
18
+ // execute
19
+ browser . execute ( ( ) => {
20
+ const table = document . querySelector ( "ui5-table" ) ;
21
+ const row1 = document . createElement ( "ui5-table-row" ) ;
22
+ // adding a row calls its connectedCallback, but there are async steps so the cell bellow should always trigger its mutationObserver
23
+ table . appendChild ( row1 ) ;
24
+
25
+ // add the cell synchronously after the row's connectedCallback
26
+ const cell1 = document . createElement ( "ui5-table-cell" ) ;
27
+ cell1 . appendChild ( document . createTextNode ( "Cell 1" ) ) ;
28
+ row1 . appendChild ( cell1 ) ;
29
+ } )
30
+
31
+ // assert
32
+ const slots = browser . $ ( "ui5-table-row" ) . shadow$$ ( "slot" ) ;
33
+ // the cell should have triggered the DOM mutation observer and a slot should be rendered in the row
34
+ assert . equal ( slots . length , 1 , "expected 1 slot in the ui5-table-row shadow DOM" ) ;
35
+ } ) ;
36
+ } ) ;
You can’t perform that action at this time.
0 commit comments