Forum: Ruby on Rails strict XHTML compliant ajax library

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Lin W. (Guest)
on 2009-02-27 09:20
problem : i have to develope a app using ajax features and it has to run
in an environment(web tv related) which is very strict about XHTML
compliance.

and ajax codes generated by rails doesnt seem to be compliant.
(they work on normal webpages , but not in the webtv env)

other than writing my own ajax codes and including them as helpers.

is there any other way ?



thanks
Phlip (Guest)
on 2009-02-27 15:19
(Received via mailing list)
Lin Wj wrote:

> problem : i have to develope a app using ajax features and it has to run
> in an environment(web tv related) which is very strict about XHTML
> compliance.
>
> and ajax codes generated by rails doesnt seem to be compliant.
> (they work on normal webpages , but not in the webtv env)
>
> other than writing my own ajax codes and including them as helpers.
>
> is there any other way ?

Install my assert_xpath, and activate its assert_javascript.

(This currently uses Javascript-PurePerl, and I hope to upgrade that to
a Ruby
solution shortly.)

Each page needs a test case like this:

   def test_foo_is_tidy
     get :foo
     assert_tidy
   end

If you put "Strict XHTML" into your DOCTYPE, then tidy should enforce
that.

Next, to test an Ajax call, you would do this:

   xhr :get, :xhr_change_the_frob
   assert_js_replace_html :frob do
     assert_xpath :'form/input[ @name = "baz" and @value = "42" ]'
   end

assert_js_replace_html lexes the returned JavaScript, finds the
Element.update()
command, and parses the XHTML inside it. The do-end block sees that
XHTML, so
you can do further queries on it.

All these tests will fail if the XHTML has a single ill-formed tag.

At my day-job, we enforce strict "Transitional XHTML", even though we
only
target wildly forgiving browsers, and even though our production code
could get
away with sloppy HTML. We do this because enforcing XHTML makes all our
view
tests much easier to write.

--
   Phlip
This topic is locked and can not be replied to.