@@ -82,7 +82,6 @@ public static function el(string $name = null, $attrs = null)
8282 /**
8383 * Changes element's name.
8484 * @return static
85- * @throws Nette\InvalidArgumentException
8685 */
8786 final public function setName (string $ name , bool $ isEmpty = null )
8887 {
@@ -293,13 +292,9 @@ public function data(string $name, $value = null)
293292 * Sets element's HTML content.
294293 * @param IHtmlString|string
295294 * @return static
296- * @throws Nette\InvalidArgumentException
297295 */
298296 final public function setHtml ($ html )
299297 {
300- if (is_array ($ html )) {
301- throw new Nette \InvalidArgumentException (sprintf ('Textual content must be a scalar, %s given. ' , gettype ($ html )));
302- }
303298 $ this ->children = [(string ) $ html ];
304299 return $ this ;
305300 }
@@ -318,7 +313,6 @@ final public function getHtml(): string
318313 * Sets element's textual content.
319314 * @param IHtmlString|string
320315 * @return static
321- * @throws Nette\InvalidArgumentException
322316 */
323317 final public function setText ($ text )
324318 {
@@ -352,7 +346,7 @@ final public function addHtml($child)
352346
353347 /**
354348 * Appends plain-text string to element content.
355- * @param IHtmlString|string
349+ * @param IHtmlString|string|int|float
356350 * @return static
357351 */
358352 public function addText ($ text )
@@ -380,21 +374,15 @@ final public function create(string $name, $attrs = null)
380374 * Inserts child node.
381375 * @param IHtmlString|string $child Html node or raw HTML string
382376 * @return static
383- * @throws Nette\InvalidArgumentException
384377 */
385378 public function insert (int $ index = null , $ child , bool $ replace = false )
386379 {
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 ;
391383
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 ]);
398386 }
399387
400388 return $ this ;
@@ -440,7 +428,7 @@ final public function offsetExists($index): bool
440428 public function offsetUnset ($ index ): void
441429 {
442430 if (isset ($ this ->children [$ index ])) {
443- array_splice ($ this ->children , ( int ) $ index , 1 );
431+ array_splice ($ this ->children , $ index , 1 );
444432 }
445433 }
446434
@@ -494,7 +482,7 @@ final public function render(int $indent = null): string
494482 $ indent ++;
495483 }
496484 foreach ($ this ->children as $ child ) {
497- if (is_object ( $ child) ) {
485+ if ($ child instanceof self ) {
498486 $ s .= $ child ->render ($ indent );
499487 } else {
500488 $ s .= $ child ;
0 commit comments