Skip to content

HTML Output for "attrs()" in combination with ".withClass()" does not work #224

@rrarrarra

Description

@rrarrarra

Actual behavior (the bug)

<div class="def"></div>

Expected behavior

<div class="abc def"></div>

To Reproduce

import static j2html.TagCreator.*;

import org.junit.Assert;

public class Bug {
	
	public static final void bug() {
		
		final String html = div(attrs(".abc"))
			.withClass("def") //or:  .withClasses("def")
			.withText("")
			.render();
		
		System.out.println(html); // prints:  <div class="def"></div>
		
		Assert.assertEquals("<div class=\"abc def\"></div>", html); // Expected is:  <div class="abc def"></div>
	}
	
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions