Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 1294a26

Browse files
Splaktarmmalerba
authored andcommitted
docs(changelog): add breaking change to md-selected-text for 1.1.2 (#11442)
<!-- Filling out this template is required! Do not delete it when submitting a Pull Request! Without this information, your Pull Request may be auto-closed. --> ## PR Checklist Please check that your PR fulfills the following requirements: - [x] The commit message follows [our guidelines](https://github.com/angular/material/blob/master/.github/CONTRIBUTING.md#-commit-message-format) - [x] Tests for the changes have been added or this is not a bug fix / enhancement - [x] Docs have been added, updated, or were not required ## PR Type What kind of change does this PR introduce? <!-- Please check the one that applies to this PR using "x". --> ``` [ ] Bugfix [ ] Enhancement [x] Documentation content changes [ ] Code style update (formatting, local variables) [ ] Refactoring (no functional changes, no api changes) [ ] Build related changes [ ] CI related changes [ ] Infrastructure changes [ ] Other... Please describe: ``` ## What is the current behavior? #10912 (comment) <!-- Please describe the current behavior that you are modifying and link to one or more relevant issues. --> Issue Number: Fixes #10912. ## What is the new behavior? We document this API change as a breaking change in 1.1.2 and provide guidance on code migration. ## Does this PR introduce a breaking change? ``` [ ] Yes [x] No ``` <!-- If this PR contains a breaking change, please describe the impact and migration path for existing applications below. --> <!-- Note that breaking changes are highly unlikely to get merged to master unless the validation is clear and the use case is critical. --> ## Other information
1 parent fedb9a3 commit 1294a26

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

CHANGELOG.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,54 @@ MyController.prototype.$onInit = function() {
442442

443443
### BREAKING CHANGES
444444

445-
* autocomplete: The autocomplete validator `md-require-match` no longer matches if the search text is empty
445+
* **autocomplete:** The autocomplete validator `md-require-match` no longer matches if the search text is empty.
446+
* **select:** `md-selected-text` now only accepts text. It used to accept and render html but this was an XSS vulnerability.
447+
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)).
446448

449+
We have added a new `md-selected-html` API for `md-select`. It accepts an expression to be evaluated
450+
that will return a string to be displayed as a placeholder in the select input box when it is
451+
closed. The value will be treated as html. The value **must** either be explicitly marked as
452+
**trustedHtml** or the **ngSanitize** module must be loaded.
453+
454+
Given the following code:
455+
```html
456+
<md-select ng-model="selectedItem" md-selected-text="getSelectedText()">
457+
```
458+
```js
459+
angular
460+
.module('selectDemoSelectedText', ['ngMaterial'])
461+
.controller('SelectedTextController', function($scope) {
462+
$scope.items = [1, 2, 3, 4, 5, 6, 7];
463+
$scope.selectedItem = undefined;
464+
$scope.getSelectedText = function() {
465+
if ($scope.selectedItem !== undefined) {
466+
return "You have selected: Item <strong>" + $scope.selectedItem + "</strong>";
467+
} else {
468+
return "Please select an item";
469+
}
470+
};
471+
});
472+
```
473+
474+
Change it to this:
475+
```html
476+
<md-select ng-model="selectedItem" md-selected-html="getSelectedText()">
477+
```
478+
```js
479+
angular
480+
.module('selectDemoSelectedText', ['ngMaterial', 'ngSanitize'])
481+
.controller('SelectedTextController', function($scope) {
482+
$scope.items = [1, 2, 3, 4, 5, 6, 7];
483+
$scope.selectedItem = undefined;
484+
$scope.getSelectedText = function() {
485+
if ($scope.selectedItem !== undefined) {
486+
return "You have selected: Item <strong>" + $scope.selectedItem + "</strong>";
487+
} else {
488+
return "Please select an item";
489+
}
490+
};
491+
});
492+
```
447493

448494
<a name="1.1.1"></a>
449495
## [Angular Material 1.1.1](https://github.com/angular/material/compare/v1.1.0...v1.1.1) (2016-09-01)

0 commit comments

Comments
 (0)