* Serializes the state into the url hash.
()
| 242 | * Serializes the state into the url hash. |
| 243 | */ |
| 244 | serialize() { |
| 245 | // Serialize regular properties. |
| 246 | let props: string[] = []; |
| 247 | State.PROPS.forEach(({name, type, keyMap}) => { |
| 248 | let value = this[name]; |
| 249 | // Don't serialize missing values. |
| 250 | if (value == null) { |
| 251 | return; |
| 252 | } |
| 253 | if (type === Type.OBJECT) { |
| 254 | value = getKeyFromValue(keyMap, value); |
| 255 | } else if (type === Type.ARRAY_NUMBER || |
| 256 | type === Type.ARRAY_STRING) { |
| 257 | value = value.join(","); |
| 258 | } |
| 259 | props.push(`${name}=${value}`); |
| 260 | }); |
| 261 | // Serialize properties that correspond to hiding UI controls. |
| 262 | getHideProps(this).forEach(prop => { |
| 263 | props.push(`${prop}=${this[prop]}`); |
| 264 | }); |
| 265 | window.location.hash = props.join("&"); |
| 266 | } |
| 267 | |
| 268 | /** Returns all the hidden properties. */ |
| 269 | getHiddenProps(): string[] { |
no test coverage detected