node_modules/@angular/elements/esm5/src/create-custom-element.js
/**
 *  @description Creates a custom element class based on an Angular component.
 *
 * Builds a class that encapsulates the functionality of the provided component and
 * uses the configuration information to provide more context to the class.
 * Takes the component factory's inputs and outputs to convert them to the proper
 * custom element API and add hooks to input changes.
 *
 * The configuration's injector is the initial injector set on the class,
 * and used by default for each created instance.This behavior can be overridden with the
 * static property to affect all newly created instances, or as a constructor argument for
 * one-off creations.
 *
 * @param component The component to transform.
 * @param config A configuration that provides initialization information to the created class.
 * @returns The custom-element construction class, which can be registered with
 * a browser's `CustomElementRegistry`.
 *
 * @publicApi
 */
@description Creates a custom element class based on an Angular component.
Builds a class that encapsulates the functionality of the provided component and
uses the configuration information to provide more context to the class.
Takes the component factory's inputs and outputs to convert them to the proper
custom element API and add hooks to input changes.

The configuration's injector is the initial injector set on the class,
and used by default for each created instance.This behavior can be overridden with the
static property to affect all newly created instances, or as a constructor argument for
one-off creations.

@param component The component to transform.
@param config A configuration that provides initialization information to the created class.
@returns The custom-element construction class, which can be registered with
a browser's `CustomElementRegistry`.

