mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-15 15:58:57 +00:00
use CData.render for innerText
This commit is contained in:
@@ -172,5 +172,5 @@
|
||||
|
||||
// TODO innerText is not rendered correctly for now.
|
||||
//testing.expectEqual("This is a\ntext", d2.innerText);
|
||||
testing.expectEqual(" This is a \n text", d2.innerText);
|
||||
testing.expectEqual(" This is a \n text ", d2.innerText);
|
||||
</script>
|
||||
|
||||
@@ -102,7 +102,8 @@ pub fn render(self: *const CData, writer: *std.io.Writer, opts: RenderOpts) !voi
|
||||
// Write the reminder chunk.
|
||||
if (is_w) {
|
||||
// Last chunk is whitespaces.
|
||||
if (opts.trim_right == false) {
|
||||
// If the string contains only whitespaces, don't write it.
|
||||
if (start > 0 and opts.trim_right == false) {
|
||||
try writer.writeByte(' ');
|
||||
}
|
||||
} else {
|
||||
@@ -285,6 +286,8 @@ test "WebApi: CData.render" {
|
||||
};
|
||||
|
||||
const test_cases = [_]TestCase{
|
||||
.{ .value = " ", .expected = "" },
|
||||
.{ .value = " ", .expected = "", .opts = .{ .trim_left = false, .trim_right = false } },
|
||||
.{ .value = "foo bar", .expected = "foo bar" },
|
||||
.{ .value = "foo bar", .expected = "foo bar" },
|
||||
.{ .value = " foo bar", .expected = "foo bar" },
|
||||
|
||||
@@ -239,7 +239,7 @@ pub fn getInnerText(self: *Element, writer: *std.Io.Writer) !void {
|
||||
},
|
||||
.cdata => |c| switch (c._type) {
|
||||
.comment => continue,
|
||||
.text => try c.render(writer, .{}),
|
||||
.text => try c.render(writer, .{ .trim_right = false, .trim_left = false }),
|
||||
},
|
||||
.document => {},
|
||||
.document_type => {},
|
||||
|
||||
Reference in New Issue
Block a user