Compare commits

...

5 Commits

Author SHA1 Message Date
Georgios Kalpakas 70724e3918 test($log): fix up to work with IE8 2016-12-07 15:18:07 +02:00
Peter Bacon Darwin 9a0156d258 test($log): fix up to work with Safari 9
On Safari 9.0.2, you are not allowed to write to `sourceUrl` or `line`
on a native Error object.

This commit uses a custom error instead.
2016-12-07 14:39:42 +02:00
Peter Bacon Darwin 5730c665e8 docs(CHANGELOG): add 1.2.32 release notes 2016-10-11 22:49:02 +01:00
Peter Bacon Darwin b8a0ecdd61 fix($compile): ensure that hidden input values are correct after history.back
Due to the nature of some browser's PageCache/BFCache, returning to an Angular
app sometimes causes `input[hidden]` elements to retain the last value
that was stored before the page was navigated away from previously.

This is particularly problematic if the input has an interpolated value.
E.g. `<input type="hidden" value="{{ 1 + 2 }}">` since when the browser
returns, instead of the original interpolation template, the HTML contains
the previous value `<input type="hidden" value="3">`.

This commit instructs the browser not to attempt to reinstate the previous
value when navigating back in history by setting `autocomplete="off"` on
the hidden input element element.
2016-10-11 13:48:38 +01:00
Peter Bacon Darwin ed44dd0659 revert:fix(input): ensure that hidden input values are correct after history.back
This reverts commit 7ec663fc70.
There was a regression against angular-material that relied upon the input directive.
2016-10-11 13:39:13 +01:00
4 changed files with 54 additions and 21 deletions
+16 -1
View File
@@ -1,9 +1,24 @@
<a name="1.2.32"></a>
# 1.2.32 alternation-intention (2016-10-10)
This release reverts the fix in 1.2.31 and provides an alternative fix that doesn't break Angular Material.
## Reverts
- **input:** ensure that hidden input values are correct after history back
([ed44dd065](https://github.com/angular/angular.js/commit/ed44dd0659f346ced78a112e4a2b30d3af4fd572))
## Bug Fixes
- **$compile:** ensure that hidden input values are correct after history back
([b8a0ecdd6](https://github.com/angular/angular.js/commit/b8a0ecdd6189fb111734eb5b6d4d473d0dcf4c36))
<a name="1.2.31"></a>
# 1.2.31 barking-moustache (2016-10-10)
## Bug Fixes
- **input:** ensure that hidden input values are correct after history back
([7ec663fc](https://github.com/angular/angular.js/commit/7ec663fc708aa7a9a9ce62d2306f24d7a733a86d)
([7ec663fc](https://github.com/angular/angular.js/commit/7ec663fc708aa7a9a9ce62d2306f24d7a733a86d))
<a name="1.2.30"></a>
+11 -1
View File
@@ -1030,13 +1030,17 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
var nodeType = node.nodeType,
attrsMap = attrs.$attr,
match,
nodeName,
className;
switch(nodeType) {
case 1: /* Element */
nodeName = nodeName_(node).toLowerCase();
// use the node name: <directive>
addDirective(directives,
directiveNormalize(nodeName_(node).toLowerCase()), 'E', maxPriority, ignoreDirective);
directiveNormalize(nodeName), 'E', maxPriority, ignoreDirective);
// iterate over the attributes
for (var attr, name, nName, ngAttrName, value, isNgAttr, nAttrs = node.attributes,
@@ -1076,6 +1080,12 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
}
}
if (nodeName === 'input' && node.getAttribute('type') === 'hidden') {
// Hidden input elements can have strange behaviour when navigating back to the page
// This tells the browser not to try to cache and reinstate previous values
node.setAttribute('autocomplete', 'off');
}
// use class as directive
className = node.className;
if (isString(className) && className !== '') {
+5 -10
View File
@@ -899,16 +899,11 @@ var inputDirective = ['$browser', '$sniffer', function($browser, $sniffer) {
return {
restrict: 'E',
require: '?ngModel',
compile: function(tElement, tAttr) {
if (lowercase(tAttr.type) === 'hidden') tAttr.$set('autocomplete', 'off');
return {
pre: function(scope, element, attr, ctrl) {
if (ctrl) {
(inputType[lowercase(attr.type)] || inputType.text)(scope, element, attr, ctrl, $sniffer,
$browser);
}
}
};
link: function(scope, element, attr, ctrl) {
if (ctrl) {
(inputType[lowercase(attr.type)] || inputType.text)(scope, element, attr, ctrl, $sniffer,
$browser);
}
}
};
}];
+22 -9
View File
@@ -144,16 +144,29 @@ describe('$log', function() {
describe('$log.error', function() {
var e, $log, errorArgs;
beforeEach(function() {
e = new Error('');
e.message = undefined;
e.sourceURL = undefined;
e.line = undefined;
e.stack = undefined;
function TestErrorPrototype() {}
TestErrorPrototype.prototype = Error.prototype;
$log = new $LogProvider().$get[1]({console:{error:function() {
errorArgs = [].slice.call(arguments, 0);
}}});
function TestError() {
Error.prototype.constructor.apply(this, arguments);
this.message = undefined;
this.sourceURL = undefined;
this.line = undefined;
this.stack = undefined;
}
TestError.prototype = new TestErrorPrototype();
TestError.prototype.constructor = TestError;
beforeEach(function() {
e = new TestError('');
var mockWindow = {
console: {
error: function() {
errorArgs = [].slice.call(arguments, 0);
}
}
};
$log = new $LogProvider().$get[1](mockWindow);
});