| OLD | NEW |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 1 | 4 |
| 2 class StorageJS implements Storage native "*Storage" { | 5 class StorageJs extends DOMTypeJs implements Storage native "*Storage" { |
| 3 | 6 |
| 4 int get length() native "return this.length;"; | 7 int get length() native "return this.length;"; |
| 5 | 8 |
| 6 void clear() native; | 9 void clear() native; |
| 7 | 10 |
| 8 String getItem(String key) native; | 11 String getItem(String key) native; |
| 9 | 12 |
| 10 String key(int index) native; | 13 String key(int index) native; |
| 11 | 14 |
| 12 void removeItem(String key) native; | 15 void removeItem(String key) native; |
| 13 | 16 |
| 14 void setItem(String key, String data) native; | 17 void setItem(String key, String data) native; |
| 15 | 18 |
| 19 |
| 20 // Storage needs a special implementation of dartObjectLocalStorage since it |
| 21 // captures what would normally be an expando and places property in the |
| 22 // storage, stringifying the assigned value. |
| 23 |
| 16 var get dartObjectLocalStorage() native """ | 24 var get dartObjectLocalStorage() native """ |
| 17 | |
| 18 if (this === window.localStorage) | 25 if (this === window.localStorage) |
| 19 return window._dartLocalStorageLocalStorage; | 26 return window._dartLocalStorageLocalStorage; |
| 20 else if (this === window.sessionStorage) | 27 else if (this === window.sessionStorage) |
| 21 return window._dartSessionStorageLocalStorage; | 28 return window._dartSessionStorageLocalStorage; |
| 22 else | 29 else |
| 23 throw new UnsupportedOperationException('Cannot dartObjectLocalStorage for
unknown Storage object.'); | 30 throw new UnsupportedOperationException('Cannot dartObjectLocalStorage for
unknown Storage object.'); |
| 24 | 31 """ { throw new UnsupportedOperationException(''); } |
| 25 """ { | |
| 26 throw new UnsupportedOperationException(''); | |
| 27 } | |
| 28 | 32 |
| 29 void set dartObjectLocalStorage(var value) native """ | 33 void set dartObjectLocalStorage(var value) native """ |
| 30 | |
| 31 if (this === window.localStorage) | 34 if (this === window.localStorage) |
| 32 window._dartLocalStorageLocalStorage = value; | 35 window._dartLocalStorageLocalStorage = value; |
| 33 else if (this === window.sessionStorage) | 36 else if (this === window.sessionStorage) |
| 34 window._dartSessionStorageLocalStorage = value; | 37 window._dartSessionStorageLocalStorage = value; |
| 35 else | 38 else |
| 36 throw new UnsupportedOperationException('Cannot dartObjectLocalStorage for
unknown Storage object.'); | 39 throw new UnsupportedOperationException('Cannot dartObjectLocalStorage for
unknown Storage object.'); |
| 37 | 40 """ { throw new UnsupportedOperationException(''); } |
| 38 """ { | |
| 39 throw new UnsupportedOperationException(''); | |
| 40 } | |
| 41 | |
| 42 String get typeName() native; | |
| 43 } | 41 } |
| OLD | NEW |