Prechádzať zdrojové kódy

Fix accessing of parent of disconnected node while listerning for new
components.

Also add test.

Pascal Thormeier 5 rokov pred
rodič
commit
debd6f0ed6
4 zmenil súbory, kde vykonal 3 pridanie a 3 odobranie
  1. 0 0
      dist/alpine.js
  2. 0 0
      dist/alpine.js.map
  3. 1 1
      src/index.js
  4. 2 2
      test/mutations.spec.js

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 0
dist/alpine.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 0
dist/alpine.js.map


+ 1 - 1
src/index.js

@@ -60,7 +60,7 @@ const Alpine = {
 
                         // Discard any changes happening within an existing component.
                         // They will take care of themselves.
-                        if (node.parentElement.closest('[x-data]')) return
+                        if (node.parentElement && node.parentElement.closest('[x-data]')) return
 
                         this.discoverUninitializedComponents((el) => {
                             this.initializeComponent(el)

+ 2 - 2
test/mutations.spec.js

@@ -15,11 +15,11 @@ test('catch disconnected nodes that were used as targets for any mutations', asy
 
     Alpine.start()
 
-    runObservers[0]([
+    runObservers.forEach(cb => cb([
         {
             target: document.createElement('div'),
             type: 'childList',
             addedNodes: [ document.createElement('div') ],
         }
-    ])
+    ]))
 })

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov