-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
82 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import {config as beCnfg} from 'be-enhanced/config.js'; | ||
import {BE, BEConfig} from 'be-enhanced/BE.js'; | ||
import {Actions, PAP, AllProps} from './types'; | ||
import {MountObserver} from 'mount-observer/MountObserver.js'; | ||
|
||
export class BeBased extends BE<Element> implements Actions{ | ||
hydrate(self: this): PAP { | ||
const {enhancedElement, forAll, base, puntOn, fileName} = self; | ||
if(!base!.endsWith('/')){ | ||
return { | ||
base: base + '/', | ||
} | ||
} | ||
const mo = new MountObserver({ | ||
on: forAll!.join(','), | ||
do: { | ||
mount: (matchingElement) => { | ||
for(const attrib of forAll!){ | ||
this.#processEl(matchingElement, attrib, base!, fileName); | ||
} | ||
} | ||
} | ||
}) | ||
return { | ||
resolved: true, | ||
} | ||
} | ||
|
||
#processEl(node: Element, attrib: string, base: string, fileName?: string){ | ||
if(!(node as Element).hasAttribute(attrib)) return; | ||
let val = (node as Element).getAttribute(attrib)!; | ||
if(val.indexOf('//') !== -1) return; | ||
if(val.startsWith('data:')) return; | ||
if(val[0] === '#') return; | ||
//TODO: support paths that start with .. | ||
//console.log({attrib, base, val, fileName}); | ||
let newVal: string | undefined; | ||
if(val.startsWith('../')){ | ||
let split = base.split('/'); | ||
split.pop(); | ||
while(val.startsWith('../')){ | ||
val = val.substring(3); | ||
split.pop(); | ||
} | ||
newVal = split.join('/') + '/' + val; | ||
// }else if(val[0] === '#'){ | ||
// newVal = base + fileName + val; | ||
}else{ | ||
if(val[0] ==='/') val = val.substring(1); // this doesn't seem right - need to start from domain (?) | ||
newVal = base + val; | ||
} | ||
(node as Element).setAttribute(attrib, newVal); | ||
} | ||
} | ||
|
||
export interface BeBased extends AllProps{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {BeBased} from './be-based.js'; | ||
import {def} from 'trans-render/lib/def.js'; | ||
|
||
await BeBased.bootUp(); | ||
|
||
def('be-based', BeBased); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import './behance.js'; | ||
import {BeHive} from 'be-hive/be-hive.js'; | ||
|
||
|
||
BeHive.registry.register({ | ||
base: 'be-based', | ||
map: { | ||
'0.0': 'ni' | ||
} | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
"strict": true | ||
}, | ||
"files":[ | ||
"legacy/behivior.ts" | ||
"behivior.ts" | ||
], | ||
"exclude":[ | ||
"node_modules" | ||
|