@@ -14,10 +14,6 @@ describe("Core morphing tests", function(){
1414 let finalSrc = "<button>Bar</button>" ;
1515 let final = make ( finalSrc ) ;
1616 Idiomorph . morph ( initial , final , { morphStyle :'outerHTML' } ) ;
17- if ( initial . outerHTML !== "<button>Bar</button>" ) {
18- console . log ( "HTML after morph: " + initial . outerHTML ) ;
19- console . log ( "Expected: " + finalSrc ) ;
20- }
2117 initial . outerHTML . should . equal ( "<button>Bar</button>" ) ;
2218 } ) ;
2319
@@ -26,10 +22,6 @@ describe("Core morphing tests", function(){
2622 let initial = make ( "<button>Foo</button>" ) ;
2723 let finalSrc = "<button>Bar</button>" ;
2824 Idiomorph . morph ( initial , finalSrc , { morphStyle :'outerHTML' } ) ;
29- if ( initial . outerHTML !== "<button>Bar</button>" ) {
30- console . log ( "HTML after morph: " + initial . outerHTML ) ;
31- console . log ( "Expected: " + finalSrc ) ;
32- }
3325 initial . outerHTML . should . equal ( "<button>Bar</button>" ) ;
3426 } ) ;
3527
@@ -39,10 +31,6 @@ describe("Core morphing tests", function(){
3931 let finalSrc = "<div><button>Bar</button></div>" ;
4032 let final = make ( finalSrc ) . children ;
4133 Idiomorph . morph ( initial , final , { morphStyle :'outerHTML' } ) ;
42- if ( initial . outerHTML !== "<button>Bar</button>" ) {
43- console . log ( "HTML after morph: " + initial . outerHTML ) ;
44- console . log ( "Expected: " + finalSrc ) ;
45- }
4634 initial . outerHTML . should . equal ( "<button>Bar</button>" ) ;
4735 } ) ;
4836
@@ -52,10 +40,6 @@ describe("Core morphing tests", function(){
5240 let finalSrc = "<div><button>Bar</button></div>" ;
5341 let final = [ ...make ( finalSrc ) . children ] ;
5442 Idiomorph . morph ( initial , final , { morphStyle :'outerHTML' } ) ;
55- if ( initial . outerHTML !== "<button>Bar</button>" ) {
56- console . log ( "HTML after morph: " + initial . outerHTML ) ;
57- console . log ( "Expected: " + finalSrc ) ;
58- }
5943 initial . outerHTML . should . equal ( "<button>Bar</button>" ) ;
6044 } ) ;
6145
@@ -66,10 +50,6 @@ describe("Core morphing tests", function(){
6650 let finalSrc = "<p>Foo</p><button>Bar</button><p>Bar</p>" ;
6751 let final = makeElements ( finalSrc ) ;
6852 Idiomorph . morph ( initial , final , { morphStyle :'outerHTML' } ) ;
69- if ( initial . outerHTML !== "<button>Bar</button>" ) {
70- console . log ( "HTML after morph: " + initial . outerHTML ) ;
71- console . log ( "Expected: " + finalSrc ) ;
72- }
7353 initial . outerHTML . should . equal ( "<button>Bar</button>" ) ;
7454 initial . parentElement . innerHTML . should . equal ( "<p>Foo</p><button>Bar</button><p>Bar</p>" ) ;
7555 } ) ;
@@ -81,10 +61,6 @@ describe("Core morphing tests", function(){
8161 let finalSrc = "<p>Foo</p><button>Bar</button><p>Bar</p>" ;
8262 let final = [ ...makeElements ( finalSrc ) ] ;
8363 Idiomorph . morph ( initial , final , { morphStyle :'outerHTML' } ) ;
84- if ( initial . outerHTML !== "<button>Bar</button>" ) {
85- console . log ( "HTML after morph: " + initial . outerHTML ) ;
86- console . log ( "Expected: " + finalSrc ) ;
87- }
8864 initial . outerHTML . should . equal ( "<button>Bar</button>" ) ;
8965 initial . parentElement . innerHTML . should . equal ( "<p>Foo</p><button>Bar</button><p>Bar</p>" ) ;
9066 } ) ;
@@ -95,10 +71,6 @@ describe("Core morphing tests", function(){
9571 let initial = parent . querySelector ( "button" ) ;
9672 let finalSrc = "<p>Foo</p><button>Bar</button><p>Bar</p>" ;
9773 Idiomorph . morph ( initial , finalSrc , { morphStyle :'outerHTML' } ) ;
98- if ( initial . outerHTML !== "<button>Bar</button>" ) {
99- console . log ( "HTML after morph: " + initial . outerHTML ) ;
100- console . log ( "Expected: " + finalSrc ) ;
101- }
10274 initial . outerHTML . should . equal ( "<button>Bar</button>" ) ;
10375 initial . parentElement . innerHTML . should . equal ( "<p>Foo</p><button>Bar</button><p>Bar</p>" ) ;
10476 } ) ;
@@ -109,10 +81,6 @@ describe("Core morphing tests", function(){
10981 let initial = parent . querySelector ( "button" ) ;
11082 let finalSrc = "<p>Doh</p><p>Foo</p><button>Bar</button><p>Bar</p><p>Ray</p>" ;
11183 Idiomorph . morph ( initial , finalSrc , { morphStyle :'outerHTML' } ) ;
112- if ( initial . outerHTML !== "<button>Bar</button>" ) {
113- console . log ( "HTML after morph: " + initial . outerHTML ) ;
114- console . log ( "Expected: " + finalSrc ) ;
115- }
11684 initial . outerHTML . should . equal ( "<button>Bar</button>" ) ;
11785 initial . parentElement . innerHTML . should . equal ( "<p>Doh</p><p>Foo</p><button>Bar</button><p>Bar</p><p>Ray</p>" ) ;
11886 } ) ;
@@ -130,10 +98,6 @@ describe("Core morphing tests", function(){
13098 let finalSrc = "<button>Bar</button>" ;
13199 let final = make ( finalSrc ) ;
132100 Idiomorph . morph ( initial , final , { morphStyle :'innerHTML' } ) ;
133- if ( initial . outerHTML !== "<button>Bar</button>" ) {
134- console . log ( "HTML after morph: " + initial . outerHTML ) ;
135- console . log ( "Expected: " + finalSrc ) ;
136- }
137101 initial . outerHTML . should . equal ( "<div><button>Bar</button></div>" ) ;
138102 } ) ;
139103
@@ -142,10 +106,6 @@ describe("Core morphing tests", function(){
142106 let initial = make ( "<button>Foo</button>" ) ;
143107 let finalSrc = "<button>Bar</button>" ;
144108 Idiomorph . morph ( initial , finalSrc , { morphStyle :'innerHTML' } ) ;
145- if ( initial . outerHTML !== "<button>Bar</button>" ) {
146- console . log ( "HTML after morph: " + initial . outerHTML ) ;
147- console . log ( "Expected: " + finalSrc ) ;
148- }
149109 initial . outerHTML . should . equal ( "<button><button>Bar</button></button>" ) ;
150110 } ) ;
151111
@@ -155,10 +115,6 @@ describe("Core morphing tests", function(){
155115 let finalSrc = "<div><button>Bar</button></div>" ;
156116 let final = make ( finalSrc ) . children ;
157117 Idiomorph . morph ( initial , final , { morphStyle :'innerHTML' } ) ;
158- if ( initial . outerHTML !== "<button>Bar</button>" ) {
159- console . log ( "HTML after morph: " + initial . outerHTML ) ;
160- console . log ( "Expected: " + finalSrc ) ;
161- }
162118 initial . outerHTML . should . equal ( "<button><button>Bar</button></button>" ) ;
163119 } ) ;
164120
@@ -168,10 +124,6 @@ describe("Core morphing tests", function(){
168124 let finalSrc = "<div><button>Bar</button></div>" ;
169125 let final = [ ...make ( finalSrc ) . children ] ;
170126 Idiomorph . morph ( initial , final , { morphStyle :'innerHTML' } ) ;
171- if ( initial . outerHTML !== "<button>Bar</button>" ) {
172- console . log ( "HTML after morph: " + initial . outerHTML ) ;
173- console . log ( "Expected: " + finalSrc ) ;
174- }
175127 initial . outerHTML . should . equal ( "<button><button>Bar</button></button>" ) ;
176128 } ) ;
177129
@@ -182,6 +134,13 @@ describe("Core morphing tests", function(){
182134 initial . outerHTML . should . equal ( "<div></div>" ) ;
183135 } ) ;
184136
137+ it ( 'errors on bad morphStyle' , function ( )
138+ {
139+ ( ( ) => {
140+ Idiomorph . morph ( make ( "<p>" ) , [ ] , { morphStyle :'magic' } ) ;
141+ } ) . should . throw ( "Do not understand how to morph style magic" ) ;
142+ } ) ;
143+
185144 it ( 'can morph a template tag properly' , function ( )
186145 {
187146 let initial = make ( "<template data-old>Foo</template>" ) ;
@@ -345,10 +304,6 @@ describe("Core morphing tests", function(){
345304
346305 let finalSrc = '<textarea>bar</textarea>' ;
347306 Idiomorph . morph ( initial , finalSrc , { morphStyle :'outerHTML' } ) ;
348- if ( initial . outerHTML !== '<input value="bar">' ) {
349- console . log ( "HTML after morph: " + initial . outerHTML ) ;
350- console . log ( "Expected: " + finalSrc ) ;
351- }
352307 initial . outerHTML . should . equal ( '<textarea>bar</textarea>' ) ;
353308
354309 initial . focus ( ) ;
@@ -362,6 +317,35 @@ describe("Core morphing tests", function(){
362317 document . body . removeChild ( parent ) ;
363318 } ) ;
364319
320+ it ( 'can morph input value properly because value property is special and doesnt reflect' , function ( )
321+ {
322+ let initial = make ( '<div><input value="foo"></div>' ) ;
323+ let final = make ( '<input value="foo">' ) ;
324+ final . value = "bar" ;
325+ Idiomorph . morph ( initial , final , { morphStyle :'innerHTML' } ) ;
326+ initial . innerHTML . should . equal ( '<input value="bar">' ) ;
327+ } ) ;
328+
329+ it ( 'can morph textarea value properly because value property is special and doesnt reflect' , function ( )
330+ {
331+ let initial = make ( '<textarea>foo</textarea>' ) ;
332+ let final = make ( '<textarea>foo</textarea>' ) ;
333+ final . value = "bar" ;
334+ Idiomorph . morph ( initial , final , { morphStyle :'outerHTML' } ) ;
335+ initial . value . should . equal ( 'bar' ) ;
336+ } ) ;
337+
338+ it ( 'specially considers textarea value property in beforeAttributeUpdated hook because value property is special and doesnt reflect' , function ( )
339+ {
340+ let initial = make ( '<div><textarea>foo</textarea></div>' ) ;
341+ let final = make ( '<textarea>foo</textarea>' ) ;
342+ final . value = "bar" ;
343+ Idiomorph . morph ( initial , final , { morphStyle :'innerHTML' , callbacks :{
344+ beforeAttributeUpdated : ( attr , to , updatetype ) => false ,
345+ } } ) ;
346+ initial . innerHTML . should . equal ( '<textarea>foo</textarea>' ) ;
347+ } ) ;
348+
365349 it ( 'can morph input checked properly, remove checked' , function ( )
366350 {
367351 let parent = make ( '<div><input type="checkbox" checked></div>' ) ;
@@ -370,10 +354,6 @@ describe("Core morphing tests", function(){
370354
371355 let finalSrc = '<input type="checkbox">' ;
372356 Idiomorph . morph ( initial , finalSrc , { morphStyle :'outerHTML' } ) ;
373- if ( initial . outerHTML !== '<input type="checkbox">' ) {
374- console . log ( "HTML after morph: " + initial . outerHTML ) ;
375- console . log ( "Expected: " + finalSrc ) ;
376- }
377357 initial . outerHTML . should . equal ( '<input type="checkbox">' ) ;
378358 initial . checked . should . equal ( false ) ;
379359 document . body . removeChild ( parent ) ;
@@ -387,10 +367,6 @@ describe("Core morphing tests", function(){
387367
388368 let finalSrc = '<input type="checkbox" checked>' ;
389369 Idiomorph . morph ( initial , finalSrc , { morphStyle :'outerHTML' } ) ;
390- if ( initial . outerHTML !== '<input type="checkbox" checked="">' ) {
391- console . log ( "HTML after morph: " + initial . outerHTML ) ;
392- console . log ( "Expected: " + finalSrc ) ;
393- }
394370 initial . outerHTML . should . equal ( '<input type="checkbox" checked="">' ) ;
395371 initial . checked . should . equal ( true ) ;
396372 document . body . removeChild ( parent ) ;
@@ -405,10 +381,6 @@ describe("Core morphing tests", function(){
405381
406382 let finalSrc = '<input type="checkbox" checked>' ;
407383 Idiomorph . morph ( initial , finalSrc , { morphStyle :'outerHTML' } ) ;
408- if ( initial . outerHTML !== '<input type="checkbox" checked="true">' ) {
409- console . log ( "HTML after morph: " + initial . outerHTML ) ;
410- console . log ( "Expected: " + finalSrc ) ;
411- }
412384 initial . outerHTML . should . equal ( '<input type="checkbox" checked="true">' ) ;
413385 initial . checked . should . equal ( true ) ;
414386 document . body . removeChild ( parent ) ;
@@ -423,10 +395,6 @@ describe("Core morphing tests", function(){
423395
424396 let finalSrc = '<input type="checkbox">' ;
425397 Idiomorph . morph ( initial , finalSrc , { morphStyle :'outerHTML' } ) ;
426- if ( initial . outerHTML !== '<input type="checkbox">' ) {
427- console . log ( "HTML after morph: " + initial . outerHTML ) ;
428- console . log ( "Expected: " + finalSrc ) ;
429- }
430398 initial . outerHTML . should . equal ( '<input type="checkbox">' ) ;
431399 initial . checked . should . equal ( false ) ;
432400 document . body . removeChild ( parent ) ;
@@ -443,10 +411,6 @@ describe("Core morphing tests", function(){
443411 // should more inner HTML despite no config
444412 Idiomorph . morph ( initial , finalSrc ) ;
445413
446- if ( initial . outerHTML !== "<button>Bar</button>" ) {
447- console . log ( "HTML after morph: " + initial . outerHTML ) ;
448- console . log ( "Expected: " + finalSrc ) ;
449- }
450414 initial . outerHTML . should . equal ( "<button><button>Bar</button></button>" ) ;
451415 } finally {
452416 Idiomorph . defaults . morphStyle = 'outerHTML' ;
@@ -464,10 +428,6 @@ describe("Core morphing tests", function(){
464428 // should morph outer HTML despite default setting
465429 Idiomorph . morph ( initial , finalSrc , { morphStyle :'outerHTML' } ) ;
466430
467- if ( initial . outerHTML !== "<button>Bar</button>" ) {
468- console . log ( "HTML after morph: " + initial . outerHTML ) ;
469- console . log ( "Expected: " + finalSrc ) ;
470- }
471431 initial . outerHTML . should . equal ( "<button>Bar</button>" ) ;
472432 } finally {
473433 Idiomorph . defaults . morphStyle = 'outerHTML' ;
0 commit comments