-
Notifications
You must be signed in to change notification settings - Fork 22.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add docs for SVGElement.attributeStyleMap
and MathMLElement.attributeStyleMap
#33642
Merged
hamishwillee
merged 2 commits into
mdn:main
from
skyclouds2001:SVGElement,MathMLElement.attributeStyleMap
Jun 13, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ browser-compat: api.HTMLElement.attributeStyleMap | |
|
||
{{APIRef("CSSOM")}} | ||
|
||
The **`attributeStyleMap`** read-only property of the {{domxref("HTMLElement")}} interface returns a live {{domxref("StylePropertyMap")}} object that contains a list of style properties of the element that are defined in the element's inline [`style`](/en-US/docs/Web/HTML/Global_attributes/style) attribute, or assigned using the {{domxref("HTMLElement.style", "style")}} property of the {{domxref("HTMLElement")}} interface via script. | ||
The **`attributeStyleMap`** read-only property of the {{domxref("HTMLElement")}} interface returns a live {{domxref("StylePropertyMap")}} object that contains a list of style properties of the element that are defined in the element's inline `style` attribute, or assigned using the {{domxref("HTMLElement.style", "style")}} property of the {{domxref("HTMLElement")}} interface via script. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume by "live" you mean dynamically updated? Doesn't matter, looks good to me :-) |
||
|
||
Shorthand properties are expanded. If you set `border-top: 1px solid black`, the longhand properties ({{cssxref("border-top-color")}}, {{cssxref("border-top-style")}}, and {{cssxref("border-top-width")}}) are set instead. | ||
|
||
|
@@ -22,7 +22,7 @@ A live {{domxref("StylePropertyMap")}} object. | |
|
||
## Examples | ||
|
||
The following code snippet shows the relationship between HTML `style` attribute and `attributeStyleMap` property: | ||
The following code snippet shows the relationship between the `style` attribute and the `attributeStyleMap` property: | ||
|
||
```html | ||
<div style="white-space: pre-line;"> | ||
|
@@ -61,3 +61,5 @@ for (const property of element.attributeStyleMap) { | |
## See also | ||
|
||
- {{domxref("HTMLElement.style")}} | ||
- {{domxref("SVGElement.attributeStyleMap")}} | ||
- {{domxref("MathMLElement.attributeStyleMap")}} |
72 changes: 72 additions & 0 deletions
72
files/en-us/web/api/mathmlelement/attributestylemap/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
--- | ||
title: "MathMLElement: attributeStyleMap property" | ||
short-title: attributeStyleMap | ||
slug: Web/API/MathMLElement/attributeStyleMap | ||
page-type: web-api-instance-property | ||
browser-compat: api.MathMLElement.attributeStyleMap | ||
--- | ||
|
||
{{APIRef("CSSOM")}} | ||
|
||
The **`attributeStyleMap`** read-only property of the {{domxref("MathMLElement")}} interface returns a live {{domxref("StylePropertyMap")}} object that contains a list of style properties of the element that are defined in the element's inline `style` attribute, or assigned using the {{domxref("MathMLElement.style", "style")}} property of the {{domxref("MathMLElement")}} interface via script. | ||
|
||
Shorthand properties are expanded. If you set `border-top: 1px solid black`, the longhand properties ({{cssxref("border-top-color")}}, {{cssxref("border-top-style")}}, and {{cssxref("border-top-width")}}) are set instead. | ||
|
||
The main difference between {{domxref("MathMLElement.style", "style")}} property and `attributeStyleMap` property is that, the `style` property will return a {{domxref("CSSStyleDeclaration")}} object, while the `attributeStyleMap` property will return a {{domxref("StylePropertyMap")}} object. | ||
|
||
Though the property itself is not writable, you could read and write inline styles through the {{domxref("StylePropertyMap")}} object that it returns, just like through the {{domxref("CSSStyleDeclaration")}} object that returns via the `style` property. | ||
|
||
## Value | ||
|
||
A live {{domxref("StylePropertyMap")}} object. | ||
|
||
## Examples | ||
|
||
The following code snippet shows the relationship between the `style` attribute and the `attributeStyleMap` property: | ||
|
||
```html | ||
<div style="white-space: pre-line;"> | ||
<math xmlns="http://www.w3.org/1998/Math/MathML"> | ||
<mrow> | ||
<mi>f</mi> | ||
<mo stretchy="false">(</mo> | ||
<mi id="el" style="border-top: 1px solid blue; color: red;">x</mi> | ||
<mo stretchy="false">)</mo> | ||
<mo>=</mo> | ||
<mi>x</mi> | ||
</mrow> | ||
</math> | ||
<div id="output"></div> | ||
</div> | ||
``` | ||
|
||
```css | ||
#el { | ||
font-size: 16px; | ||
} | ||
``` | ||
|
||
```js | ||
const element = document.getElementById("el"); | ||
const output = document.getElementById("output"); | ||
|
||
for (const property of element.attributeStyleMap) { | ||
output.textContent += `${property[0]} = ${property[1][0].toString()}\n`; | ||
} | ||
``` | ||
|
||
{{EmbedLiveSample("Examples", "200", "200")}} | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} | ||
|
||
## See also | ||
|
||
- {{domxref("MathMLElement.style")}} | ||
- {{domxref("HTMLElement.attributeStyleMap")}} | ||
- {{domxref("SVGElement.attributeStyleMap")}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
--- | ||
title: "SVGElement: attributeStyleMap property" | ||
short-title: attributeStyleMap | ||
slug: Web/API/SVGElement/attributeStyleMap | ||
page-type: web-api-instance-property | ||
browser-compat: api.SVGElement.attributeStyleMap | ||
--- | ||
|
||
{{APIRef("CSSOM")}} | ||
|
||
The **`attributeStyleMap`** read-only property of the {{domxref("SVGElement")}} interface returns a live {{domxref("StylePropertyMap")}} object that contains a list of style properties of the element that are defined in the element's inline `style` attribute, or assigned using the {{domxref("SVGElement.style", "style")}} property of the {{domxref("SVGElement")}} interface via script. | ||
|
||
Shorthand properties are expanded. If you set `border-top: 1px solid black`, the longhand properties ({{cssxref("border-top-color")}}, {{cssxref("border-top-style")}}, and {{cssxref("border-top-width")}}) are set instead. | ||
|
||
The main difference between {{domxref("SVGElement.style", "style")}} property and `attributeStyleMap` property is that, the `style` property will return a {{domxref("CSSStyleDeclaration")}} object, while the `attributeStyleMap` property will return a {{domxref("StylePropertyMap")}} object. | ||
|
||
Though the property itself is not writable, you could read and write inline styles through the {{domxref("StylePropertyMap")}} object that it returns, just like through the {{domxref("CSSStyleDeclaration")}} object that returns via the `style` property. | ||
|
||
## Value | ||
|
||
A live {{domxref("StylePropertyMap")}} object. | ||
|
||
## Examples | ||
|
||
The following code snippet shows the relationship between the `style` attribute and the `attributeStyleMap` property: | ||
|
||
```html | ||
<div style="white-space: pre-line;"> | ||
<svg | ||
width="50" | ||
height="50" | ||
xmlns="http://www.w3.org/2000/svg" | ||
viewBox="0 0 250 250" | ||
width="250" | ||
height="250" | ||
style="white-space: pre-line;"> | ||
<circle | ||
cx="100" | ||
cy="100" | ||
r="50" | ||
id="el" | ||
style="border-top: 1px solid blue; color: red;" /> | ||
</svg> | ||
<div id="output"></div> | ||
</div> | ||
``` | ||
|
||
```css | ||
#el { | ||
font-size: 16px; | ||
} | ||
``` | ||
|
||
```js | ||
const element = document.getElementById("el"); | ||
const output = document.getElementById("output"); | ||
|
||
for (const property of element.attributeStyleMap) { | ||
output.textContent += `${property[0]} = ${property[1][0].toString()}\n`; | ||
} | ||
``` | ||
|
||
{{EmbedLiveSample("Examples", "200", "200")}} | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} | ||
|
||
## See also | ||
|
||
- {{domxref("SVGElement.style")}} | ||
- {{domxref("HTMLElement.attributeStyleMap")}} | ||
- {{domxref("MathMLElement.attributeStyleMap")}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please dont bother changing to the macro format. MDN does not expect a particular style, so from a reviewer point of view this is noise.