Actually use diffTracker values for display to the user.#3375
Actually use diffTracker values for display to the user.#3375rtibbles merged 1 commit intolearningequality:unstablefrom
Conversation
| let results = uniq(this.nodes.map(node => node[key] || null)); | ||
| const results = uniq( | ||
| this.nodes.map(node => { | ||
| if (Object.prototype.hasOwnProperty.call(this.diffTracker[node.id] || {}, key)) { |
There was a problem hiding this comment.
Out of curiosity, why use Object.prototype.hasOwnProperty.call()? Does this have to do the this.diffTracker[node.id] object having to use call from the prototype?
There was a problem hiding this comment.
hasOwnProperty is the best method for determining if a Javascript object actually has a property in itself (and it's not inherited from a parent type) - so it's the best way of telling if we have actually assigned e.g. this.diffTracker[node.id] = {}.
In theory you could call it like this: this.diffTracker.hasOwnProperty(node.id) because it is just a method of any Object that inherits from or is instantiated from the Object constructor. The reason for using the Object.prototype.hasOwnProperty.call is to ensure that the method has not been maliciously overwritten on the object itself - we have a linting rule https://eslint.org/docs/rules/no-prototype-builtins that guards against this - by calling it directly from the Object prototype we guard against it having been overwritten from JSON data or somesuch. It is probably not a real concern in this instance, but simpler to obey the linting rule.
sairina
left a comment
There was a problem hiding this comment.
Manual testing works for the accessibility checkboxes!
Summary
Description of the change(s) you made
Manual verification steps performed