44 lines
872 B
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
When using the Backbone.js framework, the internal hash containing the model's state, ``++model.attributes++``, should not be accessed directly. Doing so bypasses the listeners set on the model and could put your application in a bad state.
Instead, you should use ``++set++`` to update, ``++get++`` to read, and ``++_.clone(model.attributes)++`` to obtain a copy.
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,javascript]
2021-04-28 16:49:39 +02:00
----
myModel.attributes.someAttribute = 1;
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,javascript]
2021-04-28 16:49:39 +02:00
----
myModel.set({ someAttribute: 1 });
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Use "(set|get)" instead.
'''
== Comments And Links
(visible only on this page)
=== on 20 May 2015, 12:33:22 Linda Martin wrote:
ok!
endif::env-github,rspecator-view[]