Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-40021

Behavior of deleting object properties in a loop differs from browser JavaScript runtimes

    XMLWordPrintable

Details

    Description

      Run this snippet in qmlscene:

      import QtQuick 2.0
      
      Item {
        Component.onCompleted: {
          var obj = {foo: 1, bar: 2, asdf: 3, blub: 4};
          console.log("before: ", JSON.stringify(obj));
          for (var prop in obj) {
            delete obj[prop];
          }
          console.log("after: ", JSON.stringify(obj));
        }
      }
      

      expected output:
      qml: before:

      {"asdf":3,"bar":2,"blub":4,"foo":1}

      qml: after: {}

      actual output:
      qml: before:

      {"asdf":3,"bar":2,"blub":4,"foo":1}

      qml: after:

      {"bar":2,"foo":1}

      When you run the snippet above (i.e. the contents of Component.onCompleted) in a browser environment (WebKit, Chromium, ...), the expected output will be shown.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            shausman Simon Hausmann
            milianw Milian Wolff
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes