Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.1.0-beta.5] notifyPropertyChange() fails for plain objects #16427

Closed
kanongil opened this issue Mar 27, 2018 · 6 comments
Closed

[3.1.0-beta.5] notifyPropertyChange() fails for plain objects #16427

kanongil opened this issue Mar 27, 2018 · 6 comments
Assignees
Labels
Milestone

Comments

@kanongil
Copy link
Contributor

kanongil commented Mar 27, 2018

This unit test will fail on the latest beta:

test('notifies computed properties on plain objects', function (assert) {
  let obj = {
    a: 45,
    b: computed(function () {
      return ~~(this.a / 10);
    })
  };

  assert.equal(get(obj, 'b'), 4);

  obj.a = 10;
  Ember.notifyPropertyChange(obj, 'b');

  assert.equal(get(obj, 'b'), 1);      // fails - returned value is still 4
});

It works, as intended, if I do the same on an ember object.

@mmun
Copy link
Member

mmun commented Mar 27, 2018

I assume you mean computed('a', function(){ ... })?

@kanongil
Copy link
Contributor Author

No, the code is as intended. Obviously, this is not what failed for me, but a reduced test case to expose the issue.

@mmun
Copy link
Member

mmun commented Mar 27, 2018

This is working as intended then. Since b has no dependency on a, notifying a will not cause b to be invalidated.

Did you mean Ember.notifyPropertyChange(obj, 'b');?

@kanongil
Copy link
Contributor Author

kanongil commented Mar 27, 2018

Ah, so I did make an error. Yes Ember.notifyPropertyChange(obj, 'b'); is the proper failing case.

Sorry about that. I have updated the original post.

@kanongil
Copy link
Contributor Author

A bit of further investigation reveals that this usage is scheduled for deprecation, that it also fails on canary, and that it works correctly if I use Ember.defineProperty(obj, 'b', …) to define the computed value.

@mmun
Copy link
Member

mmun commented Mar 28, 2018

Yeah, but we still need to make it work for backwards compatibility. The fix should be relatively easy but I haven't had time to work on it.

@mmun mmun added the Bug label Mar 28, 2018
@rwjblue rwjblue added this to the v3.1.x milestone Apr 21, 2018
@rwjblue rwjblue self-assigned this Apr 21, 2018
krisselden pushed a commit that referenced this issue May 17, 2018
Ensure all fallback cases are deprecated.

Fixes #16427 and add test for `notifyPropertyChange` not working for plain obj.
krisselden pushed a commit that referenced this issue May 18, 2018
Ensure all fallback cases are deprecated.

Fixes #16427 and add test for `notifyPropertyChange` not working for plain obj.
krisselden pushed a commit that referenced this issue May 18, 2018
Ensure all fallback cases are deprecated.

Fixes #16427 and add test for `notifyPropertyChange` not working for plain obj.
krisselden pushed a commit that referenced this issue May 18, 2018
Test that a CP descriptor still works with notifyPropertyChange
when it is not setup correctly via Ember.defineProperty.
krisselden added a commit that referenced this issue May 18, 2018
Setup a non setup descriptor on access.
krisselden added a commit that referenced this issue May 18, 2018
Setup a non setup descriptor on access.
rwjblue pushed a commit that referenced this issue May 21, 2018
Test that a CP descriptor still works with notifyPropertyChange
when it is not setup correctly via Ember.defineProperty.

(cherry picked from commit c486d7a)
rwjblue pushed a commit that referenced this issue May 21, 2018
Setup a non setup descriptor on access.

(cherry picked from commit 166d395)
lifeart added a commit to lifeart/ember.js that referenced this issue Jul 13, 2018
* Add eslint-plugin-import to validate imports.

This ensures that all imports are resolvable and valid.

Future changes should enable more rules from eslint-plugin-import (such
as ensuring that a given imported module is only specified once or
preventing module cycles).

* Add test for issue emberjs#16427

Test that a CP descriptor still works with notifyPropertyChange
when it is not setup correctly via Ember.defineProperty.

* [BUGFIX release] Fix emberjs#16427

Setup a non setup descriptor on access.

* upgrade broccoli-typescript-compiler

* convert ember-metal/transaction to typescript

* upgrade typescript-eslint-parser

* simplify exported type def

* [DOC release]Change name for Enumerable to comply with RFC 176

* [Feature] added module-unification route and route-test blueprints

* [BUGFIX canary] fix conditional

