Copy CustomElement's polyfill of CustomEvent to HTMLImports

This still unnecessarily polyfills the `CustomEvent` constructor on Safari (since `typeof CustomEvent === 'object'` on Safari), but now it creates a `CustomEvent` (with a proper `event.detail` property) and not a generic `Event` with no `event.detail`.