Merge pull request from bundyo/fix-window-open-options

Fix window.open options parsing
This commit is contained in:
Cheng Zhao 2015-02-27 12:24:13 -08:00
commit 70a83ad069

View file

@ -26,21 +26,25 @@ unless process.guestInstanceId?
# Make the browser window or guest view emit "new-window" event. # Make the browser window or guest view emit "new-window" event.
window.open = (url, frameName='', features='') -> window.open = (url, frameName='', features='') ->
options = {} options = {}
for feature in features.split ',' ints = [ 'x', 'y', 'width', 'height', 'min-width', 'max-width', 'min-height', 'max-height', 'zoom-factor' ]
[name, value] = feature.split '=' # Make sure to get rid of excessive whitespace in the property name
for feature in features.split /,\s*/
[name, value] = feature.split /\s*=/
options[name] = options[name] =
if value is 'yes' if value is 'yes' or value is '1'
true true
else if value is 'no' else if value is 'no' or value is '0'
false false
else else
value value
options.x ?= options.left options.x ?= options.left if options.left
options.y ?= options.top options.y ?= options.top if options.top
options.title ?= name options.title ?= name
options.width ?= 800 options.width ?= 800
options.height ?= 600 options.height ?= 600
(options[name] = parseInt(options[name], 10) if options[name]?) for name in ints
guestId = ipc.sendSync 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', url, frameName, options guestId = ipc.sendSync 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', url, frameName, options
if guestId if guestId
new FakeWindow(guestId) new FakeWindow(guestId)