Skip to content

Commit 167fdf7

Browse files
andrewseguinmhevery
authored andcommitted
feat(elements): rename API to createCustomElement (#22413)
PR Close #22413
1 parent 39a12d2 commit 167fdf7

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

aio/src/app/custom-elements/elements-loader.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { ELEMENT_MODULE_PATHS_TOKEN } from './element-registry';
88
import { of } from 'rxjs/observable/of';
99
import { Observable } from 'rxjs/Observable';
1010
import { fromPromise } from 'rxjs/observable/fromPromise';
11-
import { createNgElementConstructor } from '@angular/elements';
11+
import { createCustomElement } from '@angular/elements';
1212

1313
@Injectable()
1414
export class ElementsLoader {
@@ -44,10 +44,10 @@ export class ElementsLoader {
4444

4545
const elementModuleRef = elementModuleFactory.create(this.moduleRef.injector);
4646
const CustomElementComponent = elementModuleRef.instance.customElementComponent;
47-
const NgElement =
48-
createNgElementConstructor(CustomElementComponent, {injector: elementModuleRef.injector});
47+
const CustomElement =
48+
createCustomElement(CustomElementComponent, {injector: elementModuleRef.injector});
4949

50-
customElements!.define(selector, NgElement);
50+
customElements!.define(selector, CustomElement);
5151
this.elementsToLoad.delete(selector);
5252

5353
return customElements.whenDefined(selector);

packages/elements/public_api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Entry point for all public APIs of the `elements` package.
1313
*/
1414
export {NgElementStrategy, NgElementStrategyEvent, NgElementStrategyFactory} from './src/element-strategy';
15-
export {NgElement, NgElementConfig, NgElementConstructor, WithProperties, createNgElementConstructor} from './src/ng-element-constructor';
15+
export {NgElement, NgElementConfig, NgElementConstructor, WithProperties, createCustomElement} from './src/create-custom-element';
1616
export {VERSION} from './src/version';
1717

1818
// This file only reexports content of the `src` folder. Keep it that way.

packages/elements/src/ng-element-constructor.ts renamed to packages/elements/src/create-custom-element.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ export interface NgElementConfig {
7171
* @description Builds a class that encapsulates the functionality of the provided component and
7272
* uses the config's information to provide more context to the class. Takes the component factory's
7373
* inputs and outputs to convert them to the proper custom element API and add hooks to input
74-
* changes. Passes the config's injector to each created instance (may be overriden with the
74+
* changes. Passes the config's injector to each created instance (may be overridden with the
7575
* static property to affect all newly created instances, or as a constructor argument for
7676
* one-off creations).
7777
*
7878
* @experimental
7979
*/
80-
export function createNgElementConstructor<P>(
80+
export function createCustomElement<P>(
8181
component: Type<any>, config: NgElementConfig): NgElementConstructor<P> {
8282
const inputs = getComponentInputs(component, config.injector);
8383

packages/elements/test/ng-element-constructor_spec.ts renamed to packages/elements/test/create-custom-element_spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
1212
import {Subject} from 'rxjs/Subject';
1313

1414
import {NgElementStrategy, NgElementStrategyEvent, NgElementStrategyFactory} from '../src/element-strategy';
15-
import {NgElementConstructor, createNgElementConstructor} from '../src/ng-element-constructor';
15+
import {NgElementConstructor, createCustomElement} from '../src/create-custom-element';
1616

1717
type WithFooBar = {
1818
fooFoo: string,
1919
barBar: string
2020
};
2121

2222
if (typeof customElements !== 'undefined') {
23-
describe('createNgElementConstructor', () => {
23+
describe('createCustomElement', () => {
2424
let NgElementCtor: NgElementConstructor<WithFooBar>;
2525
let strategy: TestStrategy;
2626
let strategyFactory: TestStrategyFactory;
@@ -35,7 +35,7 @@ if (typeof customElements !== 'undefined') {
3535
strategyFactory = new TestStrategyFactory();
3636
strategy = strategyFactory.testStrategy;
3737

38-
NgElementCtor = createNgElementConstructor(TestComponent, {injector, strategyFactory});
38+
NgElementCtor = createCustomElement(TestComponent, {injector, strategyFactory});
3939

4040
// The `@webcomponents/custom-elements/src/native-shim.js` polyfill allows us to create
4141
// new instances of the NgElement which extends HTMLElement, as long as we define it.
@@ -101,7 +101,7 @@ if (typeof customElements !== 'undefined') {
101101
beforeAll(() => {
102102
strategyFactory = new TestStrategyFactory();
103103
strategy = strategyFactory.testStrategy;
104-
NgElementCtorWithChangedAttr = createNgElementConstructor(TestComponent, {
104+
NgElementCtorWithChangedAttr = createCustomElement(TestComponent, {
105105
injector,
106106
strategyFactory,
107107
attributeToPropertyInputs: {'attr-1': 'fooFoo', 'attr-2': 'barbar'}

tools/public_api_guard/elements/elements.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** @experimental */
2-
export declare function createNgElementConstructor<P>(component: Type<any>, config: NgElementConfig): NgElementConstructor<P>;
2+
export declare function createCustomElement<P>(component: Type<any>, config: NgElementConfig): NgElementConstructor<P>;
33

44
/** @experimental */
55
export declare abstract class NgElement extends HTMLElement {

0 commit comments

Comments
 (0)