@@ -280,6 +280,7 @@ public function data(string $name, $value = null)
280280
281281 /**
282282 * Sets element's HTML content.
283+ * @param IHtmlString|string
283284 * @return static
284285 * @throws Nette\InvalidArgumentException
285286 */
@@ -313,12 +314,13 @@ final public function getHtml(): string
313314
314315 /**
315316 * Sets element's textual content.
317+ * @param IHtmlString|string
316318 * @return static
317319 * @throws Nette\InvalidArgumentException
318320 */
319321 final public function setText ($ text )
320322 {
321- if (!is_array ( $ text) && ! $ text instanceof self ) {
323+ if (!$ text instanceof IHtmlString ) {
322324 $ text = htmlspecialchars ((string ) $ text , ENT_NOQUOTES , 'UTF-8 ' );
323325 }
324326 return $ this ->setHtml ((string ) $ text );
@@ -336,7 +338,7 @@ final public function getText(): string
336338
337339 /**
338340 * Adds new element's child.
339- * @param Html |string Html node or raw HTML string
341+ * @param IHtmlString |string Html node or raw HTML string
340342 * @return static
341343 */
342344 final public function addHtml ($ child )
@@ -347,11 +349,12 @@ final public function addHtml($child)
347349
348350 /**
349351 * Appends plain-text string to element content.
352+ * @param IHtmlString|string
350353 * @return static
351354 */
352355 public function addText ($ text )
353356 {
354- if (!$ text instanceof self ) {
357+ if (!$ text instanceof IHtmlString ) {
355358 $ text = htmlspecialchars ((string ) $ text , ENT_NOQUOTES , 'UTF-8 ' );
356359 }
357360 return $ this ->insert (null , $ text );
@@ -372,13 +375,14 @@ final public function create(string $name, $attrs = null)
372375
373376 /**
374377 * Inserts child node.
375- * @param Html |string $child Html node or raw HTML string
378+ * @param IHtmlString |string $child Html node or raw HTML string
376379 * @return static
377380 * @throws Nette\InvalidArgumentException
378381 */
379382 public function insert (int $ index = null , $ child , bool $ replace = false )
380383 {
381- if ($ child instanceof self || is_scalar ($ child )) {
384+ if ($ child instanceof IHtmlString || is_scalar ($ child )) {
385+ $ child = $ child instanceof self ? $ child : (string ) $ child ;
382386 if ($ index === null ) { // append
383387 $ this ->children [] = $ child ;
384388
0 commit comments