aboutsummaryrefslogtreecommitdiff
path: root/files/pl/orphaned/web
diff options
context:
space:
mode:
authorMDN <actions@users.noreply.github.com>2021-07-04 00:36:02 +0000
committerMDN <actions@users.noreply.github.com>2021-07-04 00:36:02 +0000
commit68b6aba0b2a1f8005e1c181c06e40eea4af9cd2f (patch)
treeed34f01abc54bc6fee17f912a7adf5d193797846 /files/pl/orphaned/web
parent386dea478e66a4d753c9adc9f10ecc132351692d (diff)
downloadtranslated-content-68b6aba0b2a1f8005e1c181c06e40eea4af9cd2f.tar.gz
translated-content-68b6aba0b2a1f8005e1c181c06e40eea4af9cd2f.tar.bz2
translated-content-68b6aba0b2a1f8005e1c181c06e40eea4af9cd2f.zip
[CRON] sync translated content
Diffstat (limited to 'files/pl/orphaned/web')
-rw-r--r--files/pl/orphaned/web/api/htmlorforeignelement/dataset/index.html135
1 files changed, 135 insertions, 0 deletions
diff --git a/files/pl/orphaned/web/api/htmlorforeignelement/dataset/index.html b/files/pl/orphaned/web/api/htmlorforeignelement/dataset/index.html
new file mode 100644
index 0000000000..e85163f19a
--- /dev/null
+++ b/files/pl/orphaned/web/api/htmlorforeignelement/dataset/index.html
@@ -0,0 +1,135 @@
+---
+title: HTMLElement.dataset
+slug: orphaned/Web/API/HTMLOrForeignElement/dataset
+translation_of: Web/API/HTMLOrForeignElement/dataset
+original_slug: Web/API/HTMLOrForeignElement/dataset
+---
+<div>{{ APIRef("HTML DOM") }}</div>
+
+<p><span class="seoSummary">Właściwość <code><strong>dataset</strong></code> interfejsu {{domxref("HTMLElement")}} pozwala na odczyt/zapis <a href="/en/HTML/Global_attributes#attr-data-*" title="https://developer.mozilla.org/en/HTML/Global_attributes#attr-data-*">niestandardowcyh atrybutów</a> (<code>data-*</code>) elementu.</span> Dostęp ten jest możliwy w HTMLu jak i w DOMie.  It is a <a href="/en/DOM/DOMStringMap" title="en/DOM/DOMStringMap">map of DOMString</a>, one entry for each custom data attribute. Zauważ że właściwość<strong> </strong><code>dataset</code><strong> </strong>można odczytać, ale nie zmieniać bezpośrednio. Zamiast tego, wszystkie zapisy muszą być wykonywane na pojedynczych polach <code>dataset</code>, które odpowiadają atrybutom danych. Note also that an HTML <code><strong>data-</strong></code><em>attribute</em> and its corresponding DOM<strong> </strong><code>dataset.</code><em>property</em> do not share the same name, but they are always similar:</p>
+
+<ul>
+ <li>The name of a custom data attribute in HTML begins with <code>data-</code>. It must contain only letters, numbers and the following characters: dash (<code>-</code>), dot (<code>.</code>), colon (<code>:</code>), underscore (<code>_</code>) -- but NOT any ASCII capital letters (<code>A</code> to <code>Z</code>).</li>
+ <li>The name of a custom data attribute in JavaScript is the name of the same HTML attribute but in camelCase and with no dashes, dots, etc.</li>
+</ul>
+
+<p>In addition to the information below, you'll find a how-to guide for using HTML data attributes in our article <a href="/en-US/docs/Learn/HTML/Howto/Use_data_attributes">Using data attributes.</a></p>
+
+<h3 id="Zmiana_nazw">Zmiana nazw</h3>
+
+<p>dash-style to camelCase: A custom data attribute name is transformed to a key for the {{ domxref("DOMStringMap") }} entry with the following rules</p>
+
+<ul>
+ <li>the prefix <code>data-</code> is removed (including the dash);</li>
+ <li>for any dash (<code>U+002D</code>) followed by an<span style="line-height: 1.5;"> ASCII lowercase letter </span><code>a</code><span style="line-height: 1.5;"> to </span><code>z</code><span style="line-height: 1.5;">, the dash is removed and the letter is transformed into its uppercase counterpart;</span></li>
+ <li>other characters (including other dashes) are left unchanged.</li>
+</ul>
+
+<p>camelCase to dash-style: The opposite transformation, that maps a key to an attribute name, uses the following rules:</p>
+
+<ul>
+ <li>Restriction: A dash must not be immediately followed by an ASCII lowercase letter <code>a</code> to <code>z</code> (before the transformation);</li>
+ <li>a prefix <code>data-</code> is added;</li>
+ <li>any ASCII uppercase letter <code>A</code> to <code>Z</code> is transformed into a dash followed by its lowercase counterpart;</li>
+ <li>other characters are left unchanged.</li>
+</ul>
+
+<p>The restriction in the rules above ensures that the two transformations are the inverse one of the other.</p>
+
+<p>For example, the attribute named <code>data-abc-def</code> corresponds to the key <code>abcDef</code>.</p>
+
+<ul>
+</ul>
+
+<h3 id="Dostęp_do_wartości">Dostęp do wartości</h3>
+
+<ul>
+ <li>Attributes can be set and read by using the camelCase name (the key) like an object property of the dataset, as in <em>element.</em>dataset.<em>keyname</em></li>
+ <li>Attributes can also be set and read using the object-properties bracket-syntax, as in <em>element.</em>dataset[<em>keyname</em>]</li>
+ <li>The <a href="/en-US/docs/Web/JavaScript/Reference/Operators/in">in operator</a> can be used to check whether a given atttribute exists.</li>
+</ul>
+
+
+
+<h3 id="Ustawianie_wartości">Ustawianie wartości</h3>
+
+<ul>
+ <li>Podawana podczas ustawiania atrybutu wartość jest zawsze zapisywana jako łańcuch znaków, np. <code>null</code> jest zapisywane jako "null".</li>
+ <li>Usunięcie atrybutu jest możliwe przy pomocy <a href="/en-US/docs/Web/JavaScript/Reference/Operators/delete">operatora delete</a>.</li>
+</ul>
+
+<h2 id="Składnia">Składnia</h2>
+
+<ul>
+ <li><em>string</em> = <em>element</em>.<strong>dataset</strong>.<em>camelCasedName</em>;</li>
+ <li><em>element.</em><strong>dataset</strong>.<em>camelCasedName</em> = <em>string</em>;</li>
+ <br>
+ <li><em>string</em> = <em>element</em>.<strong>dataset</strong>[<em>camelCasedName</em>];</li>
+ <li><em>element</em>.<strong>dataset</strong>[<em>camelCasedName</em>] = <em>string</em>;</li>
+ <br>
+ <li><em>Custom data attributes can also be set directly on HTML elements, but attribute names must use the data- syntax above. </em></li>
+</ul>
+
+<h2 id="Przykłady">Przykłady</h2>
+
+<pre class="brush: html">&lt;div id="user" data-id="1234567890" data-user="johndoe" data-date-of-birth&gt;John Doe&lt;/div&gt;</pre>
+
+<pre class="brush: js">const el = document.querySelector('#user');
+
+// el.id == 'user'
+// el.dataset.id === '1234567890'
+// el.dataset.user === 'johndoe'
+// el.dataset.dateOfBirth === ''
+
+// set the data attribute
+el.dataset.dateOfBirth = '1960-10-03';
+// Result: el.dataset.dateOfBirth === 1960-10-03
+
+delete el.dataset.dateOfBirth;
+// Result: el.dataset.dateOfBirth === undefined
+
+// 'someDataAttr' in el.dataset === false
+el.dataset.someDataAttr = 'mydata';
+// Result: 'someDataAttr' in el.dataset === true
+</pre>
+
+<h2 id="Specyfikacje">Specyfikacje</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specyfikacja</th>
+ <th scope="col">Status</th>
+ <th scope="col">Komentarz</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('HTML WHATWG', "dom.html#dom-dataset", "HTMLElement.dataset")}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td>No change from latest snapshot, {{SpecName('HTML5.1')}}</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('HTML5.1', "dom.html#dom-dataset", "HTMLElement.dataset")}}</td>
+ <td>{{Spec2('HTML5.1')}}</td>
+ <td>Snapshot of {{SpecName('HTML WHATWG')}}, no change from {{SpecName('HTML5 W3C')}}</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('HTML5 W3C', "dom.html#dom-dataset", "HTMLElement.dataset")}}</td>
+ <td>{{Spec2('HTML5 W3C')}}</td>
+ <td>Snapshot of  {{SpecName('HTML WHATWG')}}, initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+
+
+<p>{{Compat("api.HTMLElement.dataset")}}</p>
+
+<h2 id="Zobacz_także">Zobacz także</h2>
+
+<ul>
+ <li>The HTML <code><a href="/en-US/docs/Web/HTML/Global_attributes/data-*"><strong>data-*</strong></a></code> class of global attributes.</li>
+ <li><a href="/en-US/docs/Learn/HTML/Howto/Use_data_attributes">Używanie atrybutów danych</a></li>
+ <li>{{domxref("Element.getAttribute()")}} and {{domxref("Element.setAttribute()")}}</li>
+</ul>