Skip to content

Commit 6079126

Browse files
committed
Fix issue in text node hydration.
1 parent de2ba00 commit 6079126

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

.haxerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"version": "dc1fbac",
2+
"version": "4.3.6",
33
"resolveLibs": "scoped"
44
}

haxe_libraries/tink_core.hxml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# @install: lix --silent download "gh://github.com/haxetink/tink_core#d74b0e03d7f9efcf2c2b73fecd99d240dd6d57ff" into tink_core/2.0.2/github/d74b0e03d7f9efcf2c2b73fecd99d240dd6d57ff
2-
-cp ${HAXE_LIBCACHE}/tink_core/2.0.2/github/d74b0e03d7f9efcf2c2b73fecd99d240dd6d57ff/src
3-
-D tink_core=2.0.2
1+
# @install: lix --silent download "gh://github.com/haxetink/tink_core#323f80d2ae63036e5b324dc68775f79e98bde396" into tink_core/2.1.1/github/323f80d2ae63036e5b324dc68775f79e98bde396
2+
-cp ${HAXE_LIBCACHE}/tink_core/2.1.1/github/323f80d2ae63036e5b324dc68775f79e98bde396/src
3+
-D tink_core=2.1.1

src/coconut/vdom/Html.hx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Html {
2626
}
2727

2828
static public function text(value:String):RenderResult
29-
return inline Text.inst.vnode(value, null, null, null);//TODO: would be faster to have a dedicated text node type insteat of going through factories and all that
29+
return inline TextNode.inst.vnode(value, null, null, null);//TODO: would be faster to have a dedicated text node type insteat of going through factories and all that
3030

3131
static public function raw(hxxMeta:HxxMeta<Element>, attr:HtmlFragmentAttr & { ?tag:String }):RenderResult {
3232
return HtmlFragment.byTag(attr.tag).vnode(attr, hxxMeta.key, hxxMeta.ref);
@@ -78,20 +78,24 @@ private class HtmlFragment extends Factory<HtmlFragmentAttr, Node, Element> {
7878

7979
}
8080

81-
private class Text extends Factory<String, Node, Node> {
82-
static public var inst(default, null):Text = new Text();
81+
private class TextNode extends Factory<String, Node, Text> {
82+
static public var inst(default, null):TextNode = new TextNode();
8383

8484
function new() {}
8585

86-
override public function adopt(target:Node)
86+
override public function adopt(target:Node):Text
8787
return
88-
if (target.nodeType == Node.TEXT_NODE) target;
88+
if (target.nodeType == Node.TEXT_NODE) cast target;
8989
else null;
9090

91+
override function hydrate(target:Text, data:String)
92+
if (target.textContent.length > data.length)
93+
target.splitText(data.length);
94+
9195
public function create(text)
9296
return document.createTextNode(text);
9397

94-
public function update(target:Node, nu, old)
98+
public function update(target:Text, nu, old)
9599
if (nu != old) target.textContent = nu;
96100
}
97101

0 commit comments

Comments
 (0)