* Fix module cycle in @ember/engine package.

* Fix module cycle in @ember/application package.

* Fix module cycle in ember-runtime.

* [BUGFIX beta] bump glimmer

* More ts conversion.

* [DOC release] Update class_names_support.js to include binding classes to false properties

* reuse `isObject`

* correct `isProxy` and `setProxy`

* convert more ember-metal files to TS

* convert the rest of ember-metal to TS

* simplify chain logic

* Update the babel-plugin-debug-macros version in use.

* avoid using `isNone` internally

* move default values out of constructor in `ChainNode`

* Update to latest version of babel-plugin-debug-macros.

* Start enabling svelte builds WIP

* Extract shared utility for requiring typescript.

* Use `!!'<version string>` for deprecated feature versions.

This ensures that other typescript files detect the import is (properly)
a boolean.

* Cleanup deprecate feature parsing.

* Wrap `Ember.EXTEND_PROTOTYPES` for svelting.

* Wrap deprecated Ember.deprecate features for svelting.

* Wrap `sync` queue support for svelting.

* cleanup chains

* remove redundant `indexOf/lastIndexOf` from `NativeArray`

* Wrap `resolver` as function deprecation for svelting.

* Wrap Ember.Logger for svelting...

* Wrap positional param conflict support for svelting.

* Wrap `didInitAttrs` legacy support for svelte.

* Wrap propertyWillChange/propertyDidChange for svelting.

* Wrap `router.router` deprecation for svelting.

* Wrap `{{render` orphan `{{outlet}}` support for svelting.

* Wrap ArrayMixin's @each property for svelting.

* Wrap targetObject for svelting...

* Wrap `{{render}}` support for svelting.

* Wrap "fooBinding" support for svelting.

* Ensure @ember/deprecated-features ends up in template compiler build.

* Remove outdated `features.json` file.

* Add EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION feature flag.

* Add basic "failing test" for simple angle bracket invocation.

* Modify component lookup to dasherize (and allow single word).

* Add AST transform to validate `...attributes`.

* Add more tests for angle bracket invocation.

* Ensure `moduleFor` allows for all caps feature names...

* deprecate `NativeArray#copy`

* Fixup tests to pass when feature flag is not runtime enableable.

