Skip to content

Commit bea0708

Browse files
committed
fix naming of BNode variants
1 parent 0678829 commit bea0708

7 files changed

Lines changed: 55 additions & 55 deletions

File tree

packages/yew/src/dom_bundle/bcomp.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl Reconcilable for VComp {
9292
) -> NodeRef {
9393
match bundle {
9494
// If the existing bundle is the same type, reuse it and update its properties
95-
BNode::BComp(ref mut bcomp)
95+
BNode::Comp(ref mut bcomp)
9696
if self.type_id == bcomp.type_id && self.key == bcomp.key =>
9797
{
9898
self.reconcile(parent_scope, parent, next_sibling, bcomp)
@@ -216,7 +216,7 @@ impl ComponentRenderState {
216216
let placeholder: Node = document().create_text_node("").into();
217217
insert_node(&placeholder, &parent, next_sibling.get().as_ref());
218218
node_ref.set(Some(placeholder.clone()));
219-
BNode::BRef(placeholder)
219+
BNode::Ref(placeholder)
220220
};
221221
Self {
222222
root_node: placeholder,
@@ -232,7 +232,7 @@ impl ComponentRenderState {
232232
use super::blist::BList;
233233

234234
Self {
235-
root_node: BNode::BList(BList::new()),
235+
root_node: BNode::List(BList::new()),
236236
parent: None,
237237
next_sibling: NodeRef::default(),
238238
html_sender: Some(tx),

packages/yew/src/dom_bundle/blist.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ impl BNode {
101101
/// Assert that a bundle node is a list, or convert it to a list with a single child
102102
fn make_list(&mut self) -> &mut BList {
103103
match self {
104-
Self::BList(blist) => blist,
104+
Self::List(blist) => blist,
105105
self_ => {
106-
let b = std::mem::replace(self_, BNode::BList(BList::new()));
106+
let b = std::mem::replace(self_, BNode::List(BList::new()));
107107
let self_list = match self_ {
108-
BNode::BList(blist) => blist,
108+
BNode::List(blist) => blist,
109109
_ => unreachable!("just been set to the variant"),
110110
};
111111
let key = b.key().cloned();

packages/yew/src/dom_bundle/bnode.rs

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,32 @@ use web_sys::{Element, Node};
1111
/// The bundle implementation to [VNode].
1212
pub enum BNode {
1313
/// A bind between `VTag` and `Element`.
14-
BTag(Box<BTag>),
14+
Tag(Box<BTag>),
1515
/// A bind between `VText` and `TextNode`.
16-
BText(BText),
16+
Text(BText),
1717
/// A bind between `VComp` and `Element`.
18-
BComp(BComp),
18+
Comp(BComp),
1919
/// A holder for a list of other nodes.
20-
BList(BList),
20+
List(BList),
2121
/// A portal to another part of the document
22-
BPortal(BPortal),
22+
Portal(BPortal),
2323
/// A holder for any `Node` (necessary for replacing node).
24-
BRef(Node),
24+
Ref(Node),
2525
/// A suspendible document fragment.
26-
BSuspense(Box<BSuspense>),
26+
Suspense(Box<BSuspense>),
2727
}
2828

2929
impl BNode {
3030
/// Get the key of the underlying node
3131
pub(super) fn key(&self) -> Option<&Key> {
3232
match self {
33-
Self::BComp(bsusp) => bsusp.key(),
34-
Self::BList(blist) => blist.key(),
35-
Self::BRef(_) => None,
36-
Self::BTag(btag) => btag.key(),
37-
Self::BText(_) => None,
38-
Self::BPortal(bportal) => bportal.key(),
39-
Self::BSuspense(bsusp) => bsusp.key(),
33+
Self::Comp(bsusp) => bsusp.key(),
34+
Self::List(blist) => blist.key(),
35+
Self::Ref(_) => None,
36+
Self::Tag(btag) => btag.key(),
37+
Self::Text(_) => None,
38+
Self::Portal(bportal) => bportal.key(),
39+
Self::Suspense(bsusp) => bsusp.key(),
4040
}
4141
}
4242
}
@@ -45,34 +45,34 @@ impl DomBundle for BNode {
4545
/// Remove VNode from parent.
4646
fn detach(self, parent: &Element, parent_to_detach: bool) {
4747
match self {
48-
Self::BTag(vtag) => vtag.detach(parent, parent_to_detach),
49-
Self::BText(btext) => btext.detach(parent, parent_to_detach),
50-
Self::BComp(bsusp) => bsusp.detach(parent, parent_to_detach),
51-
Self::BList(blist) => blist.detach(parent, parent_to_detach),
52-
Self::BRef(ref node) => {
48+
Self::Tag(vtag) => vtag.detach(parent, parent_to_detach),
49+
Self::Text(btext) => btext.detach(parent, parent_to_detach),
50+
Self::Comp(bsusp) => bsusp.detach(parent, parent_to_detach),
51+
Self::List(blist) => blist.detach(parent, parent_to_detach),
52+
Self::Ref(ref node) => {
5353
// Always remove user-defined nodes to clear possible parent references of them
5454
if parent.remove_child(node).is_err() {
5555
console::warn!("Node not found to remove VRef");
5656
}
5757
}
58-
Self::BPortal(bportal) => bportal.detach(parent, parent_to_detach),
59-
Self::BSuspense(bsusp) => bsusp.detach(parent, parent_to_detach),
58+
Self::Portal(bportal) => bportal.detach(parent, parent_to_detach),
59+
Self::Suspense(bsusp) => bsusp.detach(parent, parent_to_detach),
6060
}
6161
}
6262

6363
fn shift(&self, next_parent: &Element, next_sibling: NodeRef) {
6464
match self {
65-
Self::BTag(ref vtag) => vtag.shift(next_parent, next_sibling),
66-
Self::BText(ref btext) => btext.shift(next_parent, next_sibling),
67-
Self::BComp(ref bsusp) => bsusp.shift(next_parent, next_sibling),
68-
Self::BList(ref vlist) => vlist.shift(next_parent, next_sibling),
69-
Self::BRef(ref node) => {
65+
Self::Tag(ref vtag) => vtag.shift(next_parent, next_sibling),
66+
Self::Text(ref btext) => btext.shift(next_parent, next_sibling),
67+
Self::Comp(ref bsusp) => bsusp.shift(next_parent, next_sibling),
68+
Self::List(ref vlist) => vlist.shift(next_parent, next_sibling),
69+
Self::Ref(ref node) => {
7070
next_parent
7171
.insert_before(node, next_sibling.get().as_ref())
7272
.unwrap();
7373
}
74-
Self::BPortal(ref vportal) => vportal.shift(next_parent, next_sibling),
75-
Self::BSuspense(ref vsuspense) => vsuspense.shift(next_parent, next_sibling),
74+
Self::Portal(ref vportal) => vportal.shift(next_parent, next_sibling),
75+
Self::Suspense(ref vsuspense) => vsuspense.shift(next_parent, next_sibling),
7676
}
7777
}
7878
}
@@ -105,7 +105,7 @@ impl Reconcilable for VNode {
105105
}
106106
VNode::VRef(node) => {
107107
super::insert_node(&node, parent, next_sibling.get().as_ref());
108-
(NodeRef::new(node.clone()), BNode::BRef(node))
108+
(NodeRef::new(node.clone()), BNode::Ref(node))
109109
}
110110
VNode::VPortal(vportal) => {
111111
let (node_ref, portal) = vportal.attach(parent_scope, parent, next_sibling);
@@ -142,7 +142,7 @@ impl Reconcilable for VNode {
142142
VNode::VList(vlist) => vlist.reconcile_node(parent_scope, parent, next_sibling, bundle),
143143
VNode::VRef(node) => {
144144
let _existing = match bundle {
145-
BNode::BRef(ref n) if &node == n => n,
145+
BNode::Ref(ref n) if &node == n => n,
146146
_ => {
147147
return VNode::VRef(node).replace(
148148
parent_scope,
@@ -167,55 +167,55 @@ impl Reconcilable for VNode {
167167
impl From<BText> for BNode {
168168
#[inline]
169169
fn from(btext: BText) -> Self {
170-
Self::BText(btext)
170+
Self::Text(btext)
171171
}
172172
}
173173

174174
impl From<BList> for BNode {
175175
#[inline]
176176
fn from(blist: BList) -> Self {
177-
Self::BList(blist)
177+
Self::List(blist)
178178
}
179179
}
180180

181181
impl From<BTag> for BNode {
182182
#[inline]
183183
fn from(btag: BTag) -> Self {
184-
Self::BTag(Box::new(btag))
184+
Self::Tag(Box::new(btag))
185185
}
186186
}
187187

188188
impl From<BComp> for BNode {
189189
#[inline]
190190
fn from(bcomp: BComp) -> Self {
191-
Self::BComp(bcomp)
191+
Self::Comp(bcomp)
192192
}
193193
}
194194

195195
impl From<BPortal> for BNode {
196196
#[inline]
197197
fn from(bportal: BPortal) -> Self {
198-
Self::BPortal(bportal)
198+
Self::Portal(bportal)
199199
}
200200
}
201201

202202
impl From<BSuspense> for BNode {
203203
#[inline]
204204
fn from(bsusp: BSuspense) -> Self {
205-
Self::BSuspense(Box::new(bsusp))
205+
Self::Suspense(Box::new(bsusp))
206206
}
207207
}
208208

209209
impl fmt::Debug for BNode {
210210
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
211211
match *self {
212-
Self::BTag(ref vtag) => vtag.fmt(f),
213-
Self::BText(ref btext) => btext.fmt(f),
214-
Self::BComp(ref bsusp) => bsusp.fmt(f),
215-
Self::BList(ref vlist) => vlist.fmt(f),
216-
Self::BRef(ref vref) => write!(f, "VRef ( \"{}\" )", crate::utils::print_node(vref)),
217-
Self::BPortal(ref vportal) => vportal.fmt(f),
218-
Self::BSuspense(ref bsusp) => bsusp.fmt(f),
212+
Self::Tag(ref vtag) => vtag.fmt(f),
213+
Self::Text(ref btext) => btext.fmt(f),
214+
Self::Comp(ref bsusp) => bsusp.fmt(f),
215+
Self::List(ref vlist) => vlist.fmt(f),
216+
Self::Ref(ref vref) => write!(f, "VRef ( \"{}\" )", crate::utils::print_node(vref)),
217+
Self::Portal(ref vportal) => vportal.fmt(f),
218+
Self::Suspense(ref bsusp) => bsusp.fmt(f),
219219
}
220220
}
221221
}

packages/yew/src/dom_bundle/bportal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl Reconcilable for VPortal {
6464
bundle: &mut BNode,
6565
) -> NodeRef {
6666
match bundle {
67-
BNode::BPortal(portal) => self.reconcile(parent_scope, parent, next_sibling, portal),
67+
BNode::Portal(portal) => self.reconcile(parent_scope, parent, next_sibling, portal),
6868
_ => self.replace(parent_scope, parent, next_sibling, bundle),
6969
}
7070
}

packages/yew/src/dom_bundle/bsuspense.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl Reconcilable for VSuspense {
100100
) -> NodeRef {
101101
match bundle {
102102
// We only preserve the child state if they are the same suspense.
103-
BNode::BSuspense(m)
103+
BNode::Suspense(m)
104104
if m.key == self.key
105105
&& self.detached_parent.as_ref() == Some(&m.detached_parent) =>
106106
{

packages/yew/src/dom_bundle/btag/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl Reconcilable for VTag {
162162
match bundle {
163163
// If the ancestor is a tag of the same type, don't recreate, keep the
164164
// old tag and update its attributes and children.
165-
BNode::BTag(ex) if self.key == ex.key => {
165+
BNode::Tag(ex) if self.key == ex.key => {
166166
if match (&self.inner, &ex.inner) {
167167
(VTagInner::Input(_), BTagInner::Input(_)) => true,
168168
(VTagInner::Textarea { .. }, BTagInner::Textarea { .. }) => true,
@@ -447,7 +447,7 @@ mod tests {
447447
}
448448

449449
fn assert_btag_ref(node: &BNode) -> &BTag {
450-
if let BNode::BTag(vtag) = node {
450+
if let BNode::Tag(vtag) = node {
451451
return vtag;
452452
}
453453
panic!("should be btag");
@@ -461,7 +461,7 @@ mod tests {
461461
}
462462

463463
fn assert_btag_mut(node: &mut BNode) -> &mut BTag {
464-
if let BNode::BTag(btag) = node {
464+
if let BNode::Tag(btag) = node {
465465
return btag;
466466
}
467467
panic!("should be btag");

packages/yew/src/dom_bundle/btext.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl Reconcilable for VText {
5959
bundle: &mut BNode,
6060
) -> NodeRef {
6161
match bundle {
62-
BNode::BText(btext) => self.reconcile(parent_scope, parent, next_sibling, btext),
62+
BNode::Text(btext) => self.reconcile(parent_scope, parent, next_sibling, btext),
6363
_ => self.replace(parent_scope, parent, next_sibling, bundle),
6464
}
6565
}

0 commit comments

Comments
 (0)