Skip to content

Commit

Permalink
0.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
bahrus committed Jun 4, 2023
1 parent a9a464f commit ce1d00f
Show file tree
Hide file tree
Showing 5 changed files with 202 additions and 6 deletions.
175 changes: 175 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"be-enhanced": "0.0.25",
"be-exportable": "0.0.75",
"be-hive": "0.0.99",
"be-linked": "0.0.15",
"be-propagating": "0.0.11",
"obj-ml": "0.0.9",
"trans-render": "0.0.684"
Expand Down
13 changes: 11 additions & 2 deletions v2/be-derived.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { register } from 'be-hive/register.js';
export class BeDerived extends BE {
static get beConfig() {
return {
parse: false,
parse: true,
};
}
async attach(enhancedElement, enhancementInfo) {
Expand All @@ -14,10 +14,18 @@ export class BeDerived extends BE {
const derivedObject = {};
const { childrenParsed } = await import('be-a-beacon/childrenParsed.js');
await childrenParsed(enhancedElement);
console.log('do the processing');
let itempropElements = Array.from(enhancedElement.querySelectorAll('[itemprop]'));
itempropElements = itempropElements.filter(x => x.closest('[itemscope]') === enhancedElement);
const { getItemPropVal } = await import('be-linked/getItemPropVal.js'); //TODO: rename
for (const itempropElement of itempropElements) {
derivedObject[itempropElement.getAttribute('itemprop')] = await getItemPropVal(itempropElement);
}
this.derivedObject = derivedObject;
this.resolved = true;
}
logToConsole(self) {
const { derivedObject } = self;
console.log({ derivedObject });
}
}
const tagName = 'be-derived';
Expand All @@ -28,6 +36,7 @@ const xe = new XE({
tagName,
propDefaults: {
...propDefaults,
log: false,
},
propInfo: {
...propInfo
Expand Down
14 changes: 11 additions & 3 deletions v2/be-derived.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { JSONObject } from 'trans-render/lib/types';
export class BeDerived extends BE<AP, Actions> implements Actions{
static override get beConfig(): BEConfig<any> {
return {
parse: false,
parse: true,
}
}

Expand All @@ -18,12 +18,19 @@ export class BeDerived extends BE<AP, Actions> implements Actions{
const derivedObject: JSONObject = {};
const {childrenParsed} = await import('be-a-beacon/childrenParsed.js');
await childrenParsed(enhancedElement);
console.log('do the processing');
let itempropElements = Array.from(enhancedElement.querySelectorAll('[itemprop]'));
itempropElements = itempropElements.filter(x => x.closest('[itemscope]') === enhancedElement);
const {getItemPropVal} = await import('be-linked/getItemPropVal.js'); //TODO: rename
for(const itempropElement of itempropElements){
derivedObject[itempropElement.getAttribute('itemprop')!] = await getItemPropVal(itempropElement);
}
this.derivedObject = derivedObject;
this.resolved = true;
}

logToConsole(self: this): void {
const {derivedObject} = self;

console.log({derivedObject});
}
}

Expand All @@ -38,6 +45,7 @@ const xe = new XE<AP, Actions>({
tagName,
propDefaults: {
...propDefaults,
log: false,
},
propInfo:{
...propInfo
Expand Down
5 changes: 4 additions & 1 deletion v2/demo/dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Document</title>
</head>
<body>
<div itemscope be-derived>
<div itemscope be-derived='{"log": true}'>
<data be-a-beacon itemprop="count" value=30>Thirty</data>
</div>
<script type=importmap>
Expand All @@ -16,6 +16,9 @@
"be-a-beacon/": "../../node_modules/be-a-beacon/",
"be-enhanced/": "../../node_modules/be-enhanced/",
"be-hive/": "../../node_modules/be-hive/",
"be-intl/": "../../node_modules/be-intl/",
"be-linked/": "../../node_modules/be-linked/",
"be-propagating/": "../../node_modules/be-propagating/",
"trans-render/": "../../node_modules/trans-render/",
"xtal-element/": "../../node_modules/xtal-element/"
}
Expand Down

0 comments on commit ce1d00f

Please sign in to comment.