mirror of
https://github.com/jlengrand/webcomponentsjs.git
synced 2026-03-10 15:53:12 +00:00
Make HTMLElement.prototype.constructor configurable and writable
This commit is contained in:
@@ -639,8 +639,9 @@ var Deferred;
|
||||
throw new Error('Unknown constructor. Did you call customElements.define()?');
|
||||
}
|
||||
win.HTMLElement = newHTMLElement;
|
||||
win.HTMLElement.prototype = Object.create(origHTMLElement.prototype);
|
||||
Object.defineProperty(win.HTMLElement.prototype, 'constructor', {value: win.HTMLElement});
|
||||
win.HTMLElement.prototype = Object.create(origHTMLElement.prototype, {
|
||||
constructor: {value: win.HTMLElement, configurable: true, writable: true},
|
||||
});
|
||||
|
||||
// patch all built-in subclasses of HTMLElement to inherit from the new HTMLElement
|
||||
// See https://html.spec.whatwg.org/multipage/indices.html#element-interfaces
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
'js/closure.js',
|
||||
'js/upgrade.js',
|
||||
'js/shadow-dom.js',
|
||||
'js/patching.js',
|
||||
'html/imports.html',
|
||||
]);
|
||||
</script>
|
||||
|
||||
23
tests/CustomElements/v1/js/patching.js
Normal file
23
tests/CustomElements/v1/js/patching.js
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
|
||||
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
* Code distributed by Google as part of the polymer project is also
|
||||
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
*/
|
||||
|
||||
suite('patching', function() {
|
||||
|
||||
suite('HTMLElement', function () {
|
||||
|
||||
test('constructor is configurable and writable', function() {
|
||||
var descriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'constructor');
|
||||
assert.isTrue(descriptor.configurable);
|
||||
assert.isTrue(descriptor.writable);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user