-
Notifications
You must be signed in to change notification settings - Fork 0
/
getRemoteEl.js
18 lines (18 loc) · 767 Bytes
/
getRemoteEl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { findRealm } from 'trans-render/lib/findRealm.js';
import { camelToLisp } from 'trans-render/lib/camelToLisp.js';
const realmMap = new Map([
['#', (remoteProp) => ['wrn', '#' + remoteProp]],
['/', 'hostish'],
['@', (remoteProp) => ['wf', remoteProp]],
['|', (remoteProp) => ['wis', remoteProp]],
['-', (remoteProp) => ['wis', `[-${camelToLisp(remoteProp)}]`, true]],
['$', (remoteProp) => { throw 'NI'; }]
]);
export async function getRemoteEl(enhancedElement, typ, remoteProp) {
const scopeOrScopeFn = realmMap.get(typ);
const scope = (typeof scopeOrScopeFn === 'function' ? scopeOrScopeFn(remoteProp) : scopeOrScopeFn);
const el = await findRealm(enhancedElement, scope);
if (!el)
throw 404;
return el;
}