innerHTML is dangerous.[1] You definitely should not use that for “text”.

Text should either be textContent[2] or innerText[3].

InnerText makes more sense from my perspective.

[1]https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML#Security_considerations
 
<https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML#Security_considerations>
[2]https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent 
<https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent>
[3]https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText 
<https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText>

> On Apr 4, 2019, at 8:00 PM, Carlos Rovira <carlosrov...@apache.org> wrote:
> 
> ok I'm talking about Jewel components that uses same arq as Basic since are
> based on it. So, for example TextInput, TextArea, Alert, Label, CheckBox,
> RadioButton, Button, and some more has text() and html() getters setters.
> 
> I recently changed Jewel Alert to use html instead of text, I'm thinking if
> I should make all Jewel components to have just one property (maybe better
> "text" than "html") that can get just text or text with tags. This will
> save many bytes I think
> 
> For example in Jewel Button we have the same code, so html seems not needed
> at all:
> 
> [Bindable("textChange")]
> /**
> * @copy org.apache.royale.html.Label#text
> *
> * @langversion 3.0
> * @playerversion Flash 10.2
> * @playerversion AIR 2.6
> * @productversion Royale 0.9.4
> */
>        public function get text():String
>        {
> return (element as HTMLButtonElement).innerHTML;
>        }
> 
> /**
> * @private
> */
>        public function set text(value:String):void
>        {
> (element as HTMLButtonElement).innerHTML = value;
> this.dispatchEvent(new Event('textChange'));
>        }
> 
> [Bindable("htmlChange")]
> /**
> * @copy org.apache.royale.html.Label#html
> *
> * @langversion 3.0
> * @playerversion Flash 10.2
> * @playerversion AIR 2.6
> * @productversion Royale 0.9.4
> */
>        public function get html():String
>        {
> return (element as HTMLButtonElement).innerHTML;
>        }
> 
> /**
> * @private
> */
>        public function set html(value:String):void
>        {
> (element as HTMLButtonElement).innerHTML = value;
> this.dispatchEvent(new Event('textChange'));
>        }
> 
> El jue., 4 abr. 2019 a las 16:14, Harbs (<harbs.li...@gmail.com>) escribió:
> 
>> The HTML elements have text and innerHTML which correspond to the HTML
>> element properties.
>> 
>> I’m not sure what the logic of the basic components is.
>> 
>>> On Apr 4, 2019, at 3:18 PM, Kessler CTR Mark J <
>> mark.kessler....@usmc.mil.INVALID> wrote:
>>> 
>>>   The "text" property is probably just for compatibility with the flex
>> components if we are talking about things like "TextInput".   Is the "text"
>> property just syntax sugar / wrapping for the html property?
>>> 
>>> 
>>> -Mark K
>>> 
>>> 
>>> -----Original Message-----
>>> From: Carlos Rovira [mailto:carlosrov...@apache.org]
>>> Sent: Thursday, April 4, 2019 4:59 AM
>>> To: dev@royale.apache.org
>>> Subject: [Non-DoD Source] text vs html
>>> 
>>> Hi
>>> 
>>> in many components we have properties "text" and "html", and I was trying
>>> to figure what we need this duplicate currently.
>>> My bet is that just html (or text with html tags support) will be
>>> sufficient.
>>> Is there any need to have this double property, it seems to me not PAYG
>> and
>>> html supports text with more things, so not reason for this, at least
>> that
>>> I know
>>> 
>>> thanks
>>> 
>>> --
>>> Carlos Rovira
>>> http://about.me/carlosrovira
>> 
>> 
> 
> -- 
> Carlos Rovira
> http://about.me/carlosrovira

Reply via email to