Chromium Code Reviews| Index: ui/webui/resources/js/cr/ui/array_data_model.js |
| diff --git a/ui/webui/resources/js/cr/ui/array_data_model.js b/ui/webui/resources/js/cr/ui/array_data_model.js |
| index 969f9484ff8a295571d2c87f12929e24b71bfde3..552e7cb0d1c788627b4b7a5b167c44ca8e5ddad3 100644 |
| --- a/ui/webui/resources/js/cr/ui/array_data_model.js |
| +++ b/ui/webui/resources/js/cr/ui/array_data_model.js |
| @@ -222,6 +222,18 @@ cr.define('cr.ui', function() { |
| }, |
| /** |
| + * Removes and returns the last item of the model. |
| + * |
| + * This dispatches a splice event. |
| + * |
| + * @return {*} The last item, or undefined if model has no more items. |
|
Dan Beam
2016/04/27 21:47:27
we should @template-ize this class some day
huangs
2016/04/27 21:53:13
Don't understand what you mean?
|
| + */ |
| + pop: function() { |
| + var deletedItems = this.splice(this.array_.length - 1, 1); |
| + return deletedItems.length > 0 ? deletedItems[0] : undefined; |
|
Dan Beam
2016/04/27 21:47:27
return this.splice(this.array_.length - 1, 1)[0];
huangs
2016/04/27 21:53:13
Done.
|
| + }, |
| + |
| + /** |
| * Updates the existing item with the new item. |
| * |
| * The existing item and the new item are regarded as the same item and the |