diff options
author | Leif Åstrand <leif@vaadin.com> | 2013-08-02 10:20:40 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2013-08-02 10:20:46 +0300 |
commit | d97cfbc9a1409582bbe4456f08f648921b7e3300 (patch) | |
tree | 35f60cb64968d342f28540db4e37a8205b82cd8f /client | |
parent | f5872981ddf8ff274a12ee59d7a0116e61bde602 (diff) | |
download | vaadin-framework-d97cfbc9a1409582bbe4456f08f648921b7e3300.tar.gz vaadin-framework-d97cfbc9a1409582bbe4456f08f648921b7e3300.zip |
Refine handling of null and empty URI fragments (#12207)
Change-Id: Ie133694b010a586c6336e9b04be7bcd94d2525e9
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/ui/ui/UIConnector.java | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/client/src/com/vaadin/client/ui/ui/UIConnector.java b/client/src/com/vaadin/client/ui/ui/UIConnector.java index 45b0a7ab9d..c6d2e1436b 100644 --- a/client/src/com/vaadin/client/ui/ui/UIConnector.java +++ b/client/src/com/vaadin/client/ui/ui/UIConnector.java @@ -40,6 +40,7 @@ import com.google.gwt.user.client.Event; import com.google.gwt.user.client.History; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; +import com.google.gwt.user.client.Window.Location; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.HandlerRegistration; @@ -352,14 +353,30 @@ public class UIConnector extends AbstractSingleComponentContainerConnector if (uidl.hasAttribute(UIConstants.LOCATION_VARIABLE)) { String location = uidl .getStringAttribute(UIConstants.LOCATION_VARIABLE); + String newFragment; + int fragmentIndex = location.indexOf('#'); if (fragmentIndex >= 0) { // Decode fragment to avoid double encoding (#10769) - getWidget().currentFragment = URL.decodePathSegment(location + newFragment = URL.decodePathSegment(location .substring(fragmentIndex + 1)); + + if (newFragment.isEmpty() + && Location.getHref().indexOf('#') == -1) { + // Ensure there is a trailing # even though History and + // Location.getHash() treat null and "" the same way. + Location.assign(Location.getHref() + "#"); + } + } else { + // No fragment in server-side location, but can't completely + // remove the browser fragment since that would reload the page + newFragment = ""; } - if (!getWidget().currentFragment.equals(History.getToken())) { - History.newItem(getWidget().currentFragment, true); + + getWidget().currentFragment = newFragment; + + if (!newFragment.equals(History.getToken())) { + History.newItem(newFragment, true); } } |