-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from RKatarine/riazanova/change-const-to-let
Замена const-декларации на let для пропсов
- Loading branch information
Showing
6 changed files
with
80 additions
and
2 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
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
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 { element, attach, text, createContext, setupContext, finalizeContext } from 'endorphin/internal'; | ||
import { html } from './endorphin'; | ||
|
||
function ConstToLetComponent(props) { | ||
createContext(); | ||
let { a } = props; | ||
let b = props.b; | ||
|
||
setupContext([a, b], ConstToLetComponent_template, 3 /* a | b */); | ||
return finalizeContext((nextProps) => { props = nextProps;invalidate(0, a = nextProps.a);invalidate(1, b = nextProps.b) }); | ||
} | ||
|
||
|
||
function ConstToLetComponent_template(ctx, stage, refs) { | ||
const { scope, dirty } = ctx; | ||
if (stage === 1) { | ||
refs.length = 3; | ||
refs[0] = element("div"); | ||
attach(refs[0]); | ||
refs[0].appendChild(text("\n ")); | ||
refs[1] = text(scope[0]); | ||
refs[0].appendChild(refs[1]); | ||
refs[0].appendChild(text("\n ")); | ||
refs[2] = element("span"); | ||
refs[0].appendChild(refs[2]); | ||
refs[2].innerText = scope[1]; | ||
refs[0].appendChild(text("\n ")); | ||
} else if (stage === 2) { | ||
(dirty & 1 /* a */) && (refs[1].nodeValue = scope[0]); | ||
(dirty & 2 /* b */) && (refs[2].innerText = scope[1]); | ||
} else if (stage === 3) { | ||
refs[0].remove(); | ||
} | ||
} |
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,11 @@ | ||
import { html } from './endorphin'; | ||
|
||
function ConstToLetComponent(props) { | ||
const { a } = props; | ||
const b = props.b; | ||
|
||
return html`<div> | ||
${a} | ||
<span> ${b}</span> | ||
</div>`; | ||
} |