@publicApi
@description Creates a custom element class based on an Angular component . Builds a class that encapsulates the functionality of the provided component and uses the configuration information to provide more context to the class . Takes the component factory ' s inputs and outputs to convert them to the proper custom element API and add hooks to input changes . The configuration ' s injector is the initial injector set on the class and used by default for each created instance . This behavior can be overridden with the static property to affect all newly created instances or as a constructor argument for one - off creations . @param component The component to transform . @param config A configuration that provides initialization information to the created class . @returns The custom - element construction class which can be registered with a browser ' s ` CustomElementRegistry ` . @publicApi
function createCustomElement(component, config) {
    var inputs = getComponentInputs(component, config.injector);
    var strategyFactory = config.strategyFactory || new ComponentNgElementStrategyFactory(component, config.injector);
    var attributeToPropertyInputs = getDefaultAttributeToPropertyInputs(inputs);
    var NgElementImpl =  (function (_super) {
        __extends(NgElementImpl, _super);
        function NgElementImpl(injector) {
            var _this = _super.call(this) || this;
            _this.injector = injector;
            return _this;
        }
        Object.defineProperty(NgElementImpl.prototype, "ngElementStrategy", {
            get: function () {
                var _this = this;
                 TODO(andrewseguin): Add e2e tests that cover cases where the constructor isn't called. For
                 now this is tested using a Google internal test suite.
                if (!this._ngElementStrategy) {
                    var strategy_1 = this._ngElementStrategy =
                        strategyFactory.create(this.injector || config.injector);
                     Collect pre-existing values on the element to re-apply through the strategy.
                    var preExistingValues = inputs.filter(function (_a) {
                        var propName = _a.propName;
                        return _this.hasOwnProperty(propName);
                    }).map(function (_a) {
                        var propName = _a.propName;
                        return [propName, _this[propName]];
                    });
                     In some browsers (e.g. IE10), `Object.setPrototypeOf()` (which is required by some Custom
                     Elements polyfills) is not defined and is thus polyfilled in a way that does not preserve
                     the prototype chain. In such cases, `this` will not be an instance of `NgElementImpl` and
                     thus not have the component input getters/setters defined on `NgElementImpl.prototype`.
                    if (!(this instanceof NgElementImpl)) {
                         Add getters and setters to the instance itself for each property input.
                        defineInputGettersSetters(inputs, this);
                    }
                    else {
                         Delete the property from the instance, so that it can go through the getters/setters
                         set on `NgElementImpl.prototype`.
                        preExistingValues.forEach(function (_a) {
                            var _b = __read(_a, 1), propName = _b[0];
                            return delete _this[propName];
                        });
                    }
                     Re-apply pre-existing values through the strategy.
                    preExistingValues.forEach(function (_a) {
                        var _b = __read(_a, 2), propName = _b[0], value = _b[1];
                        return strategy_1.setInputValue(propName, value);
                    });
                }
                return this._ngElementStrategy;
            },
            enumerable: true,
            configurable: true
        });
        NgElementImpl.prototype.attributeChangedCallback = function (attrName, oldValue, newValue, namespace) {
            var propName = attributeToPropertyInputs[attrName];
            this.ngElementStrategy.setInputValue(propName, newValue);
        };
        NgElementImpl.prototype.connectedCallback = function () {
            var _this = this;
            this.ngElementStrategy.connect(this);
             Listen for events from the strategy and dispatch them as custom events
            this.ngElementEventsSubscription = this.ngElementStrategy.events.subscribe(function (e) {
                var customEvent = createCustomEvent(_this.ownerDocument, e.name, e.value);
                _this.dispatchEvent(customEvent);
            });
        };
        NgElementImpl.prototype.disconnectedCallback = function () {
             Not using `this.ngElementStrategy` to avoid unnecessarily creating the `NgElementStrategy`.
            if (this._ngElementStrategy) {
                this._ngElementStrategy.disconnect();
            }
            if (this.ngElementEventsSubscription) {
                this.ngElementEventsSubscription.unsubscribe();
                this.ngElementEventsSubscription = null;
            }
        };
         Work around a bug in closure typed optimizations(b/79557487) where it is not honoring static
         field externs. So using quoted access to explicitly prevent renaming.
        NgElementImpl['observedAttributes'] = Object.keys(attributeToPropertyInputs);
        return NgElementImpl;
    }(NgElement));
     Add getters and setters to the prototype for each property input.
    defineInputGettersSetters(inputs, NgElementImpl.prototype);
    return NgElementImpl;
}
function createCustomElement ( component , config ) { var inputs = getComponentInputs ( component , config . injector ) ; var strategyFactory = config . strategyFactory || new ComponentNgElementStrategyFactory ( component , config . injector ) ; var attributeToPropertyInputs = getDefaultAttributeToPropertyInputs ( inputs ) ; var NgElementImpl = ( function ( _super ) { __extends ( NgElementImpl , _super ) ; function NgElementImpl ( injector ) { var _this = _super . call ( this ) || this ; _this . injector = injector ; return _this ; } Object . defineProperty ( NgElementImpl . prototype , "ngElementStrategy" , { get : function ( ) { var _this = this ; if ( ! this . _ngElementStrategy ) { var strategy_1 = this . _ngElementStrategy = strategyFactory . create ( this . injector || config . injector ) ; var preExistingValues = inputs . filter ( function ( _a ) { var propName = _a . propName ; return _this . hasOwnProperty ( propName ) ; } ) . map ( function ( _a ) { var propName = _a . propName ; return [ propName , _this [ propName ] ] ; } ) ; if ( ! ( this instanceof NgElementImpl ) ) { defineInputGettersSetters ( inputs , this ) ; } else { preExistingValues . forEach ( function ( _a ) { var _b = __read ( _a , 1 ) , propName = _b [ 0 ] ; return delete _this [ propName ] ; } ) ; } preExistingValues . forEach ( function ( _a ) { var _b = __read ( _a , 2 ) , propName = _b [ 0 ] , value = _b [ 1 ] ; return strategy_1 . setInputValue ( propName , value ) ; } ) ; } return this . _ngElementStrategy ; } , enumerable : true , configurable : true } ) ; NgElementImpl . prototype . attributeChangedCallback = function ( attrName , oldValue , newValue , namespace ) { var propName = attributeToPropertyInputs [ attrName ] ; this . ngElementStrategy . setInputValue ( propName , newValue ) ; } ; NgElementImpl . prototype . connectedCallback = function ( ) { var _this = this ; this . ngElementStrategy . connect ( this ) ; this . ngElementEventsSubscription = this . ngElementStrategy . events . subscribe ( function ( e ) { var customEvent = createCustomEvent ( _this . ownerDocument , e . name , e . value ) ; _this . dispatchEvent ( customEvent ) ; } ) ; } ; NgElementImpl . prototype . disconnectedCallback = function ( ) { if ( this . _ngElementStrategy ) { this . _ngElementStrategy . disconnect ( ) ; } if ( this . ngElementEventsSubscription ) { this . ngElementEventsSubscription . unsubscribe ( ) ; this . ngElementEventsSubscription = null ; } } ; NgElementImpl [ 'observedAttributes' ] = Object . keys ( attributeToPropertyInputs ) ; return NgElementImpl ; } ( NgElement ) ) ; defineInputGettersSetters ( inputs , NgElementImpl . prototype ) ; return NgElementImpl ; }
@description Creates a custom element class based on an Angular component.
@description Creates a custom element class based on an Angular component .
/** @class */ // NOTE: // Some polyfills (e.g. `document-register-element`) do not call the constructor, therefore // it is not safe to set `ngElementStrategy` in the constructor and assume it will be // available inside the methods. // // TODO(andrewseguin): Add e2e tests that cover cases where the constructor isn't called. For // now this is tested using a Google internal test suite. // Collect pre-existing values on the element to re-apply through the strategy. // In some browsers (e.g. IE10), `Object.setPrototypeOf()` (which is required by some Custom // Elements polyfills) is not defined and is thus polyfilled in a way that does not preserve // the prototype chain. In such cases, `this` will not be an instance of `NgElementImpl` and // thus not have the component input getters/setters defined on `NgElementImpl.prototype`. // Add getters and setters to the instance itself for each property input. // Delete the property from the instance, so that it can go through the getters/setters // set on `NgElementImpl.prototype`. // Re-apply pre-existing values through the strategy. // Listen for events from the strategy and dispatch them as custom events // Not using `this.ngElementStrategy` to avoid unnecessarily creating the `NgElementStrategy`. // Work around a bug in closure typed optimizations(b/79557487) where it is not honoring static // field externs. So using quoted access to explicitly prevent renaming. // Add getters and setters to the prototype for each property input.