Hi, I am using Rails 2.2.2 and have some javascript in my html.erb file in the body of the document, inside script tags. The script (which works as intended) contains the line for(var i=0; i<boxes.length; i++) In my functional tests I use assert_select and it is generating a warning "ignoring attempt to close boxes with script". It appears to be interpreting the text "<boxes" as the start of a tag. The only way I have found to get round it is to add a javascript comment "// </boxes>" to the end of the line. Is this a bug in assert_select or am I doing something foolish in my ignorance? Colin -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 13 Dec 2008, at 17:04, Colin Law wrote:> > Hi, I am using Rails 2.2.2 and have some javascript in my html.erb > file > in the body of the document, inside script tags. The script (which > works > as intended) contains the lineis the javascript inside a <![CDATA[ section ? fred> > for(var i=0; i<boxes.length; i++) > In my functional tests I use assert_select and it is generating a > warning "ignoring attempt to close boxes with script". It appears > to be > interpreting the text "<boxes" as the start of a tag. The only way I > have found to get round it is to add a javascript comment "// </ > boxes>" > to the end of the line. > Is this a bug in assert_select or am I doing something foolish in my > ignorance? > > Colin > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On 13 Dec 2008, at 17:04, Colin Law wrote: > >> >> Hi, I am using Rails 2.2.2 and have some javascript in my html.erb >> file >> in the body of the document, inside script tags. The script (which >> works >> as intended) contains the line > is the javascript inside a <![CDATA[ section ? > > fredIt wasn''t but it is now and is working, many thanks. Colin -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Colin Law wrote:> for(var i=0; i<boxes.length; i++)> Is this a bug in assert_select or am I doing something foolish in my > ignorance?Ultimately the fault lies in zillions of web pages written with Notepad. The Law (actually the Recommendations) say thou shalt escape < with <. But not all web pages treat & correctly, so browsers in turn cannot enforce the exact rules. And our tools follow suit! You might be able to get by with < there. Whatever the fix, you should move all but trivial JS up into application.js or some similar included file. We dealt with && recently (in JS code we inexplicably had to add <% %> tags to) by writing function aaaand(q,k){ return q && k; }. We put aaaand up in application.js, but note this hack turns off boolean short-circuiting! -- Phlip --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Reasonably Related Threads
- assert_select for <p><b>text</b>value</p>
- What does :count actually mean in assert_select?
- <b> tag in HTML 5 (was Re: Re: assert_select for <p><b>text</b>value</p>)
- assert_select with respond_to JS or xhr?
- assert_select trying to verify the presence of a textarea