choojs / hyperx

🏷 - tagged template string virtual dom builder
BSD 2-Clause "Simplified" License
1.01k stars 48 forks source link

add support for custom-self-closing elements #58

Open JRJurman opened 6 years ago

JRJurman commented 6 years ago

Hyperx Empty/ Void Tags PR

Hyperx does not have support for custom elements to have self-closing tags (#47)- so this PR adds such functionality.

This PR does break one of the previous tests, where hyperx makes assumptions on which elements automatically support self closing tags. However these assumptions are made at the cost of parsing through a very large array of possible self-closing tags. (See below) https://github.com/choojs/hyperx/blob/f3b880516823e9bfe714f026e67b3cfd5fcf410e/index.js#L265-L281

By removing this, we lose the functionality of being able to support widely known self-closing tags (such as <input> and <br>) but the cost is relatively small (changing <br> to <br /> and <input> to <input />) and has the benefit of support custom tags without adding them to a large list of supported closed tags.

Included in this PR to make up for the lost test, are two new tests, which confirm that existing and custom elements will support self-closing tags.

Work done by @jrjurman and @ethanjurman