From 2a30a02f015dd54846bb62d1f05e82b3cf76ef9f Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Tue, 27 Jul 2010 15:54:50 -0700 Subject: fix preventDefault for events --- example/temp.html | 7 ++++++- scenario/widgets.html | 8 ++++---- src/directives.js | 4 ++-- src/jqLite.js | 15 ++++----------- src/widgets.js | 5 +++-- test/directivesSpec.js | 14 ++++++++------ 6 files changed, 27 insertions(+), 26 deletions(-) diff --git a/example/temp.html b/example/temp.html index 337f7fba..f21d3f5c 100644 --- a/example/temp.html +++ b/example/temp.html @@ -1,10 +1,15 @@ + - Hello {{'World'}}! +
+ outter +
inner
+ link +
diff --git a/scenario/widgets.html b/scenario/widgets.html index 2626843d..d5285ea6 100644 --- a/scenario/widgets.html +++ b/scenario/widgets.html @@ -72,12 +72,12 @@ Buttons - ng-change
ng:click + ng:change
ng:click
-
-
-
+
+
+
action
diff --git a/src/directives.js b/src/directives.js index ffe37890..9aadbd11 100644 --- a/src/directives.js +++ b/src/directives.js @@ -199,10 +199,10 @@ angularWidget("@ng:repeat", function(expression, element){ angularDirective("ng:click", function(expression, element){ return function(element){ var self = this; - element.bind('click', function(){ + element.bind('click', function(event){ self.$tryEval(expression, element); self.$root.$eval(); - return false; + event.preventDefault(); }); }; }); diff --git a/src/jqLite.js b/src/jqLite.js index cff9ae00..26ca6dea 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -104,19 +104,12 @@ JQLite.prototype = { eventHandler = bind[type]; if (!eventHandler) { bind[type] = eventHandler = function(event) { - var bubbleEvent = false; + if (!event.preventDefault) { + event.returnValue = false; + } foreach(eventHandler.fns, function(fn){ - bubbleEvent = bubbleEvent || fn.call(self, event); + fn.call(self, event); }); - if (!bubbleEvent) { - if (msie) { - event.returnValue = false; - event.cancelBubble = true; - } else { - event.preventDefault(); - event.stopPropagation(); - } - } }; eventHandler.fns = []; addEventListener(element, type, eventHandler); diff --git a/src/widgets.js b/src/widgets.js index 5f0fcf7c..87a302fa 100644 --- a/src/widgets.js +++ b/src/widgets.js @@ -198,14 +198,15 @@ function inputWidget(events, modelAccessor, viewAccessor, initFn) { this.$eval(element.attr('ng:init')||''); // Don't register a handler if we are a button (noopAccessor) and there is no action if (action || modelAccessor !== noopAccessor) { - element.bind(events, function(){ + element.bind(events, function(event){ model.set(view.get()); lastValue = model.get(); scope.$tryEval(action, element); scope.$root.$eval(); // if we have noop initFn than we are just a button, // therefore we want to prevent default action - return initFn != noop; + if(initFn == noop) + event.preventDefault(); }); } view.set(lastValue = model.get()); diff --git a/test/directivesSpec.js b/test/directivesSpec.js index 8a7da41d..278f9c4c 100644 --- a/test/directivesSpec.js +++ b/test/directivesSpec.js @@ -160,13 +160,15 @@ describe("directives", function(){ expect(scope.$get('count')).toEqual(1); }); - it('should ng:click', function(){ - var scope = compile('
'); - scope.$eval(); - expect(scope.$get('clicked')).toBeFalsy(); + describe('ng:click', function(){ + it('should fire event', function(){ + var scope = compile('
'); + scope.$eval(); + expect(scope.$get('clicked')).toBeFalsy(); - element.trigger('click'); - expect(scope.$get('clicked')).toEqual(true); + element.trigger('click'); + expect(scope.$get('clicked')).toEqual(true); + }); }); it('should ng:class', function(){ -- cgit v1.2.3 From 6bd8006edcbfe1dc1be8cb865fbcfe25157fe117 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Jul 2010 16:53:23 -0700 Subject: fix IE native mothods are not functions, and preventDefault --- src/Angular.js | 19 ++++++++++++------- src/Parser.js | 13 +++++-------- src/jqLite.js | 4 +++- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/Angular.js b/src/Angular.js index 850fe34c..32e3ccf7 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -293,13 +293,18 @@ function escapeAttr(html) { function bind(_this, _function) { var curryArgs = slice.call(arguments, 2, arguments.length); - return curryArgs.length == 0 ? - function() { - return _function.apply(_this, arguments); - } : - function() { - return _function.apply(_this, curryArgs.concat(slice.call(arguments, 0, arguments.length))); - }; + if (typeof _function == 'function') { + return curryArgs.length == 0 ? + function() { + return _function.apply(_this, arguments); + } : + function() { + return _function.apply(_this, curryArgs.concat(slice.call(arguments, 0, arguments.length))); + } + } else { + // in IE, native methonds ore not functions and so they can not be bound (but they don't need to be) + return function(a, b, c, d, e){ return _function(a, b, c, d, e); }; + } } function outerHTML(node) { diff --git a/src/Parser.js b/src/Parser.js index 5c2307e4..5eb75713 100644 --- a/src/Parser.js +++ b/src/Parser.js @@ -599,14 +599,11 @@ Parser.prototype = { for ( var i = 0; i < argsFn.length; i++) { args.push(argsFn[i](self)); } - var fnPtr = fn(self); - if (typeof fnPtr === 'function') { - return fnPtr.apply(self, args); - } else if (fnPtr === undefined) { - return fnPtr; - } else { - throw "Expression '" + fn.isAssignable + "' is not a function."; - } + var fnPtr = fn(self) || noop; + // IE stupidity! + return fnPtr.apply ? + fnPtr.apply(self, args) : + fnPtr(args[0], args[1], args[2], args[3], args[4]); }; }, diff --git a/src/jqLite.js b/src/jqLite.js index 26ca6dea..04682754 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -105,7 +105,9 @@ JQLite.prototype = { if (!eventHandler) { bind[type] = eventHandler = function(event) { if (!event.preventDefault) { - event.returnValue = false; + event.preventDefault = function(){ + event.returnValue = false; + } } foreach(eventHandler.fns, function(fn){ fn.call(self, event); -- cgit v1.2.3 From 1b768b84439e725010acc943ebfda462e49d3704 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 29 Jul 2010 12:50:14 -0700 Subject: refactored $location service so that it correctly updates under all conditions --- example/temp.html | 86 +++++++++++++++++++++++++++++++++++++++---- scenario/location.html | 15 ++++++++ src/Angular.js | 6 +-- src/angular-bootstrap.js | 6 +-- src/formatters.js | 1 + src/jqLite.js | 2 +- src/services.js | 95 ++++++++++++++++++++++++++++-------------------- test/servicesSpec.js | 19 +++++----- 8 files changed, 165 insertions(+), 65 deletions(-) create mode 100644 scenario/location.html diff --git a/example/temp.html b/example/temp.html index f21d3f5c..b238c185 100644 --- a/example/temp.html +++ b/example/temp.html @@ -1,15 +1,85 @@ - + - -
- outter -
inner
- link -
+ + +

Tic-Tac-Toe

+Next Player: {{nextMove}} +
Player {{winner}} has won!
+ + + + +
{{cell}}
+ + - + \ No newline at end of file diff --git a/scenario/location.html b/scenario/location.html new file mode 100644 index 00000000..a162636b --- /dev/null +++ b/scenario/location.html @@ -0,0 +1,15 @@ + + + + + + + +
$location={{$location}}
+
+ href:
+ hash:
+ hashPath:
+ hashSearch:
+ + diff --git a/src/Angular.js b/src/Angular.js index 32e3ccf7..80acddf0 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -300,10 +300,10 @@ function bind(_this, _function) { } : function() { return _function.apply(_this, curryArgs.concat(slice.call(arguments, 0, arguments.length))); - } + }; } else { - // in IE, native methonds ore not functions and so they can not be bound (but they don't need to be) - return function(a, b, c, d, e){ return _function(a, b, c, d, e); }; + // in IE, native methods ore not functions and so they can not be bound (but they don't need to be) + return _function; } } diff --git a/src/angular-bootstrap.js b/src/angular-bootstrap.js index 90e1104e..e055371a 100644 --- a/src/angular-bootstrap.js +++ b/src/angular-bootstrap.js @@ -22,16 +22,14 @@ * THE SOFTWARE. */ (function(previousOnLoad){ - var filename = /(.*)\/angular-(.*).js(#(.*))?/, + var filename = /(.*)\/angular-(.*).js(#.*)?/, scripts = document.getElementsByTagName("SCRIPT"), serverPath, - config, match; for(var j = 0; j < scripts.length; j++) { match = (scripts[j].src || "").match(filename); if (match) { serverPath = match[1]; - config = match[4]; } } @@ -63,7 +61,7 @@ try { if (previousOnLoad) previousOnLoad(); } catch(e) {} - angularInit(parseKeyValue(config)); + angularInit(parseKeyValue(angularJsConfig(document))); }; })(window.onload); diff --git a/src/formatters.js b/src/formatters.js index 40462cf3..ca1ce83e 100644 --- a/src/formatters.js +++ b/src/formatters.js @@ -5,6 +5,7 @@ var NUMBER = /^\s*[-+]?\d*(\.\d*)?\s*$/; extend(angularFormatter, { 'noop':formatter(identity, identity), + 'json':formatter(toJson, fromJson), 'boolean':formatter(toString, toBoolean), 'number':formatter(toString, function(obj){ diff --git a/src/jqLite.js b/src/jqLite.js index 04682754..22b3c070 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -107,7 +107,7 @@ JQLite.prototype = { if (!event.preventDefault) { event.preventDefault = function(){ event.returnValue = false; - } + }; } foreach(eventHandler.fns, function(fn){ fn.call(self, event); diff --git a/src/services.js b/src/services.js index 106f8954..3dd7df09 100644 --- a/src/services.js +++ b/src/services.js @@ -7,61 +7,78 @@ var URL_MATCH = /^(file|ftp|http|https):\/\/(\w+:{0,1}\w*@)?([\w\.-]*)(:([0-9]+) var HASH_MATCH = /^([^\?]*)?(\?([^\?]*))?$/; var DEFAULT_PORTS = {'http': 80, 'https': 443, 'ftp':21}; angularService("$location", function(browser){ - var scope = this, location = {parse:parseUrl, toString:toString}; - var lastHash, lastUrl; + var scope = this, + location = {parse:parseUrl, toString:toString, update:update}, + lastLocation = {}; + + browser.watchUrl(function(url){ + update(url); + scope.$root.$eval(); + }); + this.$onEval(PRIORITY_FIRST, update); + this.$onEval(PRIORITY_LAST, update); + update(browser.getUrl()); + return location; + + function update(href){ + if (href) { + parseUrl(href); + } else { + href = check('href') || check('protocol', '://', 'host', ':', 'port', '', 'path', '?', 'search'); + var hash = check('hash'); + if (isUndefined(hash)) hash = check('hashPath', '?', 'hashSearch'); + if (isDefined(hash)) { + href = (href || location.href).split('#')[0]; + href+= '#' + hash; + } + if (isDefined(href)) { + parseUrl(href); + browser.setUrl(href); + } + } + } + + function check() { + var i = -1, + length=arguments.length, + name, seperator, parts = [], + value, same = true; + for(; i'); var log = ''; @@ -136,15 +144,6 @@ describe("service", function(){ scope.$eval(); expect(log).toEqual('/abc;'); }); - - it("should parse url which contains - in host", function(){ - scope.$location.parse('http://a-b1.c-d.09/path'); - expect(scope.$location.href).toEqual('http://a-b1.c-d.09/path'); - expect(scope.$location.protocol).toEqual('http'); - expect(scope.$location.host).toEqual('a-b1.c-d.09'); - expect(scope.$location.path).toEqual('/path'); - }); - }); describe("$invalidWidgets", function(){ -- cgit v1.2.3 From 03aac8b0ab17a9e8a41c5794f1e838315875051a Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 29 Jul 2010 15:26:10 -0700 Subject: fix broken build, fix #autobind and css loading --- example/temp.html | 15 +++++++-------- jsTestDriver-jquery.conf | 1 + jsTestDriver.conf | 1 + src/Angular.js | 25 +++++++++++++++++++------ src/angular-bootstrap.js | 4 ++-- src/angular.suffix | 2 +- 6 files changed, 31 insertions(+), 17 deletions(-) diff --git a/example/temp.html b/example/temp.html index b238c185..b6752d57 100644 --- a/example/temp.html +++ b/example/temp.html @@ -2,7 +2,7 @@ + src="../angular-debug.js" ng:autobind ng:css="css/angular.css"> @@ -17,10 +17,7 @@ function TicTacToeCntl(){ 'cursor': 'pointer' }; this.reset(); - this.$watch('$location.hashPath', this.setMemento); - this.$onEval(function(){ - this.$location.hashPath = this.getMemento(); - }); + this.$watch('$location.hashPath', this.readUrl); } TicTacToeCntl.prototype = { dropPiece: function(row, col) { @@ -28,6 +25,7 @@ TicTacToeCntl.prototype = { this.board[row][col] = this.nextMove; this.nextMove = this.nextMove == 'X' ? 'O' : 'X'; this.grade(); + this.setUrl(); } }, reset: function(){ @@ -38,6 +36,7 @@ TicTacToeCntl.prototype = { ]; this.nextMove = 'X'; this.winner = ''; + this.setUrl(); }, grade: function(){ var b = this.board; @@ -50,14 +49,14 @@ TicTacToeCntl.prototype = { function diagonal(i) { return same(b[0][1-i], b[1][1], b[2][1+i]);} function same(a, b, c) { return (a==b && b==c) ? a : '';}; }, - getMemento: function(){ + setUrl: function(){ var rows = []; angular.foreach(this.board, function(row){ rows.push(row.join(',')); }); - return rows.join(';') + '/' + this.nextMove; + this.$location.hashPath = rows.join(';') + '/' + this.nextMove; }, - setMemento: function(value) { + readUrl: function(value) { if (value) { value = value.split('/'); this.nextMove = value[1]; diff --git a/jsTestDriver-jquery.conf b/jsTestDriver-jquery.conf index 34538bce..e5dac727 100644 --- a/jsTestDriver-jquery.conf +++ b/jsTestDriver-jquery.conf @@ -6,6 +6,7 @@ load: - lib/jquery/jquery-1.4.2.js - test/jquery_alias.js - src/Angular.js + - src/JSON.js - src/*.js - src/scenario/Runner.js - src/scenario/*.js diff --git a/jsTestDriver.conf b/jsTestDriver.conf index 16bcf1db..bcd01694 100644 --- a/jsTestDriver.conf +++ b/jsTestDriver.conf @@ -6,6 +6,7 @@ load: - lib/jquery/jquery-1.4.2.js - test/jquery_remove.js - src/Angular.js + - src/JSON.js - src/*.js - src/scenario/Runner.js - src/scenario/*.js diff --git a/src/Angular.js b/src/Angular.js index 80acddf0..a9362c69 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -369,22 +369,35 @@ function toKeyValue(obj) { function angularInit(config){ if (config.autobind) { - var scope = compile(window.document, null, {'$config':config}); // TODO default to the source of angular.js - scope.$browser.addCss('css/angular.css'); + var scope = compile(window.document, null, {'$config':config}); + if (config.css) + scope.$browser.addCss(config.base_url + config.css); scope.$init(); } } -function angularJsConfig(document) { - var filename = /(.*)\/angular(-(.*))?.js(#(.*))?/, +function angularJsConfig(document, config) { + var filename = /^(.*)\/angular(-([^\/]*))?.js(#(.*))?$/, scripts = document.getElementsByTagName("script"), match; + config = extend({ + base_url: '', + css: '../css/angular.css' + }, config); for(var j = 0; j < scripts.length; j++) { match = (scripts[j].src || "").match(filename); if (match) { - return match[5]; + config.base_url = match[1] + '/'; + extend(match, config, toKeyValue(match[5])); + eachAttribute(jqLite(scripts[j]), function(value, name){ + if (/^ng:/.exec(name)) { + name = name.substring(3).replace(/-/g, '_'); + if (name == 'autobind') value = true; + config[name] = value; + } + }); } } - return ""; + return config; } diff --git a/src/angular-bootstrap.js b/src/angular-bootstrap.js index e055371a..1f03b8a3 100644 --- a/src/angular-bootstrap.js +++ b/src/angular-bootstrap.js @@ -22,7 +22,7 @@ * THE SOFTWARE. */ (function(previousOnLoad){ - var filename = /(.*)\/angular-(.*).js(#.*)?/, + var filename = /^(.*)\/angular-bootstrap.js(#.*)?$/, scripts = document.getElementsByTagName("SCRIPT"), serverPath, match; @@ -61,7 +61,7 @@ try { if (previousOnLoad) previousOnLoad(); } catch(e) {} - angularInit(parseKeyValue(angularJsConfig(document))); + angularInit(angularJsConfig(document)); }; })(window.onload); diff --git a/src/angular.suffix b/src/angular.suffix index 36d73df2..7e86c5d5 100644 --- a/src/angular.suffix +++ b/src/angular.suffix @@ -3,7 +3,7 @@ try { if (previousOnLoad) previousOnLoad(); } catch(e) {} - angularInit(parseKeyValue(angularJsConfig(document))); + angularInit(angularJsConfig(document)); }; })(window, document, window.onload); -- cgit v1.2.3 From af1eb6914e6e4b72e6baabb075138b7716184ff7 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 29 Jul 2010 15:38:14 -0700 Subject: keep #autobind for backward compatibility --- src/Angular.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Angular.js b/src/Angular.js index a9362c69..33bf86ea 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -389,7 +389,7 @@ function angularJsConfig(document, config) { match = (scripts[j].src || "").match(filename); if (match) { config.base_url = match[1] + '/'; - extend(match, config, toKeyValue(match[5])); + extend(config, parseKeyValue(match[5])); eachAttribute(jqLite(scripts[j]), function(value, name){ if (/^ng:/.exec(name)) { name = name.substring(3).replace(/-/g, '_'); -- cgit v1.2.3 From cdda664f8990351453baa26fc3dcd53329e72e68 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Fri, 30 Jul 2010 10:56:36 -0700 Subject: fix up the $location encoding --- scenario/location.html | 4 ++++ src/Angular.js | 6 +++--- src/services.js | 12 ++++++++++-- test/servicesSpec.js | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/scenario/location.html b/scenario/location.html index a162636b..75041615 100644 --- a/scenario/location.html +++ b/scenario/location.html @@ -6,6 +6,10 @@
$location={{$location}}
+ Hash Search: +
href:
hash:
diff --git a/src/Angular.js b/src/Angular.js index 33bf86ea..a6fc28b3 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -352,8 +352,8 @@ function parseKeyValue(keyValue) { foreach((keyValue || "").split('&'), function(keyValue){ if (keyValue) { key_value = keyValue.split('='); - key = decodeURIComponent(key_value[0]); - obj[key] = key_value[1] ? decodeURIComponent(key_value[1]) : true; + key = unescape(key_value[0]); + obj[key] = key_value[1] ? unescape(key_value[1]) : true; } }); return obj; @@ -362,7 +362,7 @@ function parseKeyValue(keyValue) { function toKeyValue(obj) { var parts = []; foreach(obj, function(value, key){ - parts.push(encodeURIComponent(key) + '=' + encodeURIComponent(value)); + parts.push(escape(key) + '=' + escape(value)); }); return parts.length ? parts.join('&') : ''; } diff --git a/src/services.js b/src/services.js index 3dd7df09..6a52d25a 100644 --- a/src/services.js +++ b/src/services.js @@ -26,7 +26,7 @@ angularService("$location", function(browser){ } else { href = check('href') || check('protocol', '://', 'host', ':', 'port', '', 'path', '?', 'search'); var hash = check('hash'); - if (isUndefined(hash)) hash = check('hashPath', '?', 'hashSearch'); + if (isUndefined(hash)) hash = checkHashPathSearch(); if (isDefined(hash)) { href = (href || location.href).split('#')[0]; href+= '#' + hash; @@ -53,6 +53,14 @@ angularService("$location", function(browser){ return same ? undefined : parts.join(''); } + function checkHashPathSearch(){ + if (lastLocation.hashPath === location.hashPath && + equals(lastLocation.hashSearch, location.hashSearch) ) + return undefined; + var url = toKeyValue(location.hashSearch); + return escape(location.hashPath) + (url ? '?' + url : ''); + } + function parseUrl(url){ if (isDefined(url)) { var match = URL_MATCH.exec(url); @@ -67,7 +75,7 @@ angularService("$location", function(browser){ if (location.hash) location.hash = location.hash.substr(1); match = HASH_MATCH.exec(location.hash); - location.hashPath = match[1] || ''; + location.hashPath = unescape(match[1] || ''); location.hashSearch = parseKeyValue(match[3]); copy(location, lastLocation); diff --git a/test/servicesSpec.js b/test/servicesSpec.js index cb5c9b30..ffd01267 100644 --- a/test/servicesSpec.js +++ b/test/servicesSpec.js @@ -91,7 +91,7 @@ describe("service", function(){ scope.$location.hashPath = 'page=http://path'; scope.$location.hashSearch = {k:'a=b'}; - expect(scope.$location.toString()).toEqual('http://host:123/p/a/t/h.html?query=value#page=http://path?k=a%3Db'); + expect(scope.$location.toString()).toEqual('http://host:123/p/a/t/h.html?query=value#page%3Dhttp%3A//path?k=a%3Db'); }); it('should parse file://', function(){ -- cgit v1.2.3 From 1e1c8c82f98f4a6d6ed77e7bf34ac5177fe33d4f Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Fri, 30 Jul 2010 11:45:52 -0700 Subject: minor speed improvements or URL parsing --- src/services.js | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/services.js b/src/services.js index 6a52d25a..8df23564 100644 --- a/src/services.js +++ b/src/services.js @@ -24,7 +24,7 @@ angularService("$location", function(browser){ if (href) { parseUrl(href); } else { - href = check('href') || check('protocol', '://', 'host', ':', 'port', '', 'path', '?', 'search'); + href = check('href') || checkProtocol(); var hash = check('hash'); if (isUndefined(hash)) hash = checkHashPathSearch(); if (isDefined(hash)) { @@ -38,19 +38,22 @@ angularService("$location", function(browser){ } } - function check() { - var i = -1, - length=arguments.length, - name, seperator, parts = [], - value, same = true; - for(; i" + html + ""); var scope = compiler.compile(e)(e); @@ -94,7 +94,7 @@ describe('compiler', function(){ }); it('should process markup before directives', function(){ - textMarkup.push(function(text, textNode, parentNode) { + markup.push(function(text, textNode, parentNode) { if (text == 'middle') { expect(textNode.text()).toEqual(text); parentNode.attr('hello', text); @@ -126,7 +126,7 @@ describe('compiler', function(){ this.directives(true); return noop; }; - textMarkup.push(function(text, textNode, parent){ + markup.push(function(text, textNode, parent){ if (text == '{{1+2}}') parent.text('3'); }); -- cgit v1.2.3 From 89245f3a527415a80d46b37054b558454c314532 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Tue, 3 Aug 2010 16:53:27 -0700 Subject: added RequestHeaders to XHR --- example/temp.html | 92 +++++++++++++------------------------------------------ src/Browser.js | 3 ++ 2 files changed, 25 insertions(+), 70 deletions(-) diff --git a/example/temp.html b/example/temp.html index b6752d57..8a1246ed 100644 --- a/example/temp.html +++ b/example/temp.html @@ -7,78 +7,30 @@ -

Tic-Tac-Toe

-Next Player: {{nextMove}} -
Player {{winner}} has won!
- - - - -
{{cell}}
- +
+ +
\ No newline at end of file diff --git a/src/Browser.js b/src/Browser.js index 3287cf0e..b4314e2c 100644 --- a/src/Browser.js +++ b/src/Browser.js @@ -74,6 +74,9 @@ Browser.prototype = { var xhr = new this.XHR(), self = this; xhr.open(method, url, true); + xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + xhr.setRequestHeader("Accept", "application/json, text/plain, */*"); + xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); this.outstandingRequests.count ++; xhr.onreadystatechange = function() { if (xhr.readyState == 4) { -- cgit v1.2.3