Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
link: function(scope: IPortalScope, elem, attrs) {
const debug = (method: string, message: string, ...args) =>
debugLog('angularjs', 'react-ui-view-adapter', `${$id}/${attrs.name}`, method, message, ...args);
const el = elem[0];
let _ref = null;
let destroyed = false;
const $id = id++;
const ignoredAttrKeys = ['$$element', '$attr'];
attrs = filter(attrs, (val, key) => ignoredAttrKeys.indexOf(key) === -1) as any;
debug('.link()', 'linking react-ui-view-adapter into ', el, attrs);
// The UIView ref callback, which is called after the initial render
const ref = (ref: HTMLElement) => {
// If refs are the same - don't re-render React component.
const isSameRef = ref && _ref === ref;
// If previously there was a ref, and the new `ref` is empty - the component was unmounted.
// Leave the unmounted component as it was, and don't try to re-mount it.
const isComponentUnmounted = !ref && _ref;
if (isSameRef || isComponentUnmounted) {
return;
}