danfickle/neoflyingsaucer

:before pseudo-class doesn't work

hrj opened this issue · 3 comments

hrj commented

:after works fine, but :before doesn't.

I will try to create a test-case later.

I finally got around to creating a test case and it seems to work. Test case below. Note the Blue pixel in the top-left corner.

    @Test
    public void testBeforeInsertedContent()
    {
        String html =
            "<html><head><style>" +
            "@page { size: 2px 5px; margin: 0; }" +
            "body { background-color: #0f0; margin: 0; }" +
            ".div1 { background-color: #f00; padding: 0; margin: 0; height: 4px; width: 2px; }" +
            ".div1:before { content: \" \"; display:block; background-color: #00f; width: 1px; height: 1px; padding: 0; margin: 0; }" +
            "</style></head><body><div class=\"div1\"></div></body></html>";

        String expected = 
            "BR" +
            "RR" +
            "RR" +
            "RR" +
            "GG";

        BufferedImageTest.assertImgEquals(html, expected, 2, 100, 100, 0);
    }

You don't remember the case in which it didn't work, by any chance?

hrj commented

Sorry, I can't remember the test-case now. Should have added the test case when I reported it.

You can try my website. It uses :before on the menu elements. Most probably I was testing that site with flyingsaucer while reporting this. I have lost the context, so I can't test it myself right now.

Ok, thanks, I'll have a look.