(obj, prototype)
| 847 | * @visibleForTesting |
| 848 | */ |
| 849 | export function copyProperties(obj, prototype) { |
| 850 | let current = prototype; |
| 851 | while (current !== null) { |
| 852 | if (Object.isPrototypeOf.call(current, obj)) { |
| 853 | break; |
| 854 | } |
| 855 | |
| 856 | for (const prop of Object.getOwnPropertyNames(current)) { |
| 857 | if (Object.hasOwnProperty.call(obj, prop)) { |
| 858 | continue; |
| 859 | } |
| 860 | |
| 861 | const desc = /** @type {!ObjectPropertyDescriptor<Object>} */ ( |
| 862 | Object.getOwnPropertyDescriptor(current, prop) |
| 863 | ); |
| 864 | Object.defineProperty(obj, prop, desc); |
| 865 | } |
| 866 | |
| 867 | current = Object.getPrototypeOf(current); |
| 868 | } |
| 869 | } |
| 870 | |
| 871 | /** |
| 872 | * Polyfills Custom Elements v1 API. This has 5 modes: |
no outgoing calls
no test coverage detected