From 86d32e4180f12885ab60df0d36fff227e8597c6a Mon Sep 17 00:00:00 2001 From: Michael Prentice Date: Tue, 11 Sep 2018 17:37:03 -0400 Subject: [PATCH] docs(changelog): add breaking change to md-selected-text for 1.1.2 Fixes #10912. --- CHANGELOG.md | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2727450665d..3a7b0386f92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -442,8 +442,54 @@ MyController.prototype.$onInit = function() { ### BREAKING CHANGES -* autocomplete: The autocomplete validator `md-require-match` no longer matches if the search text is empty +* **autocomplete:** The autocomplete validator `md-require-match` no longer matches if the search text is empty. +* **select:** `md-selected-text` now only accepts text. It used to accept and render html but this was an XSS vulnerability. + It was fixed in: block xss on md-select-label ([#10023](https://github.com/angular/material/issues/10023)) ([f7ecb4f](https://github.com/angular/material/commit/f7ecb4f)). +We have added a new `md-selected-html` API for `md-select`. It accepts an expression to be evaluated +that will return a string to be displayed as a placeholder in the select input box when it is +closed. The value will be treated as html. The value **must** either be explicitly marked as +**trustedHtml** or the **ngSanitize** module must be loaded. + +Given the following code: +```html + +``` +```js +angular + .module('selectDemoSelectedText', ['ngMaterial']) + .controller('SelectedTextController', function($scope) { + $scope.items = [1, 2, 3, 4, 5, 6, 7]; + $scope.selectedItem = undefined; + $scope.getSelectedText = function() { + if ($scope.selectedItem !== undefined) { + return "You have selected: Item " + $scope.selectedItem + ""; + } else { + return "Please select an item"; + } + }; + }); +``` + +Change it to this: +```html + +``` +```js +angular + .module('selectDemoSelectedText', ['ngMaterial', 'ngSanitize']) + .controller('SelectedTextController', function($scope) { + $scope.items = [1, 2, 3, 4, 5, 6, 7]; + $scope.selectedItem = undefined; + $scope.getSelectedText = function() { + if ($scope.selectedItem !== undefined) { + return "You have selected: Item " + $scope.selectedItem + ""; + } else { + return "Please select an item"; + } + }; + }); +``` ## [Angular Material 1.1.1](https://github.com/angular/material/compare/v1.1.0...v1.1.1) (2016-09-01)