googlearchive / caja

Caja is a tool for safely embedding third party HTML, CSS and JavaScript in your website.
Apache License 2.0
1.13k stars 127 forks source link

jQueryUI not loading in playground or Sites #1549

Closed kpreid closed 9 years ago

kpreid commented 9 years ago

Original issue 1549 created by cgoldfeder@google.com on 2012-09-27T14:54:30.000Z:

Minimal failure example:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js&quot;&gt;&lt;/script&gt; <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js&quot; type="text/javascript"></script>

Runtime error:

Uncaught script error: 'Cannot read property 'style_v_' of null' in source: 'precajole:///jqueryui/1.8.18/jquery-ui.js' at line: 0 precajole:///jqueryui/1.8.18/jquery-ui.js:0: Cannot read property 'stylev' of null

User reporting: http://stackoverflow.com/questions/12615179/jquery-ui-library-not-loaded-served-by-google-cdn-from-the-google-site-insert-h

kpreid commented 9 years ago

Comment #1 originally posted by felix8a on 2012-09-27T14:58:25.000Z:

<empty>

kpreid commented 9 years ago

Comment #2 originally posted by felix8a on 2012-09-27T15:26:37.000Z:

workaround: put some html before the

what's happening is jquery.ui.position.js has code var body = document.getElementsByTagName( "body" )[ 0 ], testElement = document.createElement( body ? "div" : "body" );

when there's html before the script, getElementsByTagName('body') succeeds, and document.createElement('div') succeeds.

when there's no html before the script, getElementsByTagName('body") returns undefined, and jquery-ui tries to do document.createElement('body'), which we don't support, so testElement is null, which blows up.

kpreid commented 9 years ago

Comment #3 originally posted by kpreid@google.com on 2012-09-27T15:32:10.000Z:

How is this a Caja bug? In-browser test case: data:text/html,%3Cscript%3Econsole.log(document.getElementsByTagName(%22body%22)%5B0%5D)%3C/script%3E logs undefined.

That said, we do have a bug in ES5 mode: IIRC, the

I tried moving including the entire library jquery/jquery-ui call script below as suggested, still not working?

kpreid commented 9 years ago

Comment #11 originally posted by kpreid.switchb.org on 2012-09-27T19:08:51.000Z:

When I move the entire set of

kpreid commented 9 years ago

Comment #13 originally posted by admin@adoprojecthope.org on 2012-09-27T19:56:47.000Z:

with updated JS URLs... still no luck.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

kpreid commented 9 years ago

Comment #14 originally posted by kpreid.switchb.org on 2012-09-27T20:09:43.000Z:

The cajoler rejects your input because it claims to be XHTML but has XML syntax errors. You must either have it not claim to be XML (remove the <!DOCTYPE ...XHTML...> and remove the xmlns=...) or fix the XML errors (missing quotes around the 's attributes, and no "/>" for and ); if you choose the latter path, I recommend using an XML parser or validator to confirm the correctness of your document.

You also need to change the relative URL for jquery-ui.css.

kpreid commented 9 years ago

Comment #15 originally posted by admin@adoprojecthope.org on 2012-09-27T22:30:50.000Z:

Put code thru markup validation and removed all extraneous code and tried a variety of different script placement options, still without any success...

<!DOCTYPE html>

APH Content Slider
kpreid commented 9 years ago

Comment #16 originally posted by kpreid.switchb.org on 2012-09-27T22:35:56.000Z:

I'm afraid I can't tell what the problem is. I ran your latest example in the playground and I can't tell what it might be supposed to do that it isn't doing. There's an error in the console "jQuery UI Tabs: Mismatching fragment identifier.", but that would seem to be something jQuery-specific that doesn't suggest something Caja might be doing wrong.

kpreid commented 9 years ago

Comment #17 originally posted by admin@adoprojecthope.org on 2012-09-27T23:08:22.000Z:

I appreciate all the help and time invested so far... are you aware of any instance where the jquery-ui library has been called successfully from within the Google sites "html box" tool?

It seems like calling a jqueryui library served by the Google CDN should not require this level of difficulty to roll-out a simple Content Slider; appears to defeat the purpose for electing Google sites for its supposed "ease" and "fault tolerance."

Still no success. Thank you very much for the support!

<!DOCTYPE html>

APH Content Slider
kpreid commented 9 years ago

Comment #18 originally posted by felix8a on 2012-09-28T00:07:26.000Z:

the $(document).ready() isn't firing, it seems to be a bad interaction with jquery and something we're doing with the