diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b7c33003e5f..937bccdb98e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,16 @@ # 0.9.13 curdling-stare (in-progress) # +### Bug Fixes +- Fixed cookies which contained unescaped '=' would not show up in cookie service. +- Consider all 2xx responses as OK, not just 200 +- Remove the script tag after successful JSONP request - - +### Breaking changes +- Changed the $browser.xhr parameter post from optional to required. Since everyone should be + using the $xhr instead of $browser.xhr, this should not break anyone. If you do use $browser.xhr + then just add null for the post value argument. +- Added XSRF prevention logic to $xhr service diff --git a/docs/spec/ngdocSpec.js b/docs/spec/ngdocSpec.js index 9c1a49ac3a53..46b05aef8442 100644 --- a/docs/spec/ngdocSpec.js +++ b/docs/spec/ngdocSpec.js @@ -229,9 +229,16 @@ describe('ngdoc', function(){ describe('@requires', function() { it('should parse more @requires tag into array', function() { - var doc = new Doc('@requires $service\n@requires $another'); + var doc = new Doc('@requires $service for \n`A`\n@requires $another for `B`'); + doc.ngdoc = 'service'; doc.parse(); - expect(doc.requires).toEqual(['$service', '$another']); + expect(doc.requires).toEqual([ + {name:'$service', text:'

for \nA

'}, + {name:'$another', text:'

for B

'}]); + expect(doc.html()).toContain('
$service'); + expect(doc.html()).toContain('$another'); + expect(doc.html()).toContain('

for \nA

'); + expect(doc.html()).toContain('

for B

'); }); }); diff --git a/docs/src/ngdoc.js b/docs/src/ngdoc.js index 2f59f044015d..fcfdc3f1f9e0 100644 --- a/docs/src/ngdoc.js +++ b/docs/src/ngdoc.js @@ -157,7 +157,11 @@ Doc.prototype = { description: self.markdown(text.replace(match[0], match[2])) }; } else if(atName == 'requires') { - self.requires.push(text); + var match = text.match(/^([^\s]*)\s*([\S\s]*)/); + self.requires.push({ + name: match[1], + text: self.markdown(match[2]) + }); } else if(atName == 'property') { var match = text.match(/^{(\S+)}\s+(\S+)(\s+(.*))?/); if (!match) { @@ -185,6 +189,15 @@ Doc.prototype = { 'This page is currently being revised. It might be incomplete or contain inaccuracies.'); notice('deprecated', 'Deprecated API', self.deprecated); + if (self.ngdoc != 'overview') + dom.h('Description', self.description, dom.html); + dom.h('Dependencies', self.requires, function(require){ + dom.tag('code', function(){ + dom.tag('a', {href:"#!angular.service." + require.name}, require.name); + }); + dom.html(require.text); + }); + (self['html_usage_' + self.ngdoc] || function(){ throw new Error("Don't know how to format @ngdoc: " + self.ngdoc); }).call(self, dom); @@ -251,8 +264,6 @@ Doc.prototype = { html_usage_function: function(dom){ var self = this; - dom.h('Description', self.description, dom.html); - dom.h('Dependencies', self.requires); dom.h('Usage', function(){ dom.code(function(){ dom.text(self.name); @@ -269,8 +280,6 @@ Doc.prototype = { html_usage_directive: function(dom){ var self = this; - dom.h('Description', self.description, dom.html); - dom.h('Dependencies', self.requires); dom.h('Usage', function(){ dom.tag('pre', {'class':"brush: js; html-script: true;"}, function(){ dom.text('<' + self.element + ' '); @@ -287,8 +296,6 @@ Doc.prototype = { html_usage_filter: function(dom){ var self = this; - dom.h('Description', self.description, dom.html); - dom.h('Dependencies', self.requires); dom.h('Usage', function(){ dom.h('In HTML Template Binding', function(){ dom.tag('code', function(){ @@ -319,8 +326,6 @@ Doc.prototype = { html_usage_formatter: function(dom){ var self = this; - dom.h('Description', self.description, dom.html); - dom.h('Dependencies', self.requires); dom.h('Usage', function(){ dom.h('In HTML Template Binding', function(){ dom.code(function(){ @@ -359,8 +364,6 @@ Doc.prototype = { html_usage_validator: function(dom){ var self = this; - dom.h('Description', self.description, dom.html); - dom.h('Dependencies', self.requires); dom.h('Usage', function(){ dom.h('In HTML Template Binding', function(){ dom.code(function(){ @@ -389,8 +392,6 @@ Doc.prototype = { html_usage_widget: function(dom){ var self = this; - dom.h('Description', self.description, dom.html); - dom.h('Dependencies', self.requires); dom.h('Usage', function(){ dom.h('In HTML Template Binding', function(){ dom.code(function(){ @@ -435,8 +436,6 @@ Doc.prototype = { html_usage_service: function(dom){ var self = this; - dom.h('Description', this.description, dom.html); - dom.h('Dependencies', this.requires); if (this.param.length) { dom.h('Usage', function(){ diff --git a/src/Browser.js b/src/Browser.js index af87c47d03c2..b9eecbb9b464 100644 --- a/src/Browser.js +++ b/src/Browser.js @@ -7,6 +7,11 @@ var XHR = window.XMLHttpRequest || function () { try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e3) {} throw new Error("This browser does not support XMLHttpRequest."); }; +var XHR_HEADERS = { + "Content-Type": "application/x-www-form-urlencoded", + "Accept": "application/json, text/plain, */*", + "X-Requested-With": "XMLHttpRequest" +}; /** * @private @@ -70,35 +75,37 @@ function Browser(window, document, body, XHR, $log) { * * @param {string} method Requested method (get|post|put|delete|head|json) * @param {string} url Requested url - * @param {string=} post Post data to send + * @param {string} post Post data to send (null if nothing to post) * @param {function(number, string)} callback Function that will be called on response + * @param {object=} header additional HTTP headers to send with XHR. + * Standard headers are: + * * * @description * Send ajax request */ - self.xhr = function(method, url, post, callback) { - if (isFunction(post)) { - callback = post; - post = _null; - } + self.xhr = function(method, url, post, callback, headers) { outstandingRequestCount ++; if (lowercase(method) == 'json') { - var callbackId = "angular_" + Math.random() + '_' + (idCounter++); - callbackId = callbackId.replace(/\d\./, ''); - var script = document[0].createElement('script'); - script.type = 'text/javascript'; - script.src = url.replace('JSON_CALLBACK', callbackId); + var callbackId = ("angular_" + Math.random() + '_' + (idCounter++)).replace(/\d\./, ''); + var script = jqLite('