When testing the alpha builds all features are compiled out, but using
`@feature` in the testing harness still thinks the feature will work :(

* Add ...attributes tests (when using tagless components).

* Wrap `didCreateElement` logic of curly component manager in a guard
(so that we only do things like add classes and whatnot when the
component we created uses a wrapped element.
* Added various tests for tagless components using `...attributes`

* conditionally add bindings related methods to meta

* Deprecate `Ember.Map`

* Deprecate `Ember.MapWithDefault`

* Deprecate `Ember.OrderedSet`

* Deprecate accessing jQuery.Event#originalEvent

Implements the deprecation message for user-land code accessing `originalEvent` on `jQuery.Event` instances, as proposed by RFC#294 (https://github.com/emberjs/rfcs/blob/master/text/0294-optional-jquery.md#introducing-ember-jquery-legacy-and-deprecating-jqueryevent-usage)

* Implemented copy/Copyable deprecation

* Cleaned up a couple of "pretty" issues the Travis build found.

* Ensure that if jQuery is explicitly disabled, Ember.$ is undefined, even if jquery is on the page.

* bump glimmer to 0.34.6

* convert ember-template-compiler to typescript

* Deprecate originalEvent only when jQuery is not explicitly enabled.

* Add URL to jQuery.Event deprecation

* remove redundant backtick in comment

* avoid boolean coercion in `meta`

* Update glimmer-vm to 0.34.8.

Main changes:

* No longer calls `didCreateElement` on the component manager for
  `...attributes`.
* Add support for `has-block` to be false with angle bracket invocation.
* Update glimmer-vm's own typescript config to be as strict as Embers.
* Update simple-html-tokenizer to allow an `@` in the tag name.
* Fix a number of issues with SSR related functionality.

* Update for glimmer-vm changes.

* Enable previously skipped `has-block` test
* Remove guard from `CurlyComponentManager#didCreateElement` (it is no
  longer called for each `...attributes` invocation).

* pass meta to `defineProperty`

* Bump glimmer-vm packages to 0.35.0.

* Account for breaking changes in glimmer-vm 0.35.0.

`Builder.prototype.dynamicComponent` added an additional argument
(`attr`) to support `...attributes` in dynamically angle bracket
invocations.

* Add tests for dynamic angle bracket invocation.

* Add 3.2.0 to CHANGELOG.

(cherry picked from commit d3d1f78)

* Add v3.3.0-beta.1 to CHANGELOG.md.

* Post release version bump.

* [FEATURE EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION] Enable by default.

* [BUGFIX beta] avoid ordered set deprecation

* cleanup `toBool`

* [BUGFIX canary] Use customized dasherization for angle bracket invocations.

The [Angle Bracket Invocation
RFC](https://github.com/emberjs/rfcs/blob/master/text/0311-angle-bracket-invocation.md#tag-name)
specifically states:

> The tag name will be normalized using the dasherize function, which is
> the same rules used by existing use cases, such as service injections.
> This allows existing components to be invoked by the new syntax.

Unfortunately, using `Ember.String.dasherize` has (IMHO) fatal
consequences for angle bracket invocation.  Specifically, for an angle
bracket invocation as `<XFoo />` using `Ember.String.dasherize` we would
look up `xfoo` which IMHO is fundamentally flawed...

Changing `Ember.String.dasherize` has very wide spread impact, and is
likely to break existing apps in subtle ways. This implements a much
simpler dasherization system used exclusively for component lookup (with
its own independent cache).

* small cleanup mixins/array

* use `tryInvoke` in `ArrayMixin.invoke`

* [BUGFIX beta] Update glimmer-vm to 0.35.3.

* Cleanup template string indentation in angle bracket invocation tests.

* Add test ensuring implicit `this` paths are not allowed in angle invocations.

* remove redundant argument `reducerProperty`

* [Feature] Adds mixin blueprint for module unification

* bump backburner

* using Set for storing application instances

* Fixup edgecases for angle bracket component dasherization.

Also add a small test harness for the various edge cases that the
custom component name dasherization function needs to handle.

* cleanup `_getPath`

* added tests for `get` with paths

* [Feature] Update initializer blueprint for module unification

* [BUGFIX beta] Better error when a route name is not valid

Improves the error message shown when trying to define
a route with a ':' in the name.

Fixes emberjs#16642

* use `applyMixin` directly instead of using it through `Mixin`

* avoid boolean coercion in `property_set`

* Correct redirection to route api to routing guide

* update guides link

* [DOC release] Fix broken links to guides

* [BUGFIX beta] Throw error if run.bind receives no method

This commit uses the same logic as backburner.join to know
which method is being bound.

Fixes emberjs#16652

* make setup/teardown noop functions in descriptor

* Add v3.3.0-beta.2 to CHANGELOG
[ci skip]

(cherry picked from commit 2e2528a)

* [BUGFIX beta] Update glimmer-vm to 0.35.4.

Fixes issue with parsing a self closing element with no space between
unquoted attribute and self close.

```hbs
<FooBar data-foo={{someValue}}/>
```

* Wrap Ember.Map / Ember.OrderedSet / Ember.MapWithDefault for svelting.

* [BUGFIX] bring back isObject guard for ember-utils/is_proxy

`WeakSet.has` throws `TypeError` if argument is not an object:
https://www.ecma-international.org/ecma-262/6.0/#sec-weakset.prototype.has

While recent Chrome versions just returns `false`.

* Fix container destroy timing

* Ensure tests are run against Chrome 41

Chrome 41 (as far as I can tell) is the version of Chrome that googlebot
uses.  It is exceedingly difficult to track down issues related to
Googlebot bugs in Ember.js presently.

This ensures our tests run against the last known version of Googlebot's
browser

* Fix code style

* [BUGFIX beta] Allow Route#modelFor to work without routerMicrolib

* Test value parameter does not have to be a String

* Make CoreObject rely more on ES2015 class features and interop better.

* cleanup

* Update Custom Components feature to match final RFC.

* Removes view heirarchy updating (not included in RFC)
* Updates custom manager hook method names to match final RFC
* Add `capabilities` system (still very basic)
* Disentangle curly component manager from custom component manager.
* Add optional capabilities (`destructor` / `asyncLifecycleCallbacks`)
* Add temporary global (private on the global, public via modules API)
  for `capabilities`
* Migrate `setComponentManager` to use `WeakMap`'s instead of mutation

* Add v3.3.0-beta.3 to CHANGELOG
[ci skip]

(cherry picked from commit 60b68a3)

* [DEPRECATION] Deprecate `Component#sendAction` (RFC emberjs#335)

This also implicitly deprecated passing actions to the built-in inputs like `{{input enter="foo"}},
instead users must do `{{input enter=(action "foo")}}`.
There is a build-time deprecation that uses AST visitors to output precise information of file
and line the offending code is.
There is also a runtime-deprecation for cases that the AST deprecation can't catch.

* Add v3.2.1 to CHANGELOG
[ci skip]

(cherry picked from commit d8c83ff)

* CHANGELOG entries for `{{#each}}` & `{{#each-in}}`

* trying a workaround to FireFox

* [BUGFIX release] Refactor owner/container destroy.

Ensure `.destroy()` is called on all items in the container, _before_
marking `container.isDestroyed`. Only flush the caches after destroy is
finalized.

* Initialize meta with the right meta.proto based on the object passed in.

* Remove unused export.

* remove unused code

* add interop testing for compatibility

make meta.parent lazier

* Fix tests

* [DOC release] Restore documentation for component helper

* Update api url

* Add v3.2.2 to CHANGELOG
[ci skip]

(cherry picked from commit e0f32cc)

* Ensure meta._parent is initialized

* document Route `fullRouteName` property

I found this property when investigating a bug in ember-interactivity: elwayman02/ember-interactivity#52

* fixup: prettier

* Make EmberObject and Namespace use extends

* [FEATURE glimmer-custom-component-manager] Enable by default.

Discussed in todays core team meeting: 👍

* Remove unneeded things that create many mixins and merges.

* [perf] Only apply PrototypeMixin if it exists

Currently we are always applying the PrototypeMixin in `proto`, even if
it doesn't yet exist (as in the case of native classes). By checking to
see if it exists first, we should be able to avoid creating and applying
it unless it is necessary.

* also skip create on initial reopen

* Add v3.1.3 to CHANGELOG
[ci skip]

(cherry picked from commit 175fb43)

* Add v3.3.0-beta.4 to CHANGELOG
[ci skip]

(cherry picked from commit 4f54358)

* Convert ObjectProxy and ArrayProxy

* build release branches

* cleanup `forEachInDeps`

* extract and rename common methods

* [BUGFIX beta] Ensure tests from @ember/* are excluded from debug/prod builds.

* [BUGFIX] Allow setting length on ArrayProxy.

* Add failing tests for `A().invoke()` not returning an `A`.

* [BUGFIX] Ensure `ArrayMixin#invoke` returns an Ember.A.

This is a partial revert of bee179d, moving back to a manual `forEach`
so that we can control the return value a bit more. When prototype
extensions are disabled, we cannot rely on `this.map` to return an
extended array.

* [BUGFIX] Setting ArrayProxy#content in willDestroy resets length.

Prior to this change, `ArrayProxy.prototype.length` was marked as dirty
(and therefore recomputed) when `content` was set due to
`arrangedContent` being an alias of `content`, and `ArrayProxy`
implementing `PROPERTY_DID_CHANGE` to trap `arrangedContent` changes.

Unfortunately, `notifyPropertyChange` avoids notifying _some_ things
when the object is destroying. This results in the preexisting
`PROPERTY_DID_CHANGE` trap for `arrangedContent` is no longer called,
and therefore `length` is never marked as dirty.

This fixes the condition, by implementing a `content` trap in
`PROPERTY_DID_CHANGE` that marks length as dirty. The next time that
`length` is accessed it will do the normal work to recalculate.

* [BUGFIX] remove checks on init since ember-cli resolver sets namespace
after init.

* Add v3.3.0-beta.5 to CHANGELOG
[ci skip]

(cherry picked from commit 22811d6)

* (issue 16790) Added @static tag so that we can see defineProperty in the API doc

* [BUGFIX] Fix instance-initializer-test blueprint for RFC232

* cleanup `_lookupPartial`

* [CLEANUP] Convert dasherize test over to new style

* Rename `unknown` to `unusable`.

* [CLEANUP] Move off of QUnit.config.current

Moving off of QUnit.config.current in array helpers. Apart of emberjs#15988

* remove double ending line

* [BUGFIX] Centralize build versioning info

Make BUILD_TYPE only affect published buildType if on master so we don't
accidentally publish from lts/release branches over the current beta or
release.

Only use a tag as version if it is parseable by semver.

The build-for-publishing script uses git info instead of travis env.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants