Skip to content

Commit

Permalink
fix: fix set Element.style.cssText API.
Browse files Browse the repository at this point in the history
  • Loading branch information
andycall committed Aug 11, 2023
1 parent 9c143d1 commit 853b72e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bridge/core/css/inline_css_style_declaration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ ScriptValue InlineCssStyleDeclaration::item(const AtomicString& key, ExceptionSt
bool InlineCssStyleDeclaration::SetItem(const AtomicString& key,
const ScriptValue& value,
ExceptionState& exception_state) {
if (IsPrototypeMethods(key)) {
return false;
}

std::string propertyName = key.ToStdString(ctx());
return InternalSetProperty(propertyName, value.ToLegacyDOMString());
}
Expand Down
23 changes: 23 additions & 0 deletions integration_tests/specs/cssom/cssom-setCssText-serialize.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<title>CSSOM Parsing Test: getting cssText must return the result of serializing the CSS declaration blocks.</title>
<link rel="author" title="Paul Irish" href="mailto:paul.irish@gmail.com">
<link rel="help" href="http://www.w3.org/TR/cssom-1/#the-cssstyledeclaration-interface">

<meta name="flags" content="dom">
</head>

<body>
<div id="log"></div>
<div id="box"></div>
<script>
var style = document.getElementById('box').style;
style.cssText = 'left: 10px';
assert_equals(style.left, '10px');
style.cssText = 'right: 20px; left: 10px';
assert_equals(style.left, '10px');
assert_equals(style.right, '20px');
</script>
</body>
</html>

0 comments on commit 853b72e

Please sign in to comment.