I have read the posts related and feel like my code is accurate; I have tried numerous mutations of this code as well. I am in hopes that someone can find what I am sure is a minor error in my code as I have had no luck detecting it.
Problem: Contents of foreignObject element not rendering in browser visually. DOM elements are apparently inserted into DOM but not visible.
I notice that in Chrome web developer that the foreignObject element is not camelcase in the element inspector however upon editing the html inline it is editable as camelcase, so evidently the element is held as camelcase. This likely has no impact on the issue but thought I would mention it.
DOM after executing:
<g class="component" transform="translate(75,20)">
<rect width="100" height="100" fill="red" opacity="1">
<foreignObject width="100" height="100" requiredExtensions="http://www.w3.org/1999/xhtml">
<body xmlns="http://www.w3.org/1999/xhtml">
<div style="width: 100px; height: 100px; background-color: yellow;" data-uid="special_uid">
</div>
</body>
</foreignObject>
</rect>
</g>
D3 SVG/XHTML generation code (CoffeeScript):
component = canvas.select("[data-uid=#{entityObj.name}]").selectAll('.component')
.data(entityObj.components)
.enter()
.append("g")
.each( (componentObj,i,d) =>
@generateAssociationLocalCache(entityObj,componentObj,i,d)
@generateComponentLocalCache(entityObj,componentObj,i,d)
)
.attr("data-uid", (o,i,d)-> o.name)
.attr("id", (o,i,d)-> o.name)
.attr("class", "component")
.attr("transform", (componentObj,i,d) =>
coords = @rows[entityObj.name]['components'][componentObj.uid]
"translate(#{coords.x},#{coords["y#{i}"]})"
)
.append("rect")
.attr("width", (componentObj,i,d) => componentObj.width)
.attr("height", @get('component').height)
.attr("fill", "red")
.attr("opacity", "1")
.append("foreignObject")
.attr("width", (componentObj,i,d) => componentObj.width)
.attr("height", @get('component').height)
.attr("requiredExtensions", "http://www.w3.org/1999/xhtml")
.append("body")
.attr("xmlns","http://www.w3.org/1999/xhtml")
.append("div")
.attr("style", (componentObj,i,d) => "width: #{componentObj.width}px; height: #{@get('component').height}px; background-color: yellow;")
.attr("data-uid", (o,i,d) -> o.uid)