You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@shindig.apache.org by "Paul Lindner (JIRA)" <ji...@apache.org> on 2010/01/11 23:30:55 UTC

[jira] Commented: (SHINDIG-1260) Improper JavaScript inclusion logic leads to out-of-order and duplicate includes / JavaScript errors

    [ https://issues.apache.org/jira/browse/SHINDIG-1260?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12798895#action_12798895 ] 

Paul Lindner commented on SHINDIG-1260:
---------------------------------------

Can someone review this?  Once that's done I can commit it.

thanks


> Improper JavaScript inclusion logic leads to out-of-order and duplicate includes / JavaScript errors
> ----------------------------------------------------------------------------------------------------
>
>                 Key: SHINDIG-1260
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-1260
>             Project: Shindig
>          Issue Type: Bug
>          Components: PHP
>    Affects Versions: 1.1-BETA5, 1.1-BETA6, 1.1-RC1
>         Environment: RedHat Linux 5.3, Apache 2.2.3, PHP 5.2.10
>            Reporter: James McIninch
>         Attachments: shindig-1260.patch
>
>
> The logic for selecting and inserting JavaScript using the GadgetFeatureRegistry and GadgetBaseRender is incorrect. The result is that JavaScript for features is included out-of-order of their dependencies, sometimes multiply included, and the 'gadgets' JavaScript object is not defined.
> Consider the following simple gadget:
> <?xml version="1.0" encoding="UTF-8"?>
> <Module>
> 	<ModulePrefs title="Hello" description="An example of a simple gadget" author="James McIninch" author_email="james.mcininc@biogenidec.com" />
> 	<UserPref name="firstname" display_name="Your name" datatype="string" default_value="stranger" />
> 	<Content type="html" preferred_height="50" preferred_width="200">
> 		<![CDATA[
> 		    <script type="text/javascript">
> 		       var prefs = new gadgets.Prefs();
> 		       var name  = prefs.getString("firstname");
> 		       document.getElementById("placeholder").innerHTML = name;
> 		    </script>
> 		    
> 		    Hello, <span id="placeholder">name goes here</span>!
> 		]]>
> 	</Content>
> </Module>
> This is rendered as:
> Hello, name goes here!
> Inspecting the JavaScript error console shows that 'gadgets' is undefined. However, the first instance of 'gadgets' being undefined lies in the Shindig-included JavaScript. This is because auth-init.js is included before config.js (both in features/src/main/javascript/features/core.*), but auth-init.js contains the line (28):
> shindig.auth = new shindig.Auth();
> which, in turn calls (auth.js line 159):
> gadgets.config.register("shindig.auth", null, init);
> ... but the 'gadgets' and 'gadgets.config' objects are not yet defined at that point. Despite being dependencies for the auth.js, they aren't  included in the order where the dependencies precede the code that depends on them.
> Also looking at the source of the rendered gadget, the taming.js code is included 5 separate times.
> Correcting the bug will entail re-thinking the logic of the feature ordering to include the dependency information and order the features based on the dependencies.
> All gadgets requiring the 'gadgets' object to be defined currently fail. Gadgets using the legacy model still function, though there exists redundant and erroneous JavaScript.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.