@@ -541,6 +541,27 @@ describe('html rendering', () => {
541
541
assert ( container . children [ 0 ] . localName === 'textarea' ) ;
542
542
container . remove ( ) ;
543
543
} ) ;
544
+
545
+ it ( 'renders the same template result multiple times for' , ( ) => {
546
+ const rawResult = html `< div id ="target "> </ div > ` ;
547
+ const container1 = document . createElement ( 'div' ) ;
548
+ const container2 = document . createElement ( 'div' ) ;
549
+ document . body . append ( container1 , container2 ) ;
550
+ render ( container1 , rawResult ) ;
551
+ render ( container2 , rawResult ) ;
552
+ assert ( ! ! container1 . querySelector ( '#target' ) ) ;
553
+ assert ( ! ! container2 . querySelector ( '#target' ) ) ;
554
+ render ( container1 , null ) ;
555
+ render ( container2 , null ) ;
556
+ assert ( ! container1 . querySelector ( '#target' ) ) ;
557
+ assert ( ! container2 . querySelector ( '#target' ) ) ;
558
+ render ( container1 , rawResult ) ;
559
+ render ( container2 , rawResult ) ;
560
+ assert ( ! ! container1 . querySelector ( '#target' ) ) ;
561
+ assert ( ! ! container2 . querySelector ( '#target' ) ) ;
562
+ container1 . remove ( ) ;
563
+ container2 . remove ( ) ;
564
+ } ) ;
544
565
} ) ;
545
566
546
567
describe ( 'html updaters' , ( ) => {
@@ -1085,6 +1106,16 @@ describe('svg updaters', () => {
1085
1106
1086
1107
describe ( 'rendering errors' , ( ) => {
1087
1108
describe ( 'templating' , ( ) => {
1109
+ it ( 'throws when given container is not a node' , ( ) => {
1110
+ let error ;
1111
+ try {
1112
+ render ( { } , html `` ) ;
1113
+ } catch ( e ) {
1114
+ error = e ;
1115
+ }
1116
+ assert ( error ?. message === 'Unexpected non-node render container "[object Object]".' , error . message ) ;
1117
+ } ) ;
1118
+
1088
1119
it ( 'throws when attempting to interpolate within a style tag' , ( ) => {
1089
1120
const getTemplate = ( { color } ) => {
1090
1121
return html `
@@ -1160,12 +1191,12 @@ describe('rendering errors', () => {
1160
1191
} ) ;
1161
1192
1162
1193
it ( 'throws for unquoted attributes' , ( ) => {
1163
- const templateResultReference = html `< div id ="target " not-ok =${ 'foo' } > Gotta double-quote those.</ div > ` ;
1194
+ const rawResult = html `< div id ="target " not-ok =${ 'foo' } > Gotta double-quote those.</ div > ` ;
1164
1195
const container = document . createElement ( 'div' ) ;
1165
1196
document . body . append ( container ) ;
1166
1197
let error ;
1167
1198
try {
1168
- render ( container , templateResultReference ) ;
1199
+ render ( container , rawResult ) ;
1169
1200
} catch ( e ) {
1170
1201
error = e ;
1171
1202
}
@@ -1174,12 +1205,12 @@ describe('rendering errors', () => {
1174
1205
} ) ;
1175
1206
1176
1207
it ( 'throws for single-quoted attributes' , ( ) => {
1177
- const templateResultReference = html `\n< div id ="target " not-ok ='${ 'foo' } '> Gotta double-quote those.</ div > ` ;
1208
+ const rawResult = html `\n< div id ="target " not-ok ='${ 'foo' } '> Gotta double-quote those.</ div > ` ;
1178
1209
const container = document . createElement ( 'div' ) ;
1179
1210
document . body . append ( container ) ;
1180
1211
let error ;
1181
1212
try {
1182
- render ( container , templateResultReference ) ;
1213
+ render ( container , rawResult ) ;
1183
1214
} catch ( e ) {
1184
1215
error = e ;
1185
1216
}
@@ -1188,12 +1219,12 @@ describe('rendering errors', () => {
1188
1219
} ) ;
1189
1220
1190
1221
it ( 'throws for unquoted properties' , ( ) => {
1191
- const templateResultReference = html `\n\n\n< div id ="target " .notOk =${ 'foo' } > Gotta double-quote those.</ div > ` ;
1222
+ const rawResult = html `\n\n\n< div id ="target " .notOk =${ 'foo' } > Gotta double-quote those.</ div > ` ;
1192
1223
const container = document . createElement ( 'div' ) ;
1193
1224
document . body . append ( container ) ;
1194
1225
let error ;
1195
1226
try {
1196
- render ( container , templateResultReference ) ;
1227
+ render ( container , rawResult ) ;
1197
1228
} catch ( e ) {
1198
1229
error = e ;
1199
1230
}
@@ -1202,12 +1233,12 @@ describe('rendering errors', () => {
1202
1233
} ) ;
1203
1234
1204
1235
it ( 'throws for single-quoted properties' , ( ) => {
1205
- const templateResultReference = html `< div id ="target " .notOk ='${ 'foo' } '> Gotta double-quote those.</ div > ` ;
1236
+ const rawResult = html `< div id ="target " .notOk ='${ 'foo' } '> Gotta double-quote those.</ div > ` ;
1206
1237
const container = document . createElement ( 'div' ) ;
1207
1238
document . body . append ( container ) ;
1208
1239
let error ;
1209
1240
try {
1210
- render ( container , templateResultReference ) ;
1241
+ render ( container , rawResult ) ;
1211
1242
} catch ( e ) {
1212
1243
error = e ;
1213
1244
}
@@ -1232,24 +1263,6 @@ describe('rendering errors', () => {
1232
1263
assert ( actual === expected , actual ) ;
1233
1264
container . remove ( ) ;
1234
1265
} ) ;
1235
-
1236
- it ( 'throws for re-injection of template result' , ( ) => {
1237
- const templateResultReference = html `< div id ="target "> </ div > ` ;
1238
- const container = document . createElement ( 'div' ) ;
1239
- document . body . append ( container ) ;
1240
- render ( container , templateResultReference ) ;
1241
- assert ( ! ! container . querySelector ( '#target' ) ) ;
1242
- render ( container , null ) ;
1243
- assert ( ! container . querySelector ( '#target' ) ) ;
1244
- let error ;
1245
- try {
1246
- render ( container , templateResultReference ) ;
1247
- } catch ( e ) {
1248
- error = e ;
1249
- }
1250
- assert ( error ?. message === 'Unexpected re-injection of template result.' , error . message ) ;
1251
- container . remove ( ) ;
1252
- } ) ;
1253
1266
} ) ;
1254
1267
1255
1268
describe ( 'ifDefined' , ( ) => {
0 commit comments