Is the compile-time evaluator smart enough to short-circuit boolean expressions 
even if not all the terms are compile-time constants?  E.g.,

  if ((! $mobile) && this.quirks.ie_alpha_image_loader ) {

should emit no code for $mobile, and be equivalent to:

  if (this.quirks.ie_alpha_image_loader) {

for non-mobile?  Then you would not need the more contorted:

  if (! $mobile ? this.quirks.ie_alpha_image_loader : false) {

On 2011-01-12, at 12:29, André Bargull wrote:

> The conditional operator is also handled by the compile-time evaluator, so 
> these two alternatives actually work and only emit the minimal javascript 
> code:
>> if (! $mobile ? this.quirks.ie_alpha_image_loader : false) {
>>  i._parent.style.display = '';
>> } else {
>>  i.style.display = '';
>> }
> and:
>> var target = $mobile ? e.target : (e.target || e.srcElement);
> 
> 
> On 1/12/2011 5:36 PM, Max Carlson wrote:
>> Change maxcarlson-20110112-6K9 by maxcarlson@friendly on 2011-01-12 08:29:25 
>> PST
>>     in /Users/maxcarlson/openlaszlo/trunk2
>>     for http://svn.openlaszlo.org/openlaszlo/trunk
>> 
>> Summary: First pass at commenting out non-mobile code for $mobile runtime
>> 
>> Bugs Fixed: LPP-9645 - add if (! $mobile) {...} blocks to DHTML LFC (partial)
>> 
>> Technical Reviewer: hminsky
>> QA Reviewer: ptw
>> 
>> Details: Without trying too hard, I was able to reduce the total size of the 
>> mobile LFC by ~1.6K compressed, down to 94k from 95.7k!  I think this is 
>> moving in the right direction.
>> 
>> I could have been more aggressive, but I'm trying to not restructure the 
>> code.  This means I have to leave some bits in, e.g.:
>> 
>>         if (this.quirks.ie_alpha_image_loader) {
>> if (! $mobile) {
>>             i._parent.style.display = '';
>> }
>>         } else {
>>             i.style.display = '';
>>         }
>> 
>> I could restructure a bit and eliminate the test, but this is just a first 
>> pass...  Also, it would be nice if I could do things like:
>> 
>>     // IE calls `target` `srcElement`
>>     var target = e.target
>> if (! $mobile) {
>>     || e.srcElement;
>> }
>> 
>> but that freaks out the parser.
>> 
>> Files:
>> M       WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
>> 
>> Changeset: 
>> http://svn.openlaszlo.org/openlaszlo/patches/maxcarlson-20110112-6K9.tar
>> 
>> 


Reply via email to