From 4172c64467c1b1f47251441799c00bd57f875f8b Mon Sep 17 00:00:00 2001 From: Assaf Arkin Date: Thu, 28 Jul 2011 20:49:40 -0700 Subject: [PATCH] [Closes #156] missing pathname support for window.location.href --- CHANGELOG.md | 2 ++ spec/history-spec.coffee | 9 +++++++++ src/zombie/history.coffee | 3 ++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8e852626..c393abc3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ zombie.js-changelog(7) -- Changelog Fixed: require.paths is deprecated [#158] +Fixd: missing pathname support for window.location.href [#156] + ### Version 0.9.6 2011-07-28 diff --git a/spec/history-spec.coffee b/spec/history-spec.coffee index 43fa3f496..e0dfc4f88 100644 --- a/spec/history-spec.coffee +++ b/spec/history-spec.coffee @@ -103,6 +103,15 @@ vows.describe("History").addBatch( "should add page to history": (browser)-> assert.length browser.window.history, 2 "should change location URL": (browser)-> assert.equal browser.location, "http://localhost:3003/history/boo" "should load document": (browser)-> assert.match browser.html(), /Eeek!/ + "change relative href": + zombie.wants "http://localhost:3003/" + topic: (browser)-> + browser.window.location.href = "/history/boo" + browser.window.document.addEventListener "DOMContentLoaded", => @callback null, browser + return + "should add page to history": (browser)-> assert.length browser.window.history, 2 + "should change location URL": (browser)-> assert.equal browser.location, "http://localhost:3003/history/boo" + "should load document": (browser)-> assert.match browser.html(), /Eeek!/ "change hash": zombie.wants "http://localhost:3003/" topic: (browser)-> diff --git a/src/zombie/history.coffee b/src/zombie/history.coffee index b1c6fea1f..79a550375 100644 --- a/src/zombie/history.coffee +++ b/src/zombie/history.coffee @@ -221,7 +221,8 @@ class Location # ### location.href => String @__defineGetter__ "href", -> url?.href # ### location.href = url - @__defineSetter__ "href", (url)-> history._assign url + @__defineSetter__ "href", (new_url)-> + history._assign URL.resolve(url, new_url) # Getter/setter for location parts. for prop in ["hash", "host", "hostname", "pathname", "port", "protocol", "search"] do (prop)=>