Skip to content
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

Deprecated dataset methods #1

Merged
merged 1 commit into from
Sep 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions closure/goog/dom/dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ goog.dom.dataset.isValidProperty_ = function(key) {
/**
* Sets a custom data attribute on an element. The key should be
* in camelCase format (e.g "keyName" for the "data-key-name" attribute).
*
* @deprecated use <code>element.dataset.yourKeyHere = yourValue</code> instead
*
* @param {Element} element DOM node to set the custom data attribute on.
* @param {string} key Key for the custom data attribute.
* @param {string} value Value for the custom data attribute.
Expand All @@ -89,6 +92,9 @@ goog.dom.dataset.set = function(element, key, value) {
/**
* Gets a custom data attribute from an element. The key should be
* in camelCase format (e.g "keyName" for the "data-key-name" attribute).
*
* @deprecated use <code>element.dataset.yourKeyHere<code> directly
*
* @param {Element} element DOM node to get the custom data attribute from.
* @param {string} key Key for the custom data attribute.
* @return {?string} The attribute value, if it exists.
Expand Down Expand Up @@ -118,7 +124,10 @@ goog.dom.dataset.get = function(element, key) {

/**
* Removes a custom data attribute from an element. The key should be
* in camelCase format (e.g "keyName" for the "data-key-name" attribute).
* in camelCase format (e.g "keyName" for the "data-key-name" attribute).
*
* @deprecated use <code>delete element.dataset.yourKeyHere</code> instead
*
* @param {Element} element DOM node to get the custom data attribute from.
* @param {string} key Key for the custom data attribute.
*/
Expand Down Expand Up @@ -146,6 +155,8 @@ goog.dom.dataset.remove = function(element, key) {
* Checks whether custom data attribute exists on an element. The key should be
* in camelCase format (e.g "keyName" for the "data-key-name" attribute).
*
* @deprecated check for the existance of <code>element.dataset.yourKey</code> instead
*
* @param {Element} element DOM node to get the custom data attribute from.
* @param {string} key Key for the custom data attribute.
* @return {boolean} Whether the attribute exists.
Expand Down Expand Up @@ -174,8 +185,11 @@ goog.dom.dataset.has = function(element, key) {
* camel cased (e.g., data-foo-bar -> dataset['fooBar']). This operation is not
* safe for attributes having camel-cased names clashing with already existing
* properties (e.g., data-to-string -> dataset['toString']).
*
* @deprecated use <code>element.dataset</code> instead, which returns a <code>DOMStringMap</code>
*
* @param {!Element} element DOM node to get the data attributes from.
* @return {!Object} The string map containing data attributes and their
* @return {!Object<string, string?>} The string map containing data attributes and their
* respective values.
*/
goog.dom.dataset.getAll = function(element) {
Expand Down