PiRSquared17 / activescaffold

Automatically exported from code.google.com/p/activescaffold
MIT License
0 stars 0 forks source link

JavaScript error #760

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
- As soon as I insert the active_scaffold_includes helper into the head of my 
HTML ERB template, I get the following JavaScript/HTML errors in Chrome and 
Safari:

Unmatched </head> encountered.  Ignoring tag.
Extra <body> encountered.  Migrating attributes back to the original <body> 
element and ignoring the tag.

If I then remove the active_scaffold_includes helper I no longer have this 
issue, but obviously ActiveScaffold AJAX functionality no longer works.

What is the expected output? What do you see instead?
I would expect not to see any errors which leads me to believe that the 
ActiveScaffold JavaScript is for some reason inserting extra tags into the HTML.

Please use labels and text to provide additional information.
I am using version 1.2RC1 of the ActiveScaffold plugin (latest)
I installed the render_component plugin too

Here are the gems I have installed:

  * actionmailer (2.3.8)
  * actionpack (2.3.8)
  * activerecord (2.3.8)
  * activeresource (2.3.8)
  * activesupport (2.3.8)
  * authlogic (2.1.5)
  * awesome_print (0.2.1)
  * aws-s3 (0.6.2)
  * builder (2.1.2)
  * columnize (0.3.1)
  * cucumber (0.8.5)
  * cucumber-rails (0.3.2)
  * database_cleaner (0.5.2)
  * diff-lcs (1.1.2)
  * factory_girl (1.3.1)
  * friendly_id (3.0.6)
  * gherkin (2.1.5)
  * haml (3.0.13)
  * hoptoad_notifier (2.3.2)
  * json_pure (1.4.3)
  * linecache (0.43)
  * mime-types (1.16)
  * newrelic_rpm (2.12.3)
  * nokogiri (1.4.2)
  * paperclip (2.3.3)
  * pg (0.9.0)
  * rack (1.1.0)
  * rack-test (0.5.3)
  * rails (2.3.8)
  * rake (0.8.7)
  * rspec (1.3.0)
  * rspec-rails (1.3.2)
  * ruby-debug (0.10.3)
  * ruby-debug-base (0.10.3)
  * shoulda (2.10.3)
  * sqlite3-ruby (1.2.5)
  * term-ansicolor (1.0.5)
  * trollop (1.16.2)
  * webrat (0.7.1)
  * xml-simple (1.0.12)

Here is the HTML header that is generated which causes the error:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns='http://www.w3.org/1999/xhtml'>
  <head>
    <title>
      Title
    </title>
    <meta content='text/html; charset=utf-8' http-equiv='Content-Type' />
    <meta content='en-GB' http-equiv='Content-Language' />
    <script src="/javascripts/prototype.js?1269956686" type="text/javascript"></script>
    <script src="/javascripts/active_scaffold/default/active_scaffold.js?1279787832" type="text/javascript"></script>
    <script src="/javascripts/active_scaffold/default/dhtml_history.js?1279787832" type="text/javascript"></script>
    <script src="/javascripts/active_scaffold/default/form_enhancements.js?1279787832" type="text/javascript"></script>
    <script src="/javascripts/active_scaffold/default/rico_corner.js?1279787832" type="text/javascript"></script>

    <link href="/stylesheets/active_scaffold/default/stylesheet.css?1279787832" media="screen" rel="stylesheet" type="text/css" />
    <!--[if IE]><link href="/stylesheets/active_scaffold/default/stylesheet-ie.css?1279787832" media="screen" rel="stylesheet" type="text/css" /><![endif]-->
    <script type="text/javascript">
    //<![CDATA[

    var action_link_close = ActiveScaffold.ActionLink.Abstract.prototype.close;
    ActiveScaffold.ActionLink.Abstract.prototype.close = function() {
      this.adapter.select('textarea').each(function(elem) {
       if (/_editor$/.test(elem.id)) {if (CKEDITOR.instances[elem.id]) {CKEDITOR.instances[elem.id].destroy(false);}}
      });
      action_link_close.apply(this);
    };

    //]]>
    </script>
    <script src="/javascripts/ckeditor/ckeditor.js?1279748460" type="text/javascript"></script>

  </head>
  <body>
    .....

Original issue reported on code.google.com by matthew....@gmail.com on 22 Jul 2010 at 10:46

GoogleCodeExporter commented 9 years ago
It's working here, do you get that error without ckeditor bridge?

Original comment by sergio.c...@gmail.com on 23 Jul 2010 at 7:21

