Address vhtml#11: Add ability to directly set innerHTML of a component using the dangerouslySetInnerHTML attribute.#12
Address vhtml#11: Add ability to directly set innerHTML of a component using the dangerouslySetInnerHTML attribute.#12developit merged 5 commits intodevelopit:masterfrom pl12133:feature/dangerouslySetInnerHTML
dangerouslySetInnerHTML attribute.#12Conversation
…t using the `dangerouslySetInnerHTML` attribute.
|
+1 for this |
|
I think we can slim this down a bit without losing much functionality, but inlining the property name and skipping one of the conditionals: if (attrs && attrs.dangerouslySetInnerHTML) {
s += attrs.dangerouslySetInnerHTML.__html;
} |
|
Good call on dropping the extra check, no need for However I did find |
Saves 3 bytes.
This allows us to assume that `attrs` is a plain object, and remove multiple guards. Saves 6B.
|
Aha, whoops maybe I should've looked here before implementing #17… #17 does pass one test that this doesn't, though I'm not sure whether it "should" according to the spec. The test is: it('should support dangerouslySetInnerHTML (without __html)', () => {
expect(
<div dangerouslySetInnerHTML>foo</div>
).to.equal(
'<div></div>'
);
});In this case, this PR returns |
|
@ithinkihaveacat - I'm going to merge Peter's here, since it's substantially smaller. I personally don't care what we return for the case of a boolean dangerouslySetInnerHTML value - since that actually throws in React most folks wouldn't be using it. |
Should take care of #11.
New Size:.630BNew Size:.624BNew Size:
615B.50Bis kinda significant 😢 but I consider this a useful feature.This was initially a
50Bincrease in size but is now worked down to35Bincrease in size.