Skip to content
This repository has been archived by the owner on Dec 17, 2020. It is now read-only.

Commit

Permalink
Use innerHTML property to set dynamic resource as an image
Browse files Browse the repository at this point in the history
For some reasons EDGE doesn't show svg image created from the server
side. So instead of creating a real "object" element it's set as
"innerHTML" property for its "fake" parent element.

Fixes #184
  • Loading branch information
Denis Anisimov committed Mar 9, 2017
1 parent 292230c commit aeeaa59
Showing 1 changed file with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ private void createGenerateImageButton() {
Button button = new Button("Generate image");

button.addClickListener(event -> {
image.setAttribute("data", createResource());
// image.setAttribute("data", createResource());
updateImage();
});

add(button);
Expand All @@ -83,14 +84,24 @@ private void createImageOpener() {
}

private void createImage() {
image = new Element("object");
image.setAttribute("type", "image/svg+xml");
image.getStyle().set("display", "block");
image.setAttribute("data", createResource());
image = new Element("div");
// image.setAttribute("type", "image/svg+xml");
// image.getStyle().set("display", "block");
// image.setAttribute("data", createResource());
updateImage();

getElement().appendChild(image);

}

private void updateImage() {
StreamResource resource = createResource();
image.setAttribute("non-existent", resource);
image.setProperty("innerHTML",
"<object type='image/svg+xml' style='display:block' data='"
+ image.getAttribute("non-existent") + "'></object>");
}

private StreamResource createResource() {
return new StreamResource("image.svg", this::getImageInputStream);
}
Expand Down

0 comments on commit aeeaa59

Please sign in to comment.