()
| 262 | let attributesSpy, originalAttributesPropDescriptor; |
| 263 | |
| 264 | export function spyOnElementAttributes() { |
| 265 | const test = Object.getOwnPropertyDescriptor(Element.prototype, 'attributes'); |
| 266 | |
| 267 | // IE11 doesn't correctly restore the prototype methods so we have to check |
| 268 | // whether this prototype method is already a sinon spy. |
| 269 | if (!attributesSpy && !(test && test.get && test.get.isSinonProxy)) { |
| 270 | if (!originalAttributesPropDescriptor) { |
| 271 | originalAttributesPropDescriptor = Object.getOwnPropertyDescriptor( |
| 272 | Element.prototype, |
| 273 | 'attributes' |
| 274 | ); |
| 275 | } |
| 276 | |
| 277 | attributesSpy = sinon.spy(Element.prototype, 'attributes', ['get']); |
| 278 | } else if (test && test.get && test.get.isSinonProxy) { |
| 279 | // Due to IE11 not resetting we will do this manually when it is a proxy. |
| 280 | test.get.resetHistory(); |
| 281 | } |
| 282 | |
| 283 | return attributesSpy || test; |
| 284 | } |
| 285 | |
| 286 | function restoreElementAttributes() { |
| 287 | if (originalAttributesPropDescriptor) { |
no outgoing calls
no test coverage detected
searching dependent graphs…