GithubHelp home page GithubHelp logo

Comments (8)

ljharb avatar ljharb commented on June 17, 2024 3

This has already been decided. trimLeft and trimRight are in Annex B for legacy reasons, and trimStart and trimEnd are the proper names. The same logic applied to padStart and padEnd.

The start of the string is index 0, and the end is index length - 1. "Left" and "right" are problematic because they refer to display, and JS-the-language does not concern itself with display - for example, Unicode Byte Order Markers are not treated specially.

from proposal-string-left-right-trim.

hax avatar hax commented on June 17, 2024 1

@ljharb I just realize that my problem is I never know trimLeft/trimRight already implemented in all browsers. My fault, thank you.

from proposal-string-left-right-trim.

hax avatar hax commented on June 17, 2024

I'm curious that why padLeft/padRight/contains not in Annex B if 'trimLeft/trimRight` will.

from proposal-string-left-right-trim.

ljharb avatar ljharb commented on June 17, 2024

@hax there is no padLeft, or padRight, or contains - those things simply don't exist and never have (although they all almost did). There is padStart, padEnd, and includes.

from proposal-string-left-right-trim.

hax avatar hax commented on June 17, 2024

@ljharb I remember padLeft/padRight/contains are names in the old draft and many polyfill old versions use these names. Maybe padLeft/padRight never exist in engines, but at least contains existed in FF 17~39, Chrome 30~39 (under flag), Node 0.12.x (with --harmony), and I happened meet a bug in a Node.js project related to it.

from proposal-string-left-right-trim.

ljharb avatar ljharb commented on June 17, 2024

Annex B is only for legacy compat; something that never existed without a flag never needs to exist without one.

People using polyfills of nonstandard features are taking a risk, and they need to be responsible to update them when the standard changes - otherwise they're just mutating builtins, which is a horrific practice for the web.

from proposal-string-left-right-trim.

hax avatar hax commented on June 17, 2024

@ljharb But string.prototype.contains existed in FF 17~39 without flag.

from proposal-string-left-right-trim.

ljharb avatar ljharb commented on June 17, 2024

Sure. But to be a web compat issue, it had to exist in the majority of browsers at least. Existing in only one browser doesn't matter at all, as any code that relied on it was already broken for the rest.

from proposal-string-left-right-trim.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.