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

Commit 1eeafee

Browse files
committed
fix(toast): switch content to textContent to unify w/ dialog. Deprecate content
1 parent b9dae8d commit 1eeafee

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/components/toast/demoBasicUsage/script.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ angular.module('toastDemo1', ['ngMaterial'])
4343
$scope.showSimpleToast = function() {
4444
$mdToast.show(
4545
$mdToast.simple()
46-
.content('Simple Toast!')
46+
.textContent('Simple Toast!')
4747
.position($scope.getToastPosition())
4848
.hideDelay(3000)
4949
);
5050
};
5151

5252
$scope.showActionToast = function() {
5353
var toast = $mdToast.simple()
54-
.content('Action Toast!')
54+
.textContent('Action Toast!')
5555
.action('OK')
5656
.highlightAction(false)
5757
.position($scope.getToastPosition());

src/components/toast/toast.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function MdToastDirective($mdToast) {
5353
* var app = angular.module('app', ['ngMaterial']);
5454
* app.controller('MyController', function($scope, $mdToast) {
5555
* $scope.openToast = function($event) {
56-
* $mdToast.show($mdToast.simple().content('Hello!'));
56+
* $mdToast.show($mdToast.simple().textContent('Hello!'));
5757
* // Could also do $mdToast.showSimple('Hello');
5858
* };
5959
* });
@@ -84,7 +84,7 @@ function MdToastDirective($mdToast) {
8484
* _**Note:** These configuration methods are provided in addition to the methods provided by
8585
* the `build()` and `show()` methods below._
8686
*
87-
* - `.content(string)` - Sets the toast content to the specified string.
87+
* - `.textContent(string)` - Sets the toast content to the specified string.
8888
*
8989
* - `.action(string)` - Adds an action button. If clicked, the promise (returned from `show()`)
9090
* will resolve with the value `'ok'`; otherwise, it is resolved with `true` after a `hideDelay`
@@ -102,7 +102,7 @@ function MdToastDirective($mdToast) {
102102

103103
/**
104104
* @ngdoc method
105-
* @name $mdToast#updateContent
105+
* @name $mdToast#updateTextContent
106106
*
107107
* @description
108108
* Updates the content of an existing toast. Useful for updating things like counts, etc.
@@ -206,8 +206,8 @@ function MdToastProvider($$interimElementProvider) {
206206
options: toastDefaultOptions
207207
})
208208
.addPreset('simple', {
209-
argOption: 'content',
210-
methods: ['content', 'action', 'highlightAction', 'theme', 'parent'],
209+
argOption: 'textContent',
210+
methods: ['textContent', 'content', 'action', 'highlightAction', 'theme', 'parent'],
211211
options: /* @ngInject */ function($mdToast, $mdTheming) {
212212
var opts = {
213213
template: [
@@ -234,9 +234,12 @@ function MdToastProvider($$interimElementProvider) {
234234
return opts;
235235
}
236236
})
237-
.addMethod('updateContent', function(newContent) {
237+
.addMethod('updateTextContent', updateTextContent)
238+
.addMethod('updateContent', updateTextContent);
239+
240+
function updateTextContent(newContent) {
238241
activeToastContent = newContent;
239-
});
242+
}
240243

241244
return $mdToast;
242245

@@ -252,7 +255,7 @@ function MdToastProvider($$interimElementProvider) {
252255
};
253256

254257
function onShow(scope, element, options) {
255-
activeToastContent = options.content;
258+
activeToastContent = options.textContent || options.content; // support deprecated #content method
256259

257260
element = $mdUtil.extractElementByName(element, 'md-toast', true);
258261
options.onSwipe = function(ev, gesture) {

0 commit comments

Comments
 (0)