| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 class _StorageJs extends _DOMTypeJs implements Storage native "*Storage" { | 5 class _StorageJs extends _DOMTypeJs implements Storage native "*Storage" { |
| 6 | 6 |
| 7 final int length; | 7 final int length; |
| 8 | 8 |
| 9 void clear() native; | 9 void clear() native; |
| 10 | 10 |
| 11 String getItem(String key) native; | 11 String getItem(String key) native; |
| 12 | 12 |
| 13 String key(int index) native; | 13 String key(int index) native; |
| 14 | 14 |
| 15 void removeItem(String key) native; | 15 void removeItem(String key) native; |
| 16 | 16 |
| 17 void setItem(String key, String data) native; | 17 void setItem(String key, String data) native; |
| 18 | 18 |
| 19 | 19 |
| 20 // Storage needs a special implementation of dartObjectLocalStorage since it | 20 // Storage needs a special implementation of dartObjectLocalStorage since it |
| 21 // captures what would normally be an expando and places property in the | 21 // captures what would normally be an expando and places property in the |
| 22 // storage, stringifying the assigned value. | 22 // storage, stringifying the assigned value. |
| 23 | 23 |
| 24 var get dartObjectLocalStorage() native """ | 24 get dartObjectLocalStorage() native """ |
| 25 if (this === window.localStorage) | 25 if (this === window.localStorage) |
| 26 return window._dartLocalStorageLocalStorage; | 26 return window._dartLocalStorageLocalStorage; |
| 27 else if (this === window.sessionStorage) | 27 else if (this === window.sessionStorage) |
| 28 return window._dartSessionStorageLocalStorage; | 28 return window._dartSessionStorageLocalStorage; |
| 29 else | 29 else |
| 30 throw new UnsupportedOperationException('Cannot dartObjectLocalStorage for
unknown Storage object.'); | 30 throw new UnsupportedOperationException('Cannot dartObjectLocalStorage for
unknown Storage object.'); |
| 31 """ { throw new UnsupportedOperationException(''); } | 31 """ { throw new UnsupportedOperationException(''); } |
| 32 | 32 |
| 33 void set dartObjectLocalStorage(var value) native """ | 33 void set dartObjectLocalStorage(var value) native """ |
| 34 if (this === window.localStorage) | 34 if (this === window.localStorage) |
| 35 window._dartLocalStorageLocalStorage = value; | 35 window._dartLocalStorageLocalStorage = value; |
| 36 else if (this === window.sessionStorage) | 36 else if (this === window.sessionStorage) |
| 37 window._dartSessionStorageLocalStorage = value; | 37 window._dartSessionStorageLocalStorage = value; |
| 38 else | 38 else |
| 39 throw new UnsupportedOperationException('Cannot dartObjectLocalStorage for
unknown Storage object.'); | 39 throw new UnsupportedOperationException('Cannot dartObjectLocalStorage for
unknown Storage object.'); |
| 40 """ { throw new UnsupportedOperationException(''); } | 40 """ { throw new UnsupportedOperationException(''); } |
| 41 } | 41 } |
| OLD | NEW |