Skip to content

Commit

Permalink
Some more deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
DreierF committed Apr 13, 2020
1 parent de475f4 commit 9528b73
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions closure/goog/array/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ goog.array.count = function(arr, f, opt_obj) {
* @return {T|null} The first array element that passes the test, or null if no
* element is found.
* @template T,S
* @deprecated Use arr.find(f) instead
*/
goog.array.find = function(arr, f, opt_obj) {
var i = goog.array.findIndex(arr, f, opt_obj);
Expand All @@ -385,6 +386,7 @@ goog.array.find = function(arr, f, opt_obj) {
* @return {number} The index of the first array element that passes the test,
* or -1 if no element is found.
* @template T,S
* @deprecated Use arr.findIndex(f) instead
*/
goog.array.findIndex = function(arr, f, opt_obj) {
var l = arr.length; // must be fixed during loop... see docs
Expand Down Expand Up @@ -450,6 +452,7 @@ goog.array.findIndexRight = function(arr, f, opt_obj) {
* element.
* @param {*} obj The object for which to test.
* @return {boolean} true if obj is present.
* @deprecated Use arr.includes(obj) instead
*/
goog.array.contains = function(arr, obj) {
return goog.array.indexOf(arr, obj) >= 0;
Expand Down Expand Up @@ -993,6 +996,7 @@ goog.array.binarySearch_ = function(
* negative number, zero, or a positive number depending on whether the
* first argument is less than, equal to, or greater than the second.
* @template T
* @deprecated Use arr.sort(opt_compareFn) instead
*/
goog.array.sort = function(arr, opt_compareFn) {
// TODO(arv): Update type annotation since null is not accepted.
Expand Down
8 changes: 8 additions & 0 deletions closure/goog/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,14 @@ goog.isNull = function(val) {
* Returns true if the specified value is defined and not null.
* @param {?} val Variable to test.
* @return {boolean} Whether variable is defined and not null.
* @deprecated Try to avoid having a variable use null and
* undefined at the same time by:
* - Using default parameter values
* - Nullish coalescing operator
* - Optional chaining
*
* If none of the above is appicable use `!= null` to check for
* null and undefined
*/
goog.isDefAndNotNull = function(val) {
// Note that undefined == null.
Expand Down
3 changes: 3 additions & 0 deletions closure/goog/dom/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ goog.dom.getElementByTagNameAndClass = function(opt_tag, opt_class, opt_el) {
* @param {string} className the name of the class to look for.
* @param {(Document|Element)=} opt_el Optional element to look in.
* @return {!IArrayLike<!Element>} The items found with the class name provided.
* @deprecated Use document.querySelectorAll('.classname') or element.querySelectorAll('.classname') instead
*/
goog.dom.getElementsByClass = function(className, opt_el) {
var parent = opt_el || document;
Expand All @@ -267,6 +268,7 @@ goog.dom.getElementsByClass = function(className, opt_el) {
* @param {string} className the name of the class to look for.
* @param {Element|Document=} opt_el Optional element to look in.
* @return {Element} The first item with the class name provided.
* @deprecated Use document.querySelector('.classname') or element.querySelector('.classname') instead
*/
goog.dom.getElementByClass = function(className, opt_el) {
var parent = opt_el || document;
Expand Down Expand Up @@ -1270,6 +1272,7 @@ goog.dom.insertChildAt = function(parent, child, index) {
* Removes a node from its parent.
* @param {Node} node The node to remove.
* @return {Node} The node removed if removed; else, null.
* @deprecated Use node.parentNode?.removeChild(node) instead
*/
goog.dom.removeNode = function(node) {
return node && node.parentNode ? node.parentNode.removeChild(node) : null;
Expand Down

0 comments on commit 9528b73

Please sign in to comment.