|
@@ -337,6 +337,29 @@ test('can morph using different keys',
|
|
|
},
|
|
|
)
|
|
|
|
|
|
+test('can morph elements with dynamic ids',
|
|
|
+ [html`
|
|
|
+ <ul>
|
|
|
+ <li x-data x-bind:id="'1'" >foo<input></li>
|
|
|
+ </ul>
|
|
|
+ `],
|
|
|
+ ({ get }, reload, window, document) => {
|
|
|
+ let toHtml = html`
|
|
|
+ <ul>
|
|
|
+ <li x-data x-bind:id="'1'" >foo<input></li>
|
|
|
+ </ul>
|
|
|
+ `
|
|
|
+
|
|
|
+ get('input').type('foo')
|
|
|
+
|
|
|
+ get('ul').then(([el]) => window.Alpine.morph(el, toHtml, {
|
|
|
+ key(el) { return el.id }
|
|
|
+ }))
|
|
|
+
|
|
|
+ get('li:nth-of-type(1) input').should(haveValue('foo'))
|
|
|
+ },
|
|
|
+)
|
|
|
+
|
|
|
test('can morph different inline nodes',
|
|
|
[html`
|
|
|
<div id="from">
|
|
@@ -470,3 +493,47 @@ test('can morph @event handlers', [
|
|
|
get('button').should(haveText('buzz'));
|
|
|
}
|
|
|
);
|
|
|
+
|
|
|
+test.only('can morph menu',
|
|
|
+ [html`
|
|
|
+ <main x-data>
|
|
|
+ <article x-menu>
|
|
|
+ <button data-trigger x-menu:button x-text="'ready'"></button>
|
|
|
+
|
|
|
+ <div x-menu:items>
|
|
|
+ <button x-menu:item href="#edit">
|
|
|
+ Edit
|
|
|
+ <input>
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </article>
|
|
|
+ </main>
|
|
|
+ `],
|
|
|
+ ({ get }, reload, window, document) => {
|
|
|
+ let toHtml = html`
|
|
|
+ <main x-data>
|
|
|
+ <article x-menu>
|
|
|
+ <button data-trigger x-menu:button x-text="'ready'"></button>
|
|
|
+
|
|
|
+ <div x-menu:items>
|
|
|
+ <button x-menu:item href="#edit">
|
|
|
+ Edit
|
|
|
+ <input>
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </article>
|
|
|
+ </main>
|
|
|
+ `
|
|
|
+
|
|
|
+ get('[data-trigger]').should(haveText('ready'));
|
|
|
+ get('button[data-trigger').click()
|
|
|
+
|
|
|
+ get('input').type('foo')
|
|
|
+
|
|
|
+ get('main').then(([el]) => window.Alpine.morph(el, toHtml, {
|
|
|
+ key(el) { return el.id }
|
|
|
+ }))
|
|
|
+
|
|
|
+ get('input').should(haveValue('foo'))
|
|
|
+ },
|
|
|
+)
|