bigskysoftware / htmx-extensions

167 stars 51 forks source link

Update deprecated `String.prototype.substr` uses in response-targets.js #100

Closed BlueLovin closed 1 month ago

BlueLovin commented 1 month ago

Hey there, I love this extension. I saw that this script was using the deprecated substr string method. In this particular case, it was super easy to swap out, since the "start index" of the calls are all zero.

All tests passing.

Here is some info on the deprecation of substr() from the MDN Web Docs:

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

Note: substr() is not part of the main ECMAScript specification — it's defined in Annex B: Additional ECMAScript Features for Web Browsers , which is normative optional for non-browser runtimes. Therefore, people are advised to use the standard String.prototype.substring() and String.prototype.slice() methods instead to make their code maximally cross-platform friendly. The String.prototype.substring() page has some comparisons between the three methods.

netlify[bot] commented 1 month ago

Deploy Preview for htmx-extensions canceled.

Name Link
Latest commit b9546bf88af1fdcacf99d831f31edbc301a7fa34
Latest deploy log https://app.netlify.com/sites/htmx-extensions/deploys/66fd3bd8d52e89000898ac46