ExportXMLWordPrintable

    • Type: Incident report
    • Resolution: Unresolved
    • Priority: Trivial
    • None
    • Affects Version/s: 7.4.13
    • Component/s: Documentation (D)
    • None

      This commit (in 7.4.13rc1) “added freezing of all default prototypes to JS initialization”.

      The Upgrade notes for 7.4.13 say “built-in object methods are now read-only”.
      I believe it should actually say “built-in objects are now read-only”.
      At least, that was my experience. I had the following in a pre-processing script:

      
      
      data = JSON.parse(value);
      
      // Polyfill for padEnd
      if (!String.prototype.padEnd) {
        String.prototype.padEnd = function (targetLength, padString) {
          padString = padString || ' ';
          var str = String(this);
          while (str.length < targetLength) {
            str += padString;
          }
          return str;
        };
      }
      
      ...

      and after the upgrade, it started failing:

      TypeError: undefined not callable (property 'padEnd' of 'host_name')
      at [anon] (duktape.c:69017) internal
      at [anon] (function:27) preventsyield

      So I was unable to extend the String.prototype object - ie String.prototype became read-only.
      Converting the polyfill to a standalone function resolved issue.

            Assignee:
            Maciej Czernielewski
            Reporter:
            Wojciech Rawicki
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: