@@ -82,7 +82,6 @@ public static function el(string $name = null, $attrs = null)
82
82
/**
83
83
* Changes element's name.
84
84
* @return static
85
- * @throws Nette\InvalidArgumentException
86
85
*/
87
86
final public function setName (string $ name , bool $ isEmpty = null )
88
87
{
@@ -293,13 +292,9 @@ public function data(string $name, $value = null)
293
292
* Sets element's HTML content.
294
293
* @param IHtmlString|string
295
294
* @return static
296
- * @throws Nette\InvalidArgumentException
297
295
*/
298
296
final public function setHtml ($ html )
299
297
{
300
- if (is_array ($ html )) {
301
- throw new Nette \InvalidArgumentException (sprintf ('Textual content must be a scalar, %s given. ' , gettype ($ html )));
302
- }
303
298
$ this ->children = [(string ) $ html ];
304
299
return $ this ;
305
300
}
@@ -318,7 +313,6 @@ final public function getHtml(): string
318
313
* Sets element's textual content.
319
314
* @param IHtmlString|string
320
315
* @return static
321
- * @throws Nette\InvalidArgumentException
322
316
*/
323
317
final public function setText ($ text )
324
318
{
@@ -352,7 +346,7 @@ final public function addHtml($child)
352
346
353
347
/**
354
348
* Appends plain-text string to element content.
355
- * @param IHtmlString|string
349
+ * @param IHtmlString|string|int|float
356
350
* @return static
357
351
*/
358
352
public function addText ($ text )
@@ -380,21 +374,15 @@ final public function create(string $name, $attrs = null)
380
374
* Inserts child node.
381
375
* @param IHtmlString|string $child Html node or raw HTML string
382
376
* @return static
383
- * @throws Nette\InvalidArgumentException
384
377
*/
385
378
public function insert (int $ index = null , $ child , bool $ replace = false )
386
379
{
387
- if ($ child instanceof IHtmlString || is_scalar ($ child )) {
388
- $ child = $ child instanceof self ? $ child : (string ) $ child ;
389
- if ($ index === null ) { // append
390
- $ this ->children [] = $ child ;
380
+ $ child = $ child instanceof self ? $ child : (string ) $ child ;
381
+ if ($ index === null ) { // append
382
+ $ this ->children [] = $ child ;
391
383
392
- } else { // insert or replace
393
- array_splice ($ this ->children , $ index , $ replace ? 1 : 0 , [$ child ]);
394
- }
395
-
396
- } else {
397
- throw new Nette \InvalidArgumentException (sprintf ('Child node must be scalar or Html object, %s given. ' , is_object ($ child ) ? get_class ($ child ) : gettype ($ child )));
384
+ } else { // insert or replace
385
+ array_splice ($ this ->children , $ index , $ replace ? 1 : 0 , [$ child ]);
398
386
}
399
387
400
388
return $ this ;
@@ -440,7 +428,7 @@ final public function offsetExists($index): bool
440
428
public function offsetUnset ($ index ): void
441
429
{
442
430
if (isset ($ this ->children [$ index ])) {
443
- array_splice ($ this ->children , ( int ) $ index , 1 );
431
+ array_splice ($ this ->children , $ index , 1 );
444
432
}
445
433
}
446
434
@@ -494,7 +482,7 @@ final public function render(int $indent = null): string
494
482
$ indent ++;
495
483
}
496
484
foreach ($ this ->children as $ child ) {
497
- if (is_object ( $ child) ) {
485
+ if ($ child instanceof self ) {
498
486
$ s .= $ child ->render ($ indent );
499
487
} else {
500
488
$ s .= $ child ;
0 commit comments