-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: runtime structure * chore: lint * feat: support element template diff * chore: lint * feat(compiler): update structure in get template method (#62) * feat: support svg elements (#60) * feat: support svg elements * chore: fix lint and add notes * feat(compiler): update structure in get template method * fix(compiler): lint error * feat(compiler): use handler to distinguish events and on props * chore(compiler): add EventAttributeDescriptor interface Co-authored-by: Rongyan Chen <[email protected]> Co-authored-by: 狒狒神 <[email protected]> * feat: html method support new structure * feat: html method support new structure * fix(compiler): inject wrong value in runtime compiler * refactor: reactive node * chore: test case * fix(compiler): replace values with templateData in template result * chore: test case * chore: add test case * refactor: base render * chore: revert code * chore: test case * chore: lint * chore: ts type * chore: test case * chore: add comment * chore: remove useless comment * chore: add test case * chore: optimize code * chore: optimize code * chore: link * chore: optimize code Co-authored-by: NK <[email protected]> Co-authored-by: Rongyan Chen <[email protected]> Co-authored-by: 逆葵 <[email protected]>
- Loading branch information
1 parent
e5b302d
commit 6eddb4f
Showing
36 changed files
with
2,213 additions
and
1,308 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
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,21 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Basic</title> | ||
<style> | ||
.red { | ||
color: red; | ||
} | ||
.green { | ||
color: green; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<custom-element> | ||
</custom-element> | ||
<script type="module" src="/main.js"></script> | ||
</body> | ||
</html> |
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,34 @@ | ||
import { reactive, customElement, html } from 'pwc'; | ||
|
||
@customElement('custom-element') | ||
class CustomElement extends HTMLElement { | ||
@reactive | ||
accessor #title = 'default title'; | ||
|
||
@reactive | ||
accessor #list = ['item 1', 'item 2', 'item 3', 'item 4']; | ||
|
||
onClick() { | ||
this.#list.push('item 5'); | ||
} | ||
|
||
handleItemClick(index) { | ||
this.#list = [...this.#list.slice(0, index), ...this.#list.slice(index + 1)]; | ||
} | ||
|
||
get template() { | ||
return html`<div @click=${this.onClick}> | ||
${html`${this.#list.map((item, index) => { | ||
if (item === 'item 2') { | ||
return null; | ||
} | ||
if (item === 'item 3') { | ||
return [1, 2, 3].map((insideItem) => { | ||
return html`<div @click=${() => this.handleItemClick(index)}>inside list: ${insideItem}</div>`; | ||
}); | ||
} | ||
return html`<div @click=${() => this.handleItemClick(index)}>${item}</div>`; | ||
})}`} | ||
</div>`; | ||
} | ||
} |
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,18 @@ | ||
{ | ||
"name": "basic", | ||
"version": "0.0.0", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"preview": "vite preview" | ||
}, | ||
"devDependencies": { | ||
"rollup": "^2.0.0", | ||
"vite": "^2.7.2", | ||
"vite-plugin-babel": "^1.0.0" | ||
}, | ||
"dependencies": { | ||
"pwc": "workspace:*" | ||
}, | ||
"browserslist": "chrome > 60" | ||
} |
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,33 @@ | ||
import { defineConfig } from 'vite'; | ||
import babel from 'vite-plugin-babel'; | ||
|
||
export default defineConfig({ | ||
plugins: [ | ||
babel({ | ||
babelConfig: { | ||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
targets: { | ||
chrome: 99, | ||
}, | ||
modules: false, | ||
}, | ||
], | ||
], | ||
plugins: [ | ||
[ | ||
'@babel/plugin-proposal-decorators', | ||
{ | ||
version: '2021-12', | ||
}, | ||
], | ||
'@babel/plugin-proposal-class-properties', | ||
'@babel/plugin-proposal-class-static-block', | ||
'@babel/plugin-proposal-private-methods' | ||
], | ||
}, | ||
}), | ||
], | ||
}); |
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
Oops, something went wrong.