Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.

Commit e14a329

Browse files
committed
support document.registerElement
1 parent 9e99fcf commit e14a329

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/CustomElements.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ if (!scope) {
2323
}
2424
var flags = scope.flags;
2525

26-
// native document.register?
26+
// native document.registerElement?
2727

28-
var hasNative = Boolean(document.register);
28+
var hasNative = Boolean(document.registerElement);
2929
var useNative = !flags.register && hasNative;
3030

3131
if (useNative) {
@@ -73,7 +73,7 @@ if (useNative) {
7373
* element.
7474
*
7575
* @example
76-
* FancyButton = document.register("fancy-button", {
76+
* FancyButton = document.registerElement("fancy-button", {
7777
* extends: 'button',
7878
* prototype: Object.create(HTMLButtonElement.prototype, {
7979
* readyCallback: {
@@ -86,19 +86,19 @@ if (useNative) {
8686
* @return {Function} Constructor for the newly registered type.
8787
*/
8888
function register(name, options) {
89-
//console.warn('document.register("' + name + '", ', options, ')');
89+
//console.warn('document.registerElement("' + name + '", ', options, ')');
9090
// construct a defintion out of options
9191
// TODO(sjmiles): probably should clone options instead of mutating it
9292
var definition = options || {};
9393
if (!name) {
9494
// TODO(sjmiles): replace with more appropriate error (EricB can probably
9595
// offer guidance)
96-
throw new Error('document.register: first argument `name` must not be empty');
96+
throw new Error('document.registerElement: first argument `name` must not be empty');
9797
}
9898
if (name.indexOf('-') < 0) {
9999
// TODO(sjmiles): replace with more appropriate error (EricB can probably
100100
// offer guidance)
101-
throw new Error('document.register: first argument (\'name\') must contain a dash (\'-\'). Argument provided was \'' + String(name) + '\'.');
101+
throw new Error('document.registerElement: first argument (\'name\') must contain a dash (\'-\'). Argument provided was \'' + String(name) + '\'.');
102102
}
103103
// elements may only be registered once
104104
if (getRegisteredDefinition(name)) {
@@ -359,7 +359,7 @@ if (useNative) {
359359

360360
// exports
361361

362-
document.register = register;
362+
document.registerElement = register;
363363
document.createElement = createElement; // override
364364
Node.prototype.cloneNode = cloneNode; // override
365365

@@ -379,6 +379,9 @@ if (useNative) {
379379
scope.upgrade = upgradeElement;
380380
}
381381

382+
// bc
383+
document.register = document.registerElement;
384+
382385
scope.hasNative = hasNative;
383386
scope.useNative = useNative;
384387

src/boot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function bootstrap() {
1616
Platform.endOfMicrotask :
1717
setTimeout;
1818
async(function() {
19-
// set internal 'ready' flag, now document.register will trigger
19+
// set internal 'ready' flag, now document.registerElement will trigger
2020
// synchronous upgrades
2121
CustomElements.ready = true;
2222
// capture blunt profiling data

0 commit comments

Comments
 (0)