foundryvtt / foundryvtt

Public issue tracking and documentation for Foundry Virtual Tabletop - software connecting RPG gamers in a shared multiplayer environment with an intuitive interface and powerful API.
https://foundryvtt.com/
192 stars 10 forks source link

Improve handling of explicit null in hasProperty and getProperty helpers. #10780

Closed In3luki closed 2 weeks ago

In3luki commented 2 weeks ago

What happened?

This is a regression from v11.

What ways of accessing Foundry can you encounter this issue in?

Reproduction Steps

const object = {
  property: {
    inner: "value",
  }
}

const object2 = {
  property: null,
}

// v11
console.log(foundry.utils.getProperty(object, "property.inner")); // value
console.log(foundry.utils.getProperty(object2, "property.inner")); // undefined

// v12
console.log(foundry.utils.getProperty(object, "property.inner")); // value
console.log(foundry.utils.getProperty(object2, "property.inner")); // TypeError: Cannot use 'in' operator to search for 'inner' in null

What core version are you reporting this for?

Version 12 Build 320

Relevant log output

No response

Bug Checklist

In3luki commented 2 weeks ago

Apparently foundry.utils.hasProperty has the same problem.

In3luki commented 2 weeks ago

Related to #7813