aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/svgelement/index.html
blob: 1ee9eaa4d4fb17916aa076d10ff75eac9fab6f7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
---
title: SVGElement
slug: Web/API/SVGElement
translation_of: Web/API/SVGElement
---
<div>{{APIRef("SVG")}}</div>

<div>所有SVG DOM类的父类.</div>

<div> </div>

<p>{{InheritanceDiagram}}</p>

<h2 id="属性">属性</h2>

<dl>
 <dt>{{domxref("SVGElement.dataset")}}{{readonlyInline}}</dt>
 <dd>A {{domxref("DOMStringMap")}} object which provides a list of key/value pairs of named data attributes which correspond to <a href="/en-US/docs/Web/Guide/HTML/Using_data_attributes">custom data attributes</a> attached to the element. These can also be defined in SVG using attributes of the form {{SVGAttr("data-*")}}, where <code>*</code> is the key name for the pair. This works just like HTML's {{domxref("HTMLElement.dataset")}} property and HTML's {{htmlattrxref("data-*")}} global attribute.</dd>
 <dt>{{domxref("SVGElement.id")}}{{readonlyInline}}</dt>
 <dd>A {{domxref("DOMString")}} representing the value of the {{SVGAttr("id")}} attribute on the given element, or the empty string if <code>id</code> is not present.</dd>
 <dt>{{domxref("SVGElement.xmlbase")}}{{readonlyInline}}</dt>
 <dd>A {{domxref("DOMString")}} corresponding to the {{SVGAttr("xml:base")}} attribute on the given element.</dd>
 <dt>{{domxref("SVGElement.ownerSVGElement")}}{{readonlyInline}}</dt>
 <dd>An {{domxref("SVGSVGElement")}} referring to the nearest ancestor {{SVGElement("svg")}} element. <code>null</code> if the given element is the outermost <code>&lt;svg&gt;</code> element.</dd>
 <dt>{{domxref("SVGElement.viewportElement")}}{{readonlyInline}}</dt>
 <dd>The {{domxref("SVGElement")}}, which established the current viewport. Often, the nearest ancestor {{SVGElement("svg")}} element. <code>null</code> if the given element is the outermost <code>&lt;svg&gt;</code> element.</dd>
</dl>

<h2 id="方法">方法</h2>

<p><em><code>SVGElement</code>类本身没有方法, 但拥有从父类{{domxref("Element")}}继承的方法.</em></p>

<h2 id="规范">规范</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName("SVG2", "types.html#InterfaceSVGElement", "SVGElement")}}</td>
   <td>{{Spec2("SVG2")}}</td>
   <td>Adds the {{domxref("SVGElement.dataset", "dataset")}} property.</td>
  </tr>
  <tr>
   <td>{{SpecName("SVG1.1", "types.html#InterfaceSVGElement", "SVGElement")}}</td>
   <td>{{Spec2("SVG1.1")}}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>

<p>{{ CompatibilityTable }}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Edge</th>
   <th>Firefox (Gecko)</th>
   <th>Microsoft Edge</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari (WebKit)</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatVersionUnknown}}<sup>[1]</sup></td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatIE("9.0")}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
  <tr>
   <td><code>dataset</code> attribute</td>
   <td>{{CompatChrome("54")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoDesktop("51")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatOpera("41")}}</td>
   <td>{{CompatSafari("10.0")}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Android Webview</th>
   <th>Edge</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
   <th>Chrome for Android</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatVersionUnknown}}<sup>[1]</sup></td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}} [1]</td>
  </tr>
  <tr>
   <td><code>dataset</code> attribute</td>
   <td>{{CompatNo}}</td>
   <td>54</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoMobile(51)}}</td>
   <td>{{CompatUnknown}}</td>
   <td>41</td>
   <td>10.0</td>
   <td>54</td>
  </tr>
 </tbody>
</table>
</div>

<p>[1] 属性 <code>offsetParent</code>, <code>offsetTop</code>, <code>offsetLeft</code>, <code>offsetWidth</code>, 和 <code>offsetHeight</code> 从Chrome 48开始被废弃.</p>

<h2 id="相关链接">相关链接</h2>

<ul>
 <li>HTML {{htmlattrxref("data-*")}} 属性</li>
 <li>SVG {{SVGAttr("data-*")}} 属性</li>
 <li><a href="/zh-CN/docs/Web/Guide/HTML/Using_data_attributes">使用数据属性</a></li>
</ul>