GoogleCodeExporter commented 9 years ago
Yup, removed CKEditor and ckeditor_bridge altogether and still got the same 
issue.

Original comment by matthew....@gmail.com on 23 Jul 2010 at 6:01

GoogleCodeExporter commented 9 years ago
I can't see any error in that HTML header. Are you using embedded scaffolds? 
Embedded scaffolds were rendering layout again, which put doctype head and body 
declaration inside the main body tag.

Original comment by sergio.c...@gmail.com on 26 Jul 2010 at 6:37

GoogleCodeExporter commented 9 years ago

Original comment by sergio.c...@gmail.com on 23 Aug 2010 at 7:13

GoogleCodeExporter commented 9 years ago
Sorry I did not reply, I missed the notification somehow.
Nope, I am not using embedded scaffolds.

Original comment by matthew....@gmail.com on 23 Aug 2010 at 9:34

GoogleCodeExporter commented 9 years ago
I can't see any extra body tag or unmatched </head> tag. Can you look at full 
html code and look for extra head or body tags?

Original comment by sergio.c...@gmail.com on 24 Aug 2010 at 7:08

GoogleCodeExporter commented 9 years ago
Yup, neither can I, which makes me think that perhaps at render time the 
JavaScript is trying to insert these additional closing tags somehow.    

The specific errors reported by Chrome & Safari are:
Unmatched </head> encountered.  Ignoring tag. articles:49
Extra <body> encountered.  Migrating attributes back to the original <body> 
element and ignoring the tag. articles:50

Mozilla does not report any errors, so not sure what that means.

Sorry I can't be of more help.

Matt

Original comment by matthew....@gmail.com on 26 Aug 2010 at 11:46

GoogleCodeExporter commented 9 years ago
Look at http://code.google.com/p/chromium/issues/detail?id=44274
According that bug an empty tag in head can break Chrome. I can't see any empty 
tag, but I think line 49 is not in your report. Can you post firsts 50 lines?

Original comment by sergio.c...@gmail.com on 27 Aug 2010 at 7:15

GoogleCodeExporter commented 9 years ago
Or better, attach that page, only html

Original comment by sergio.c...@gmail.com on 27 Aug 2010 at 7:15

GoogleCodeExporter commented 9 years ago
Attached is the actual HTML source generated, and also the rendered HTML source 
(i.e. if some JavaScript modifies the DOM then Chrome will reflect those 
changes in the rendered HTML source).  Hope that helps.

Original comment by matthew....@gmail.com on 27 Aug 2010 at 9:21

Attachments:

GoogleCodeExporter commented 9 years ago
I can't see anything wrong, and opening source in chrome doesn't give me any 
errors. Does opening that file in chrome gives you any error?

Can I access to that web? You can send me the url in private if you prefer it.

Original comment by sergio.c...@gmail.com on 30 Aug 2010 at 8:16

GoogleCodeExporter commented 9 years ago
Nope, no errors, but that is because the dependent files (JS & CSS) are not 
loaded.  I can send you details for the URL, please can you give me your 
contact details so I can send it to you in private.

Original comment by matthew....@gmail.com on 31 Aug 2010 at 11:37

GoogleCodeExporter commented 9 years ago
my username @gmail.com

Original comment by sergio.c...@gmail.com on 1 Sep 2010 at 7:26

GoogleCodeExporter commented 9 years ago
dhtml_history.js was adding some elements with document.write.

I have delayed creating infrastructure to window.onload, as initializing was 
done. The right fix would be changing with document.body.appendChild, but it's 
harder, and needs more testing.

Original comment by sergio.c...@gmail.com on 2 Sep 2010 at 3:04

GoogleCodeExporter commented 9 years ago
I see the fix was reverted a few hours after it was committed to the git 
repository.  Therefore it is not surprising that I am still seeing this issue - 
please can you change the Status back from Fixed to Open?

Is there a workaround I can use until the right fix is committed?  Thanks!

Original comment by adam.spi...@gmail.com on 28 Nov 2010 at 2:33

GoogleCodeExporter commented 9 years ago
Note that this also breaks Capybara's save_and_open_page:

http://groups.google.com/group/ruby-capybara/browse_thread/thread/6ab9acb563007a
4a

Original comment by adam.spi...@gmail.com on 28 Nov 2010 at 3:10

GoogleCodeExporter commented 9 years ago
Please post commit id if you have seen it reverted, it's easy for me to commit 
it again, I forgot to post commit id here.

Original comment by sergio.c...@gmail.com on 29 Nov 2010 at 8:46