When built with gcc-8 RelWithDebInfo, adds "display: block" to some elements with changed tag names
- Clone Wt into a subfolder
wtof the location of
CMakeLists.txt(checkout tag 4.0.5)
mkdir build && cd build
cmake .. && make
./bugdemo --docroot . --http-listen 127.0.0.1:8080
- Point a browser at
- Inspect the text element
<nav id="someId" class="navbar> <span id="someOtherId">Bug demo</span> </nav>
<nav id="someId" class="navbar style="display: block;"> <span id="someOtherId">Bug demo</span> </nav>
This only happens when built with gcc-8 in CMake's default
RelWithDebInfo config. If you do
cmake .. -DCMAKE_BUILD_TYPE=Debug so that it instead builds
libwtd.so, the bug does not happen. If you build with gcc-9, the bug does not happen.
From my investigation, the root of the issue seems to be in
DomElement.isDefaultInline. This is called from
WWebWidget.updateDom and the extra
display: block is added if it returns true. In the case of this
<nav> element, its type is
DomElementType::OTHER, whose ordinal is 51, and we look in
defaultInline_ at that index for an answer, but that array has only 50 elements. When built in any of the "good" configurations,
defaultInline_ evaluates to false. When built in the "bad" configuration, it evaluates (on my system) to 97, i.e. true.
Seems to me like two "easy" fixes would be
- Add two more
defaultInline_to bring its size in line with the number of
isDefaultInline, check if
static_cast<unsigned int>(type) > 49and just return false if so
But I'm not sure what the other implications of that might be.
Note: In my own project, I've seen this happen in 2 places: a
WContainerWidget whose tag name was changed to "nav" (like in my example), and a
WTemplateFormView whose tag name was changed to "form". Other elements have changed tag names but do not exhibit this behavior.