Altitude - Changes to AL-Rendering package stop AjaxCounterExample from working

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Altitude - Changes to AL-Rendering package stop AjaxCounterExample from working

Chris Cunnington

Changes to the AL-Rendering package allow for escape characters in tag attributes. The changes in ALHtml5Tag>>writeOpenInto: to produce that change (with the use of XTHtmlEntityWriteStream) but cause the AjaxCounterExample to stop working. The double quotes, ", become " and JavaScript becomes incomprehensible to the browser.

It looks like the following with ViewSource in a browser with the old package, the new package, and a simple solution.


AjaxCounterExample>>renderScriptsOn: with older Render package:


new Counter("/76S.tbklwPZckEDg94Zqgn7tB.-"); counter.install("#count", "#dec", "#inc");


AjaxCounterExample>>renderScriptsOn: with latest changer to Render package:

new Counter("""""/76S.tbklwPZckEDg94Zqgn7tB.-"""""); counter.install("#count", "#dec", "#inc");


AjaxCounterExample>>renderScriptsOn: with single quotes.

new Counter('/76S.tbklwPZckEDg94Zqgn7tB.-'); counter.install('#count', '#dec', '#inc');


The code in question is:

AjaxCounterExample>>renderScriptsOn:

[html text: 'var counter = new Counter("'.
html text: (html context registerResource: self resource) printString.
html text: '"); counter.install("#count", "#dec", "#inc");' ]

A simple solution could be to write JavaScript with pairs of single quotes instead of double quotes. '' instead of ". Just a thought.

Chris



Reply | Threaded
Open this post in threaded view
|

Re: Altitude - Changes to AL-Rendering package stop AjaxCounterExample from working

Colin Putney-3
On Mon, Aug 20, 2012 at 12:00 PM, Chris Cunnington
<[hidden email]> wrote:

> Changes to the AL-Rendering package allow for escape characters in tag
> attributes. The changes in ALHtml5Tag>>writeOpenInto: to produce that change
> (with the use of XTHtmlEntityWriteStream) but cause the AjaxCounterExample
> to stop working. The double quotes, ", become &quot; and JavaScript becomes
> incomprehensible to the browser.

Whoops. Javascript should be rendered with #raw: and not #text:, since
we don't want Javascript to be entity-encoded. Fixed in
AL-Examples-cwp.10.

Colin

Reply | Threaded
Open this post in threaded view
|

Re: Altitude - Changes to AL-Rendering package stop AjaxCounterExample from working

Chris Cunnington
On 12-08-21 12:52 AM, Colin Putney wrote:

> On Mon, Aug 20, 2012 at 12:00 PM, Chris Cunnington
> <[hidden email]> wrote:
>
>> Changes to the AL-Rendering package allow for escape characters in tag
>> attributes. The changes in ALHtml5Tag>>writeOpenInto: to produce that change
>> (with the use of XTHtmlEntityWriteStream) but cause the AjaxCounterExample
>> to stop working. The double quotes, ", become &quot; and JavaScript becomes
>> incomprehensible to the browser.
> Whoops. Javascript should be rendered with #raw: and not #text:, since
> we don't want Javascript to be entity-encoded. Fixed in
> AL-Examples-cwp.10.
>
> Colin
>
Super. Thanks.

Chris