Skip to content

HTML: addChild() & addChildren() #223

Open
@dakur

Description

@dakur

▸ Is your feature request related to a problem? Please describe.

There is no intuitive way to nest element and nest them safely. I can use one of following methods:

  • Html::el('ul')->addHtml(Html::el('li'))
    • the problem is, that addHtml()'s parameter accepts string as well which opens it for potential XSS issues
  • Html::el('ul')->create('li')
    • safe one, but not much intuitive and requires a loop in case of nesting multiple elements into one parent

▸ Explain your intentions.

I suggest to create addChild(Html $child) and addChildren(Html[] $children) methods on Html objects. As it accepts only Html instances it is safe and its name also goes with industry standard.

▸ It's up to you to make a strong case to convince the project's developers of the merits of this feature.

I did above.

I can make a pull request if you agree on this proposal as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions