diff options
author | MDN <actions@users.noreply.github.com> | 2021-06-23 00:34:06 +0000 |
---|---|---|
committer | MDN <actions@users.noreply.github.com> | 2021-06-23 00:34:06 +0000 |
commit | 52ccdf1f0a1cee3f0659ac78e81c79dae152399b (patch) | |
tree | b17424899ff0c32cee6820a6921edd9999da6ea1 /files/zh-cn/web/api | |
parent | d62c8afe56395e9e793dab0f629b2a1694449c82 (diff) | |
download | translated-content-52ccdf1f0a1cee3f0659ac78e81c79dae152399b.tar.gz translated-content-52ccdf1f0a1cee3f0659ac78e81c79dae152399b.tar.bz2 translated-content-52ccdf1f0a1cee3f0659ac78e81c79dae152399b.zip |
[CRON] sync translated content
Diffstat (limited to 'files/zh-cn/web/api')
-rw-r--r-- | files/zh-cn/web/api/node/getuserdata/index.html | 96 | ||||
-rw-r--r-- | files/zh-cn/web/api/node/setuserdata/index.html | 103 |
2 files changed, 0 insertions, 199 deletions
diff --git a/files/zh-cn/web/api/node/getuserdata/index.html b/files/zh-cn/web/api/node/getuserdata/index.html deleted file mode 100644 index cc81f8c288..0000000000 --- a/files/zh-cn/web/api/node/getuserdata/index.html +++ /dev/null @@ -1,96 +0,0 @@ ---- -title: Node.getUserData() -slug: Web/API/Node/getUserData -translation_of: Web/API/Node/getUserData ---- -<p>{{ APIRef }}{{ obsolete_header() }}</p> -<p>The <code><strong>Node.getUserData()</strong></code> method returns any user {{domxref("DOMUserData")}} set previously on the given node by {{domxref("Node.setUserData()")}}.</p> -<div class="note"> - <p>The <code>Node.setUserData</code> and {{domxref("Node.getUserData")}} methods are no longer available from Web content. {{domxref("Element.dataset")}} or <a href="/en-US/docs/JavaScript/Reference/Global_Objects/WeakMap"><code>WeakMap</code></a> can be used instead.</p> -</div> -<h2 id="Syntax">Syntax</h2> -<pre class="syntaxbox"><em>userData</em> = <em>someNode</em>.getUserData(<em>userKey</em>);</pre> -<h3 id="Parameters">Parameters</h3> -<ul> - <li><code>userKey</code> is the key to choose the specific data sought for the given node. More than one key may have been assigned on a given node, containing its own value.</li> -</ul> -<h2 id="Example">Example</h2> -<pre class="brush: js">var d = document.setUserData('key', 15, null); -alert(document.getUserData('key')); // 15</pre> -<h2 id="Specifications">Specifications</h2> -<table class="standard-table"> - <thead> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName('DOM WHATWG', '#interface-node', 'Node')}}</td> - <td>{{Spec2('DOM WHATWG')}}</td> - <td>Removed from the specification.</td> - </tr> - <tr> - <td>{{SpecName('DOM3 Core', 'core.html#Node3-getUserData', 'Node.getUserData()')}}</td> - <td>{{Spec2('DOM3 Core')}}</td> - <td>Initial definition.</td> - </tr> - </tbody> -</table> -<h2 id="Browser_compatibility">Browser compatibility</h2> -<p>{{CompatibilityTable}}</p> -<div id="compat-desktop"> - <table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>Supported from {{CompatGeckoDesktop("1.0")}} to {{CompatGeckoDesktop("21.0")}}.<br> - Removed in {{CompatGeckoDesktop("22.0")}} [1]</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> - </table> -</div> -<div id="compat-mobile"> - <table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>Supported from {{CompatGeckoMobile("1.0")}} to {{CompatGeckoMobile("21.0")}}.<br> - Removed in {{CompatGeckoMobile("22.0")}} [1]</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> - </table> -</div> -<p>[1] The method is still available from chrome scripts.</p> -<h2 id="See_also">See also</h2> -<ul> - <li>{{domxref("Node.setUserData()")}}</li> - <li>{{domxref("UserDataHandler")}}</li> - <li>{{domxref("DOMUserData")}}</li> -</ul> diff --git a/files/zh-cn/web/api/node/setuserdata/index.html b/files/zh-cn/web/api/node/setuserdata/index.html deleted file mode 100644 index 2729b79c50..0000000000 --- a/files/zh-cn/web/api/node/setuserdata/index.html +++ /dev/null @@ -1,103 +0,0 @@ ---- -title: Node.setUserData() -slug: Web/API/Node/setUserData -translation_of: Web/API/Node/setUserData ---- -<p>{{ APIRef }}{{ obsolete_header() }}</p> -<p>The <code><strong>Node.setUserData()</strong></code> method allows a user to attach (or remove) data to an element, without needing to modify the DOM. Note that such data will not be preserved when imported via {{domxref("Node.importNode")}}, as with {{domxref("Node.cloneNode()")}} and {{domxref("Node.renameNode()")}} operations (though {{domxref("Node.adoptNode")}} does preserve the information), and equality tests in {{domxref("Node.isEqualNode()")}} do not consider user data in making the assessment.</p> -<p>This method offers the convenience of associating data with specific nodes without needing to alter the structure of a document and in a standard fashion, but it also means that extra steps may need to be taken if one wishes to serialize the information or include the information upon clone, import, or rename operations.</p> -<div class="note"> - <p>The <code>Node.getUserData</code> and {{domxref("Node.setUserData")}} methods are no longer available from Web content. {{domxref("Element.dataset")}} or <a href="/en-US/docs/JavaScript/Reference/Global_Objects/WeakMap"><code>WeakMap</code></a> can be used instead.</p> -</div> -<h2 id="Syntax">Syntax</h2> -<pre class="syntaxbox"><em>prevUserData = someNode</em>.setUserData(<em>userKey</em>, <em>userData</em>, <em>handler</em>);</pre> -<h3 id="Parameters">Parameters</h3> -<ul> - <li><code>userKey</code> is used as the key by which one may subsequently obtain the stored data. More than one key can be set for a given node.</li> - <li><code>handler</code> is a callback which will be called any time the node is being cloned, imported, renamed, as well as if deleted or adopted; a function can be used or an object implementing the <code>handle</code> method (part of the {{domxref("UserDataHandler")}} interface). The handler will be passed five arguments: an operation type integer (e.g., 1 to indicate a clone operation), the user key, the data on the node, the source node (<code>null</code> if being deleted), the destination node (the newly created node or <code>null</code> if none).If no handler is desired, one must specify <code>null</code>.</li> - <li><code>userData</code> is the object to associate to <code>userKey</code> on someNode. If <code>null</code>, any previously registered object and UserDataHandler associated to <code>userKey</code> on this node will be removed.</li> -</ul> -<h2 id="Example">Example</h2> -<pre class="brush: js">var d = document.implementation.createDocument('', 'test', null); -d.documentElement.setUserData('key', 15, {handle:function (o, k, d, s, ds) {alert(o+'::'+k+'::'+d+'::'+s+'::'+ds)}}); // 2::key::15::[object Element]::[object Element] -alert(d.documentElement.getUserData('key')); // 15 -var e = document.importNode(d.documentElement, true); // causes handler to be called -alert(e.getUserData('key')); // null since user data is not copied -</pre> -<h2 id="Specifications">Specifications</h2> -<table class="standard-table"> - <thead> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName('DOM WHATWG', '#interface-node', 'Node')}}</td> - <td>{{Spec2('DOM WHATWG')}}</td> - <td>Removed from the specification.</td> - </tr> - <tr> - <td>{{SpecName('DOM3 Core', 'core.html#Node3-setUserData', 'Node.setUserData()')}}</td> - <td>{{Spec2('DOM3 Core')}}</td> - <td>Initial definition.</td> - </tr> - </tbody> -</table> -<h2 id="Browser_compatibility">Browser compatibility</h2> -<p>{{CompatibilityTable}}</p> -<div id="compat-desktop"> - <table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>Supported from {{CompatGeckoDesktop("1.0")}} to {{CompatGeckoDesktop("21.0")}}.<br> - Removed in {{CompatGeckoDesktop("22.0")}} [1]</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> - </table> -</div> -<div id="compat-mobile"> - <table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>Supported from {{CompatGeckoMobile("1.0")}} to {{CompatGeckoMobile("21.0")}}.<br> - Removed in {{CompatGeckoMobile("22.0")}} [1]</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> - </table> -</div> -<p>[1] The method is still available from chrome scripts.</p> -<h2 id="See_also">See also</h2> -<ul> - <li>{{domxref("Node.getUserData()")}}</li> - <li>{{domxref("UserDataHandler")}}</li> - <li>{{domxref("DOMUserData")}}</li> -</ul> |