@@ -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' , ( ) => {
@@ -1081,6 +1102,16 @@ describe('svg updaters', () => {
1081
1102
1082
1103
describe ( 'rendering errors' , ( ) => {
1083
1104
describe ( 'templating' , ( ) => {
1105
+ it ( 'throws when given container is not a node' , ( ) => {
1106
+ let error ;
1107
+ try {
1108
+ render ( { } , html `` ) ;
1109
+ } catch ( e ) {
1110
+ error = e ;
1111
+ }
1112
+ assert ( error ?. message === 'Unexpected non-node render container "[object Object]".' , error . message ) ;
1113
+ } ) ;
1114
+
1084
1115
it ( 'throws when attempting to interpolate within a style tag' , ( ) => {
1085
1116
const getTemplate = ( { color } ) => {
1086
1117
return html `
@@ -1156,12 +1187,12 @@ describe('rendering errors', () => {
1156
1187
} ) ;
1157
1188
1158
1189
it ( 'throws for unquoted attributes' , ( ) => {
1159
- const templateResultReference = html `< div id ="target " not-ok =${ 'foo' } > Gotta double-quote those.</ div > ` ;
1190
+ const rawResult = html `< div id ="target " not-ok =${ 'foo' } > Gotta double-quote those.</ div > ` ;
1160
1191
const container = document . createElement ( 'div' ) ;
1161
1192
document . body . append ( container ) ;
1162
1193
let error ;
1163
1194
try {
1164
- render ( container , templateResultReference ) ;
1195
+ render ( container , rawResult ) ;
1165
1196
} catch ( e ) {
1166
1197
error = e ;
1167
1198
}
@@ -1170,12 +1201,12 @@ describe('rendering errors', () => {
1170
1201
} ) ;
1171
1202
1172
1203
it ( 'throws for single-quoted attributes' , ( ) => {
1173
- const templateResultReference = html `\n< div id ="target " not-ok ='${ 'foo' } '> Gotta double-quote those.</ div > ` ;
1204
+ const rawResult = html `\n< div id ="target " not-ok ='${ 'foo' } '> Gotta double-quote those.</ div > ` ;
1174
1205
const container = document . createElement ( 'div' ) ;
1175
1206
document . body . append ( container ) ;
1176
1207
let error ;
1177
1208
try {
1178
- render ( container , templateResultReference ) ;
1209
+ render ( container , rawResult ) ;
1179
1210
} catch ( e ) {
1180
1211
error = e ;
1181
1212
}
@@ -1184,12 +1215,12 @@ describe('rendering errors', () => {
1184
1215
} ) ;
1185
1216
1186
1217
it ( 'throws for unquoted properties' , ( ) => {
1187
- const templateResultReference = html `\n\n\n< div id ="target " .notOk =${ 'foo' } > Gotta double-quote those.</ div > ` ;
1218
+ const rawResult = html `\n\n\n< div id ="target " .notOk =${ 'foo' } > Gotta double-quote those.</ div > ` ;
1188
1219
const container = document . createElement ( 'div' ) ;
1189
1220
document . body . append ( container ) ;
1190
1221
let error ;
1191
1222
try {
1192
- render ( container , templateResultReference ) ;
1223
+ render ( container , rawResult ) ;
1193
1224
} catch ( e ) {
1194
1225
error = e ;
1195
1226
}
@@ -1198,12 +1229,12 @@ describe('rendering errors', () => {
1198
1229
} ) ;
1199
1230
1200
1231
it ( 'throws for single-quoted properties' , ( ) => {
1201
- const templateResultReference = html `< div id ="target " .notOk ='${ 'foo' } '> Gotta double-quote those.</ div > ` ;
1232
+ const rawResult = html `< div id ="target " .notOk ='${ 'foo' } '> Gotta double-quote those.</ div > ` ;
1202
1233
const container = document . createElement ( 'div' ) ;
1203
1234
document . body . append ( container ) ;
1204
1235
let error ;
1205
1236
try {
1206
- render ( container , templateResultReference ) ;
1237
+ render ( container , rawResult ) ;
1207
1238
} catch ( e ) {
1208
1239
error = e ;
1209
1240
}
@@ -1228,24 +1259,6 @@ describe('rendering errors', () => {
1228
1259
assert ( actual === expected , actual ) ;
1229
1260
container . remove ( ) ;
1230
1261
} ) ;
1231
-
1232
- it ( 'throws for re-injection of template result' , ( ) => {
1233
- const templateResultReference = html `< div id ="target "> </ div > ` ;
1234
- const container = document . createElement ( 'div' ) ;
1235
- document . body . append ( container ) ;
1236
- render ( container , templateResultReference ) ;
1237
- assert ( ! ! container . querySelector ( '#target' ) ) ;
1238
- render ( container , null ) ;
1239
- assert ( ! container . querySelector ( '#target' ) ) ;
1240
- let error ;
1241
- try {
1242
- render ( container , templateResultReference ) ;
1243
- } catch ( e ) {
1244
- error = e ;
1245
- }
1246
- assert ( error ?. message === 'Unexpected re-injection of template result.' , error . message ) ;
1247
- container . remove ( ) ;
1248
- } ) ;
1249
1262
} ) ;
1250
1263
1251
1264
describe ( 'ifDefined' , ( ) => {
0 commit comments