mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 02:17:35 +00:00
LibWeb: Invalidate element style after setting Element.style.foo
This makes us recompute style for the element so the change actually takes effect. :^)
This commit is contained in:
parent
6c8185151e
commit
cad4cc9a2a
5 changed files with 40 additions and 5 deletions
|
@ -24,8 +24,10 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/ScopeGuard.h>
|
||||
#include <LibWeb/Bindings/CSSStyleDeclarationWrapper.h>
|
||||
#include <LibWeb/CSS/Parser/DeprecatedCSSParser.h>
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
|
||||
namespace Web::Bindings {
|
||||
|
||||
|
@ -58,6 +60,12 @@ bool CSSStyleDeclarationWrapper::put(const JS::PropertyName& name, JS::Value val
|
|||
if (!new_value)
|
||||
return false;
|
||||
|
||||
ScopeGuard style_invalidation_guard = [&] {
|
||||
auto& declaration = downcast<CSS::ElementInlineCSSStyleDeclaration>(impl());
|
||||
if (auto* element = declaration.element())
|
||||
element->invalidate_style();
|
||||
};
|
||||
|
||||
// FIXME: I don't think '!important' is being handled correctly here..
|
||||
|
||||
for (auto& property : impl().m_properties) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue