Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@binaryphile
Copy link
Contributor

I ran across this issue when I added an override to the spree/checkout/_address view.

Simply by virtue of adding a deface override to that view (irrespective of what you're overriding), the resulting html renders in such a way that it breaks checkout.js, which is responsible for showing/hiding the state field of the billing and shipping addresses based on whether or not a country has states configured.

This results in the state picker not properly converting to a text input when the user's chosen country does not have states configured for it.

I tracked down the cause to invalid html in the view itself. Evidently, deface's processing "corrects" the invalid html, causing the output to no longer have the structure that the selector in checkout.js expect, so the functions defined there never get called.

The offending tag is the noscript block that lies in the paragraph that houses the state select/input field. According to the html4 dtd, noscript is a block-level element (unlike <script>) which cannot be placed inside a paragraph because paragraphs can only contain inline elements.

Because of this, the deface processing adds a closing </p>, moving the paragraph contents outside of the paragraph and the checkout.js selector's p#bstate/sstate.

The simplest fix is to move the noscript block outside and below the paragraph. I've tested this and it works both when the browser supports javascript as well as when javascript is turned off.

@radar
Copy link
Contributor

radar commented Jul 20, 2012

Thanks for the great explanation of the issue. I've now pulled in your change into 1-1-stable with @74e0981b9d0aaaf9ae86762de5c6566422dfd6fa and master with @60c9fa41f1e923bdcd080498305d378472d91e00.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants