On Dec 31, 2016 5:23 PM, "Alex Harui" <aha...@adobe.com> wrote:



On 12/31/16, 4:40 PM, "omup...@gmail.com on behalf of OmPrakash Muppirala"
<omup...@gmail.com on behalf of bigosma...@gmail.com> wrote:

>
>The question is does a HTMLText component exist in the default component
>set?  That is a common enough pattern that we do seem to need it to be
>part
>of the default component set.  Much like a button or an image.

Not yet.  Feel free to make DivWithText extending UIBase.  Really, my
original bet was that FlexJS was more about creating interactive sets of
controls and less on displaying HTML markup.  But it looks like I'm wrong
about that since this topic keeps coming up.


Okay, I see your point now.  To be clear, I did not set out to write HTML
code.  The bio in team.json is a html snippet.  So, I am just trying to
display it as a piece of formatted data.  Even in other projects, I do need
this kind of thing quite often.

That brings up a related concern.  We need to sanitize such html content
during runtime [1]


>
>Right now, we do not have a good way to display HTML content, while with
>direct HTML/JS development, that is a no-brainer operation.  We cannot
>ship
>without an easy way to display HTML.  Given that the runtime cost of this
>component is almost nothing, we really don't lose anything by having such
>a
>component.
>
>
>>
>> That said, it might be worth revisiting whether we can create
>>non-IUIBase
>> children in the default property for Containers.
>
>
>Not really sure why this is required.  I am looking for usage patterns
>like
>this:
>
><Panel>
>    <HTMLText>{myFancyHTMLText}</HTMLText>
>    <Image></Image>
></Panel>
>
><TabNavigator>
>    <Tab>
>        <Button />
>        <HTMLText />
>    </Tab>
>    <Tab><HTMLText></Tab>
></TabNavigator>
>
>I guess the HTMLText component has to be a UIBase for this to work, right?
>
>Maybe I am not understanding the point you are trying to make.

The above would likely create an HTML DOM like:

<Div className="Panel">
  <Span>the HTML from myFancyHTMLText</Span>
  <Img />
</Div>


Carlos asked earlier about getting rid of the Span since we all know it is
legit to have the HTML DOM look like:

<Div className="Panel">
  The HTML from MyFancyHTMLTExt
  <img />
</div>


I doubt if this HTML can be generated.  Are you sure there will be a
linebreak after the text?

That looks a TextNode element.  Which is lightweight than innerHTML  But
are we sure we don't want formatting for such text?  If we want to be able
to format, we need to use a p or a span element.

What happens to the layout is a different question.  TextNode and span are
inline.  Whereas p is a block element.


IOW, no wrapping HTMLElement for the text.  The MXML parser doesn't really
support random text nodes right now, and the UIBase parent/child is pretty
much expecting HTMLElements as children.

There is a cost in both development time and runtime performance to
generalizing this.  Should we do it?


Hmm,  I don't think this requires a change to MXML parsing.  I would rather
use a div and set innerHTML and be done with it.  There is also an
insertAdjacentHTML method that is apparently quite fast in some usecases.
[2]

Thanks,
Om

[1] https://en.m.wikipedia.org/wiki/HTML_sanitization
[2] https://developer.mozilla.org/en-US/docs/Web/API/Element/
insertAdjacentHTML

Reply via email to