flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Harui <aha...@adobe.com>
Subject Re: [FlexJS] How to add html content?
Date Sun, 01 Jan 2017 08:15:30 GMT

On 12/31/16, 11:23 PM, "omuppi1@gmail.com on behalf of OmPrakash
Muppirala" <omuppi1@gmail.com on behalf of bigosmallm@gmail.com> wrote:
>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
>this kind of thing quite often.

IMO, this is use case #1: non-interactive HTML content.  We could just
have an HTML component with an "html" property.  But it would want to wrap
the content in a <div> or <span>

Case #2: In MXML, someone wants to mix FlexJS elements with random HTML.

Case #3: In MXML, someone wants to put in random HTML where one child HTML
tag has an id and wants to write code that addresses that id.

The cheap option is to only support #1 by creating an HTML component with
an "html" property.  Everything else needs more thinking, IMO.

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

IMO, those are just utility functions.  Not everybody needs sanitization,

>>Not really sure why this is required.  I am looking for usage patterns
>>    <HTMLText>{myFancyHTMLText}</HTMLText>
>>    <Image></Image>
>>    <Tab>
>>        <Button />
>>        <HTMLText />
>>    </Tab>
>>    <Tab><HTMLText></Tab>
>>I guess the HTMLText component has to be a UIBase for this to work,
>>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 />
>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 />
>I doubt if this HTML can be generated.  Are you sure there will be a
>linebreak after the text?

No.  I just added that to show the "children".

>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.

AIUI, a TextNode is just plain text.  If the above was:

<div className="Panel">
  The <b>HTML</b> from <strong>MyFancyHTMLTExt</strong>.
  <img />

There would be a TextNode for "The", a Bold node for "HTML", another
TextNode for "from" etc.

This doesn't feel right to me.  All of us seem tempted to want to define a
scrap of complex HTML separate from other child controls in a container.
If there was an HTML control, it would still add a wrapping element.  If
you pull of a trick where the HTML control just injects the content, you
run into more complexity dealing with numElements and childIndex.  It
would be what the browser says it would be, but not quite as obvious from
the MXML.

On the other hand we have those thin-wrapping components like Div, and A
and you ought to be a able to put in HTML content without it being wrapped
by another layer.

>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 think it does.  The default property is expected to be an array of
Ichild elements.  When you have random HTML in the default property the
compiler won't accept XML TextNodes in many places and where it does, it
tries to concatenate TextNodes which is what we don't want.

Other opinions welcome...

View raw message