summaryrefslogtreecommitdiffstats
path: root/codon.mjs
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2021-02-19 13:13:39 -0500
committerBrian Cully <bjc@kublai.com>2021-02-19 13:13:39 -0500
commited96e5c2964d93bd5b43f85577ef4ab7c217fa2d (patch)
tree2aaae3bcebe3ab87301ea9fd77eddc0915a0722b /codon.mjs
parent0a703e8f463dfadcf102e0b553d798b8046b03ee (diff)
downloadmolsim2-ed96e5c2964d93bd5b43f85577ef4ab7c217fa2d.tar.gz
molsim2-ed96e5c2964d93bd5b43f85577ef4ab7c217fa2d.zip
Update amino acid in DOM after selection.
Diffstat (limited to 'codon.mjs')
-rw-r--r--codon.mjs17
1 files changed, 15 insertions, 2 deletions
diff --git a/codon.mjs b/codon.mjs
index 6163883..c5f8328 100644
--- a/codon.mjs
+++ b/codon.mjs
@@ -4,7 +4,6 @@ import Nucleotide from './nucleotide.mjs'
class Codon {
constructor(n1, n2, n3) {
this.bases = [n1, n2, n3]
- this.aminoAcid = new AminoAcid(n1, n2, n3)
const nucleotideList = document.createElement('ol')
this.bases = [n1, n2, n3].map(base => {
@@ -14,7 +13,8 @@ class Codon {
return n
})
this.elt.appendChild(nucleotideList)
- this.elt.appendChild(this.aminoAcid.elt)
+
+ this.aminoAcid = new AminoAcid(n1, n2, n3)
}
get elt() {
@@ -29,6 +29,19 @@ class Codon {
return this.bases.map(b => b.value).join('')
}
+ get aminoAcid() {
+ return this._aminoAcid
+ }
+
+ set aminoAcid(value) {
+ this._aminoAcid = value
+ const oldElt = this.elt.querySelector('.amino-acid')
+ if (oldElt) {
+ this.elt.removeChild(oldElt)
+ }
+ this.elt.appendChild(value.elt)
+ }
+
lock() {
this.bases.forEach(n => n.lock())
this.aminoAcid.lock()