language
stringclasses 1
value | owner
stringlengths 2
15
| repo
stringlengths 2
21
| sha
stringlengths 45
45
| message
stringlengths 7
36.3k
| path
stringlengths 1
199
| patch
stringlengths 15
102k
| is_multipart
bool 2
classes |
---|---|---|---|---|---|---|---|
Other
|
emberjs
|
ember.js
|
1de74dc28634cbfc14bab974d14db37ba0aab67e.json
|
Add v3.3.0-beta.2 to CHANGELOG
[ci skip]
(cherry picked from commit 2e2528a973901bb6999c013ae257358104bca4da)
|
CHANGELOG.md
|
@@ -1,5 +1,11 @@
# Ember Changelog
+### v3.3.0-beta.2 (June 11, 2018)
+- [#16709](https://github.com/emberjs/ember.js/pull/16709) [BUGFIX] Avoid ordered set deprecation in @ember/ordered-set addon
+- [#16715](https://github.com/emberjs/ember.js/pull/16715) [BUGFIX] Update glimmer-vm to 0.35.3
+- [#16729](https://github.com/emberjs/ember.js/pull/16729) [BUGFIX] Throw error if run.bind receives no method
+- [#16731](https://github.com/emberjs/ember.js/pull/16731) [BUGFIX] Better error when a route name is not valid
+
### v3.3.0-beta.1 (May 31, 2018)
- [#16687](https://github.com/emberjs/ember.js/pull/16687) [FEATURE] Implement optional jQuery integration (see [emberjs/rfcs#294](https://github.com/emberjs/rfcs/blob/master/text/0294-optional-jquery.md) for more details).
| false |
Other
|
emberjs
|
ember.js
|
33001ed3e60f4b2a9ee57e5f727ba951435cd34d.json
|
Correct redirection to route api to routing guide
|
packages/ember-routing/lib/system/route.js
|
@@ -49,7 +49,7 @@ export function hasDefaultSerialize(route) {
/**
The `Route` class is used to define individual routes. Refer to
- the [routing guide](https://emberjs.com/guides/routing/) for documentation.
+ the [routing guide](https://guides.emberjs.com/release/routing/) for documentation.
@class Route
@extends EmberObject
| false |
Other
|
emberjs
|
ember.js
|
f3eec4490ea0ec88ed71da42af5784c19f067720.json
|
avoid boolean coercion in `property_set`
|
packages/ember-metal/lib/property_set.ts
|
@@ -171,22 +171,19 @@ if (DEBUG) {
};
}
-function setPath(root: object, path: string, value: any, tolerant?: boolean) {
+function setPath(root: object, path: string, value: any, tolerant?: boolean): any {
let parts = path.split('.');
- let keyName = parts.pop();
+ let keyName = parts.pop() as string;
assert('Property set failed: You passed an empty path', keyName!.trim().length > 0);
let newPath = parts.join('.');
-
let newRoot = getPath(root, newPath);
- if (newRoot) {
- return set(newRoot, keyName!, value);
+ if (newRoot !== null && newRoot !== undefined) {
+ return set(newRoot, keyName, value);
} else if (!tolerant) {
- throw new EmberError(
- `Property set failed: object in path "${newPath}" could not be found or was destroyed.`
- );
+ throw new EmberError(`Property set failed: object in path "${newPath}" could not be found.`);
}
}
| true |
Other
|
emberjs
|
ember.js
|
f3eec4490ea0ec88ed71da42af5784c19f067720.json
|
avoid boolean coercion in `property_set`
|
packages/ember-metal/tests/accessors/set_path_test.js
|
@@ -77,8 +77,7 @@ moduleFor(
// DEPRECATED
//
['@test [obj, bla.bla] gives a proper exception message'](assert) {
- let exceptionMessage =
- 'Property set failed: object in path "bla" could not be found or was destroyed.';
+ let exceptionMessage = 'Property set failed: object in path "bla" could not be found.';
try {
set(obj, 'bla.bla', 'BAM');
} catch (ex) {
| true |
Other
|
emberjs
|
ember.js
|
8d5d7601395fd42fa0e8a262a74eb93e647f6cd8.json
|
remove redundant argument `reducerProperty`
|
packages/ember-runtime/lib/mixins/array.js
|
@@ -932,17 +932,16 @@ const ArrayMixin = Mixin.create(Enumerable, {
@method reduce
@param {Function} callback The callback to execute
@param {Object} initialValue Initial value for the reduce
- @param {String} reducerProperty internal use only.
@return {Object} The reduced value.
@public
*/
- reduce(callback, initialValue, reducerProperty) {
+ reduce(callback, initialValue) {
assert('`reduce` expects a function as first argument.', typeof callback === 'function');
let ret = initialValue;
this.forEach(function(item, i) {
- ret = callback(ret, item, i, this, reducerProperty);
+ ret = callback(ret, item, i, this);
}, this);
return ret;
@@ -960,7 +959,7 @@ const ArrayMixin = Mixin.create(Enumerable, {
@public
*/
invoke(methodName, ...args) {
- return this.map((item) => tryInvoke(item, methodName, args));
+ return this.map(item => tryInvoke(item, methodName, args));
},
/**
| false |
Other
|
emberjs
|
ember.js
|
573ddd1ac3a085adc0319361ca5f14b737a9f60d.json
|
Add v3.3.0-beta.1 to CHANGELOG.md.
|
CHANGELOG.md
|
@@ -1,5 +1,13 @@
# Ember Changelog
+### v3.3.0-beta.1 (May 31, 2018)
+
+- [#16687](https://github.com/emberjs/ember.js/pull/16687) [FEATURE] Implement optional jQuery integration (see [emberjs/rfcs#294](https://github.com/emberjs/rfcs/blob/master/text/0294-optional-jquery.md) for more details).
+- [#16690](https://github.com/emberjs/ember.js/pull/16690) [DEPRECATION] [emberjs/rfcs#294](emberjs/rfcs#294) Deprecate accessing `jQuery.Event#originalEvent`.
+- [#16691](https://github.com/emberjs/ember.js/pull/16691) [DEPRECATION] [emberjs/rfcs#237](https://github.com/emberjs/rfcs/pull/237) Implement `Ember.Map`, `Ember.MapWithDefault`, and `Ember.OrderedSet` deprecation.
+- [#16692](https://github.com/emberjs/ember.js/pull/16692) [DEPRECATION] [emberjs/rfcs#322](https://github.com/emberjs/rfcs/pull/322) Implement `Ember.copy`/`Ember.Copyable` deprecation.
+
+
### v3.2.0 (May 31, 2018)
- [#16613](https://github.com/emberjs/ember.js/pull/16613) [BUGFIX] Prevent errors in ember-engines + 3.1 + proxies.
| false |
Other
|
emberjs
|
ember.js
|
5154db427be5cbc722600b5344eb1802ebd2e3b4.json
|
Add 3.2.0 to CHANGELOG.
(cherry picked from commit d3d1f787e52e29ce0e02385ad41703dafa066f65)
|
CHANGELOG.md
|
@@ -1,14 +1,11 @@
# Ember Changelog
-### v3.2.0-beta.5 (May 14, 2018)
-- [#16613](https://github.com/emberjs/ember.js/pull/16613) [BUGFIX] Prevent errors in ember-engines + 3.1 + proxies.
+### v3.2.0 (May 31, 2018)
-### v3.2.0-beta.4 (May 7, 2018)
+- [#16613](https://github.com/emberjs/ember.js/pull/16613) [BUGFIX] Prevent errors in ember-engines + 3.1 + proxies.
- [#16597](https://github.com/emberjs/ember.js/pull/16597) [BUGFIX] Ensure `Ember.run.cancelTimers` is present.
- [#16605](https://github.com/emberjs/ember.js/pull/16605) [BUGFIX] Use resetCache on container destroy
- [#16615](https://github.com/emberjs/ember.js/pull/16615) [BUGFIX] Fix NAMESPACES_BY_ID leaks
-
-### v3.2.0-beta.3 (April 23, 2018)
- [#16539](https://github.com/emberjs/ember.js/pull/16539) [BUGFIX] Ember is already registered by the libraries registry already.
- [#16559](https://github.com/emberjs/ember.js/pull/16559) [BUGFIX] Fix property normalization, Update glimmer-vm to 0.34.0
- [#16563](https://github.com/emberjs/ember.js/pull/16563) [BUGFIX] Ensure `ariaRole` can be initially false.
@@ -18,19 +15,13 @@
- [#16560](https://github.com/emberjs/ember.js/pull/16560) [BUGFIX] avoid strict assertion when object proxy calls thru for function
- [#16564](https://github.com/emberjs/ember.js/pull/16564) [BUGFIX] Ensure Ember.isArray does not trigger proxy assertion.
- [#16572](https://github.com/emberjs/ember.js/pull/16572) [BUGFIX] Fix curly component class reference setup
-
-### v3.2.0-beta.2 (April 16, 2018)
-
- [#16493](https://github.com/emberjs/ember.js/pull/16493) [BUGFIX] Ensure proxies have access to `getOwner(this)`.
- [#16494](https://github.com/emberjs/ember.js/pull/16494) [BUGFIX] Adjust assertion to allow for either undefined or null
- [#16499](https://github.com/emberjs/ember.js/pull/16499) [BUGFIX] Object to string serialization
- [#16514](https://github.com/emberjs/ember.js/pull/16514) [BUGFIX] Bring back (with deprecation) Ember.EXTEND_PROTOTYPES.
- [#16520](https://github.com/emberjs/ember.js/pull/16520) [BUGFIX] Adds options checking ability to debug/deprecation test helpers
- [#16526](https://github.com/emberjs/ember.js/pull/16526) [BUGFIX] Ensure setting a `NAME_KEY` does not error.
- [#16527](https://github.com/emberjs/ember.js/pull/16527) [BUGFIX] Update glimmer-vm to 0.33.5.
-
-### v3.2.0-beta.1 (April 10, 2018)
-
- [#16250](https://github.com/emberjs/ember.js/pull/16250) [DEPRECATION] Deprecation of `Ember.Logger`
- [#16436](https://github.com/emberjs/ember.js/pull/16436) [BUGFIX] Refactor `CoreObject` to leverage native JS semantics.
- [#16382](https://github.com/emberjs/ember.js/pull/16382) Upgrade `backburner.js` to 2.2.2.
| false |
Other
|
emberjs
|
ember.js
|
e59fa6bb366b6303834a34bbb18fb7264cb98fa4.json
|
Add tests for dynamic angle bracket invocation.
|
packages/ember-glimmer/tests/integration/components/angle-bracket-invocation-test.js
|
@@ -465,20 +465,20 @@ if (EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) {
'@test positional parameters are not allowed'() {
this.registerComponent('sample-component', {
ComponentClass: Component.extend().reopenClass({
- positionalParams: ['name', 'age'],
+ positionalParams: ['first', 'second'],
}),
- template: '{{name}}{{age}}',
+ template: '{{first}}{{second}}',
});
// this is somewhat silly as the browser "corrects" for these as
// attribute names, but regardless the thing we care about here is that
// they are **not** used as positional params
- this.render('<SampleComponent Quint 4 />');
+ this.render('<SampleComponent one two />');
this.assertText('');
}
- '@skip can invoke curried components with capitalized block param names'() {
+ '@test can invoke curried components with capitalized block param names'() {
this.registerComponent('foo-bar', { template: 'hello' });
this.render(strip`
@@ -496,6 +496,34 @@ if (EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) {
this.assertStableRerender();
}
+ '@test can invoke curried components with named args'() {
+ this.registerComponent('foo-bar', { template: 'hello' });
+ this.registerComponent('test-harness', { template: '<@foo />' });
+ this.render(strip`{{test-harness foo=(component 'foo-bar')}}`);
+
+ this.assertComponentElement(this.firstChild.firstChild, { content: 'hello' });
+
+ this.runTask(() => this.rerender());
+
+ this.assertComponentElement(this.firstChild.firstChild, { content: 'hello' });
+
+ this.assertStableRerender();
+ }
+
+ '@test can invoke curried components with a path'() {
+ this.registerComponent('foo-bar', { template: 'hello' });
+ this.registerComponent('test-harness', { template: '<this.foo />' });
+ this.render(strip`{{test-harness foo=(component 'foo-bar')}}`);
+
+ this.assertComponentElement(this.firstChild.firstChild, { content: 'hello' });
+
+ this.runTask(() => this.rerender());
+
+ this.assertComponentElement(this.firstChild.firstChild, { content: 'hello' });
+
+ this.assertStableRerender();
+ }
+
'@test has-block'() {
this.registerComponent('check-block', {
template: strip`
@@ -516,7 +544,7 @@ if (EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) {
this.assertStableRerender();
}
- '@skip includes invocation specified attributes in root element ("splattributes")'() {
+ '@test includes invocation specified attributes in root element ("splattributes")'() {
this.registerComponent('foo-bar', {
ComponentClass: Component.extend(),
template: 'hello',
| false |
Other
|
emberjs
|
ember.js
|
d676abe1a5736f5a6a576d541ed4d7dd538788d3.json
|
pass meta to `defineProperty`
|
packages/ember-metal/lib/properties.ts
|
@@ -169,7 +169,6 @@ export function defineProperty(
if (wasDescriptor) {
previousDesc.teardown(obj, keyName, meta);
-
meta.removeDescriptors(keyName);
}
| true |
Other
|
emberjs
|
ember.js
|
d676abe1a5736f5a6a576d541ed4d7dd538788d3.json
|
pass meta to `defineProperty`
|
packages/ember-runtime/lib/system/core_object.js
|
@@ -197,7 +197,7 @@ function makeCtor(base) {
self.setUnknownProperty(keyName, value);
} else {
if (DEBUG) {
- defineProperty(self, keyName, null, value); // setup mandatory setter
+ defineProperty(self, keyName, null, value, m); // setup mandatory setter
} else {
self[keyName] = value;
}
| true |
Other
|
emberjs
|
ember.js
|
cc3147ddfa7e0cdfb9ece6ad81b877771b4ac127.json
|
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.
|
package.json
|
@@ -66,14 +66,14 @@
"resolve": "^1.6.0"
},
"devDependencies": {
- "@glimmer/compiler": "^0.34.6",
+ "@glimmer/compiler": "^0.34.8",
"@glimmer/env": "^0.1.7",
- "@glimmer/interfaces": "^0.34.6",
- "@glimmer/node": "^0.34.6",
- "@glimmer/opcode-compiler": "^0.34.6",
- "@glimmer/program": "^0.34.6",
- "@glimmer/reference": "^0.34.6",
- "@glimmer/runtime": "^0.34.6",
+ "@glimmer/interfaces": "^0.34.8",
+ "@glimmer/node": "^0.34.8",
+ "@glimmer/opcode-compiler": "^0.34.8",
+ "@glimmer/program": "^0.34.8",
+ "@glimmer/reference": "^0.34.8",
+ "@glimmer/runtime": "^0.34.8",
"@types/qunit": "^2.5.0",
"@types/rsvp": "^4.0.1",
"amd-name-resolver": "^1.2.0",
| true |
Other
|
emberjs
|
ember.js
|
cc3147ddfa7e0cdfb9ece6ad81b877771b4ac127.json
|
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.
|
yarn.lock
|
@@ -2,105 +2,105 @@
# yarn lockfile v1
-"@glimmer/compiler@^0.34.6":
- version "0.34.6"
- resolved "https://registry.yarnpkg.com/@glimmer/compiler/-/compiler-0.34.6.tgz#cb3b4aa4765d174da365abfbfc78fcd5214eac69"
+"@glimmer/compiler@^0.34.8":
+ version "0.34.8"
+ resolved "https://registry.yarnpkg.com/@glimmer/compiler/-/compiler-0.34.8.tgz#bd61d598224bb2332282c27c690b075f20f0646e"
dependencies:
- "@glimmer/interfaces" "^0.34.6"
- "@glimmer/syntax" "^0.34.6"
- "@glimmer/util" "^0.34.6"
- "@glimmer/wire-format" "^0.34.6"
+ "@glimmer/interfaces" "^0.34.8"
+ "@glimmer/syntax" "^0.34.8"
+ "@glimmer/util" "^0.34.8"
+ "@glimmer/wire-format" "^0.34.8"
-"@glimmer/encoder@^0.34.6":
- version "0.34.6"
- resolved "https://registry.yarnpkg.com/@glimmer/encoder/-/encoder-0.34.6.tgz#622018544dde56446ef2b994947f9be5df8f9ff7"
+"@glimmer/encoder@^0.34.8":
+ version "0.34.8"
+ resolved "https://registry.yarnpkg.com/@glimmer/encoder/-/encoder-0.34.8.tgz#e3548dab4fc639800fcc9267c236781c848f3ddd"
"@glimmer/env@^0.1.7":
version "0.1.7"
resolved "https://registry.yarnpkg.com/@glimmer/env/-/env-0.1.7.tgz#fd2d2b55a9029c6b37a6c935e8c8871ae70dfa07"
-"@glimmer/interfaces@^0.34.6":
- version "0.34.6"
- resolved "https://registry.yarnpkg.com/@glimmer/interfaces/-/interfaces-0.34.6.tgz#cd5f94583b48f90dca1c1dc5e6e2a1a88d516c7f"
+"@glimmer/interfaces@^0.34.8":
+ version "0.34.8"
+ resolved "https://registry.yarnpkg.com/@glimmer/interfaces/-/interfaces-0.34.8.tgz#421ff213a69120d42ffacf6edc184f8e78e558f5"
dependencies:
- "@glimmer/wire-format" "^0.34.6"
+ "@glimmer/wire-format" "^0.34.8"
-"@glimmer/low-level@^0.34.6":
- version "0.34.6"
- resolved "https://registry.yarnpkg.com/@glimmer/low-level/-/low-level-0.34.6.tgz#1c0895906159075e35b22beb82014c07b9060484"
+"@glimmer/low-level@^0.34.8":
+ version "0.34.8"
+ resolved "https://registry.yarnpkg.com/@glimmer/low-level/-/low-level-0.34.8.tgz#ac82953d68171ed5640a8d58045afd57d35ed0ac"
-"@glimmer/node@^0.34.6":
- version "0.34.6"
- resolved "https://registry.yarnpkg.com/@glimmer/node/-/node-0.34.6.tgz#9545cf1ee41f6112522115f3c321213ee70dcbbf"
+"@glimmer/node@^0.34.8":
+ version "0.34.8"
+ resolved "https://registry.yarnpkg.com/@glimmer/node/-/node-0.34.8.tgz#294c96c1e6c09a22dc2a136eb9582a0557f87d0b"
dependencies:
- "@glimmer/interfaces" "^0.34.6"
- "@glimmer/runtime" "^0.34.6"
+ "@glimmer/interfaces" "^0.34.8"
+ "@glimmer/runtime" "^0.34.8"
simple-dom "^0.3.0"
-"@glimmer/opcode-compiler@^0.34.6":
- version "0.34.6"
- resolved "https://registry.yarnpkg.com/@glimmer/opcode-compiler/-/opcode-compiler-0.34.6.tgz#f1032864210be247850ad7f18be5728bb75673db"
- dependencies:
- "@glimmer/encoder" "^0.34.6"
- "@glimmer/interfaces" "^0.34.6"
- "@glimmer/program" "^0.34.6"
- "@glimmer/reference" "^0.34.6"
- "@glimmer/util" "^0.34.6"
- "@glimmer/vm" "^0.34.6"
- "@glimmer/wire-format" "^0.34.6"
-
-"@glimmer/program@^0.34.6":
- version "0.34.6"
- resolved "https://registry.yarnpkg.com/@glimmer/program/-/program-0.34.6.tgz#dee64251c900d3fa77db553f7febb1a8577bd87e"
- dependencies:
- "@glimmer/encoder" "^0.34.6"
- "@glimmer/interfaces" "^0.34.6"
- "@glimmer/util" "^0.34.6"
-
-"@glimmer/reference@^0.34.6":
- version "0.34.6"
- resolved "https://registry.yarnpkg.com/@glimmer/reference/-/reference-0.34.6.tgz#c5116c39eed505f21578972e34403622d966fe8a"
- dependencies:
- "@glimmer/util" "^0.34.6"
-
-"@glimmer/runtime@^0.34.6":
- version "0.34.6"
- resolved "https://registry.yarnpkg.com/@glimmer/runtime/-/runtime-0.34.6.tgz#f3321ea8e2e153bd42ddfd27b33e50005e105f4e"
- dependencies:
- "@glimmer/interfaces" "^0.34.6"
- "@glimmer/low-level" "^0.34.6"
- "@glimmer/program" "^0.34.6"
- "@glimmer/reference" "^0.34.6"
- "@glimmer/util" "^0.34.6"
- "@glimmer/vm" "^0.34.6"
- "@glimmer/wire-format" "^0.34.6"
-
-"@glimmer/syntax@^0.34.6":
- version "0.34.6"
- resolved "https://registry.yarnpkg.com/@glimmer/syntax/-/syntax-0.34.6.tgz#5e471aa4edfca1a57d41b9a9e568fe3add461353"
- dependencies:
- "@glimmer/interfaces" "^0.34.6"
- "@glimmer/util" "^0.34.6"
+"@glimmer/opcode-compiler@^0.34.8":
+ version "0.34.8"
+ resolved "https://registry.yarnpkg.com/@glimmer/opcode-compiler/-/opcode-compiler-0.34.8.tgz#9851f94162dd1c691b4db4d37b84d817a0a717c4"
+ dependencies:
+ "@glimmer/encoder" "^0.34.8"
+ "@glimmer/interfaces" "^0.34.8"
+ "@glimmer/program" "^0.34.8"
+ "@glimmer/reference" "^0.34.8"
+ "@glimmer/util" "^0.34.8"
+ "@glimmer/vm" "^0.34.8"
+ "@glimmer/wire-format" "^0.34.8"
+
+"@glimmer/program@^0.34.8":
+ version "0.34.8"
+ resolved "https://registry.yarnpkg.com/@glimmer/program/-/program-0.34.8.tgz#6d0867f6c1bbfbad5835946717e26fb8fb842a7c"
+ dependencies:
+ "@glimmer/encoder" "^0.34.8"
+ "@glimmer/interfaces" "^0.34.8"
+ "@glimmer/util" "^0.34.8"
+
+"@glimmer/reference@^0.34.8":
+ version "0.34.8"
+ resolved "https://registry.yarnpkg.com/@glimmer/reference/-/reference-0.34.8.tgz#441933512355afc7da131c5908d818eff07bf15c"
+ dependencies:
+ "@glimmer/util" "^0.34.8"
+
+"@glimmer/runtime@^0.34.8":
+ version "0.34.8"
+ resolved "https://registry.yarnpkg.com/@glimmer/runtime/-/runtime-0.34.8.tgz#85831f857e3a67c6de5a7531b6d570586a3f70b4"
+ dependencies:
+ "@glimmer/interfaces" "^0.34.8"
+ "@glimmer/low-level" "^0.34.8"
+ "@glimmer/program" "^0.34.8"
+ "@glimmer/reference" "^0.34.8"
+ "@glimmer/util" "^0.34.8"
+ "@glimmer/vm" "^0.34.8"
+ "@glimmer/wire-format" "^0.34.8"
+
+"@glimmer/syntax@^0.34.8":
+ version "0.34.8"
+ resolved "https://registry.yarnpkg.com/@glimmer/syntax/-/syntax-0.34.8.tgz#fc7c54faa450111a4c97200100f7510294217156"
+ dependencies:
+ "@glimmer/interfaces" "^0.34.8"
+ "@glimmer/util" "^0.34.8"
handlebars "^4.0.6"
- simple-html-tokenizer "^0.5.1"
+ simple-html-tokenizer "^0.5.3"
-"@glimmer/util@^0.34.6":
- version "0.34.6"
- resolved "https://registry.yarnpkg.com/@glimmer/util/-/util-0.34.6.tgz#bb8202655927a721a09a4fb8f063a074409b9f30"
+"@glimmer/util@^0.34.8":
+ version "0.34.8"
+ resolved "https://registry.yarnpkg.com/@glimmer/util/-/util-0.34.8.tgz#0f1349b3134bb55d4887da73919863401647525b"
-"@glimmer/vm@^0.34.6":
- version "0.34.6"
- resolved "https://registry.yarnpkg.com/@glimmer/vm/-/vm-0.34.6.tgz#03201d215eb74a7a543584c1de695c85341afa0b"
+"@glimmer/vm@^0.34.8":
+ version "0.34.8"
+ resolved "https://registry.yarnpkg.com/@glimmer/vm/-/vm-0.34.8.tgz#4485dcf41f1caa4bf05449c4dfb440bb88afc039"
dependencies:
- "@glimmer/interfaces" "^0.34.6"
- "@glimmer/program" "^0.34.6"
- "@glimmer/util" "^0.34.6"
+ "@glimmer/interfaces" "^0.34.8"
+ "@glimmer/program" "^0.34.8"
+ "@glimmer/util" "^0.34.8"
-"@glimmer/wire-format@^0.34.6":
- version "0.34.6"
- resolved "https://registry.yarnpkg.com/@glimmer/wire-format/-/wire-format-0.34.6.tgz#ad4684ea5c0d1f4b3f36fdbdbd8b46a921431a1e"
+"@glimmer/wire-format@^0.34.8":
+ version "0.34.8"
+ resolved "https://registry.yarnpkg.com/@glimmer/wire-format/-/wire-format-0.34.8.tgz#5f792d4c8789d77a801e7d4c742ea42f55d24816"
dependencies:
- "@glimmer/util" "^0.34.6"
+ "@glimmer/util" "^0.34.8"
"@types/acorn@^4.0.3":
version "4.0.3"
@@ -6589,9 +6589,9 @@ simple-dom@^0.3.0:
version "0.3.2"
resolved "https://registry.yarnpkg.com/simple-dom/-/simple-dom-0.3.2.tgz#0663d10f1556f1500551d518f56e3aba0871371d"
-simple-html-tokenizer@^0.5.1:
- version "0.5.1"
- resolved "https://registry.yarnpkg.com/simple-html-tokenizer/-/simple-html-tokenizer-0.5.1.tgz#125d486de28ffd5365624c11a71944a2cc2826dc"
+simple-html-tokenizer@^0.5.3:
+ version "0.5.3"
+ resolved "https://registry.yarnpkg.com/simple-html-tokenizer/-/simple-html-tokenizer-0.5.3.tgz#c1c246a53ccf1cd65fb2fa970967145b47602ce4"
sinon@^1.17.6:
version "1.17.7"
| true |
Other
|
emberjs
|
ember.js
|
c369dcea2cc7e63be1545eb456c5cd91f308c479.json
|
avoid boolean coercion in `meta`
|
packages/ember-meta/lib/meta.ts
|
@@ -189,7 +189,7 @@ export class Meta {
// Implements a member that provides a lazily created map of maps,
// with inheritance at both levels.
- writeDeps(subkey: string, itemkey: string, value: any) {
+ writeDeps(subkey: string, itemkey: string, count: number) {
assert(
this.isMetaDestroyed()
? `Cannot modify dependent keys for \`${itemkey}\` on \`${toString(
@@ -204,10 +204,10 @@ export class Meta {
if (innerMap === undefined) {
innerMap = outerMap[subkey] = Object.create(null);
}
- innerMap[itemkey] = value;
+ innerMap[itemkey] = count;
}
- peekDeps(subkey: string, itemkey: string) {
+ peekDeps(subkey: string, itemkey: string): number {
let pointer: Meta | undefined = this;
while (pointer !== undefined) {
let map = pointer._deps;
@@ -222,6 +222,8 @@ export class Meta {
}
pointer = pointer.parent;
}
+
+ return 0;
}
hasDeps(subkey: string) {
@@ -350,8 +352,9 @@ export class Meta {
map[subkey] = value;
}
- peekWatching(subkey: string) {
- return this._findInherited('_watching', subkey);
+ peekWatching(subkey: string): number {
+ let count = this._findInherited('_watching', subkey);
+ return count === undefined ? 0 : count;
}
addMixin(mixin: any) {
| true |
Other
|
emberjs
|
ember.js
|
c369dcea2cc7e63be1545eb456c5cd91f308c479.json
|
avoid boolean coercion in `meta`
|
packages/ember-metal/lib/alias.ts
|
@@ -13,7 +13,7 @@ import { defineProperty, Descriptor } from './properties';
import { get } from './property_get';
import { set } from './property_set';
-const CONSUMED = {};
+const CONSUMED = Object.freeze({});
export default function alias(altKey: string): AliasedProperty {
return new AliasedProperty(altKey);
@@ -32,13 +32,13 @@ export class AliasedProperty extends Descriptor implements DescriptorWithDepende
setup(obj: object, keyName: string): void {
assert(`Setting alias '${keyName}' on self`, this.altKey !== keyName);
let meta = metaFor(obj);
- if (meta.peekWatching(keyName)) {
+ if (meta.peekWatching(keyName) > 0) {
addDependentKeys(this, obj, keyName, meta);
}
}
teardown(obj: object, keyName: string, meta: Meta): void {
- if (meta.peekWatching(keyName)) {
+ if (meta.peekWatching(keyName) > 0) {
removeDependentKeys(this, obj, keyName, meta);
}
}
| true |
Other
|
emberjs
|
ember.js
|
c369dcea2cc7e63be1545eb456c5cd91f308c479.json
|
avoid boolean coercion in `meta`
|
packages/ember-metal/lib/dependent_keys.ts
|
@@ -25,7 +25,7 @@ export function addDependentKeys(
for (let idx = 0; idx < depKeys.length; idx++) {
let depKey = depKeys[idx];
// Increment the number of times depKey depends on keyName.
- meta.writeDeps(depKey, keyName, (meta.peekDeps(depKey, keyName) || 0) + 1);
+ meta.writeDeps(depKey, keyName, meta.peekDeps(depKey, keyName) + 1);
// Watch the depKey
watch(obj, depKey, meta);
}
@@ -47,7 +47,7 @@ export function removeDependentKeys(
for (let idx = 0; idx < depKeys.length; idx++) {
let depKey = depKeys[idx];
// Decrement the number of times depKey depends on keyName.
- meta.writeDeps(depKey, keyName, (meta.peekDeps(depKey, keyName) || 0) - 1);
+ meta.writeDeps(depKey, keyName, meta.peekDeps(depKey, keyName) - 1);
// Unwatch the depKey
unwatch(obj, depKey, meta);
}
| true |
Other
|
emberjs
|
ember.js
|
c369dcea2cc7e63be1545eb456c5cd91f308c479.json
|
avoid boolean coercion in `meta`
|
packages/ember-metal/lib/properties.ts
|
@@ -163,8 +163,7 @@ export function defineProperty(
meta = metaFor(obj);
}
- let watchEntry = meta.peekWatching(keyName);
- let watching = watchEntry !== undefined && watchEntry > 0;
+ let watching = meta.peekWatching(keyName) > 0;
let previousDesc = descriptorFor(obj, keyName, meta);
let wasDescriptor = previousDesc !== undefined;
| true |
Other
|
emberjs
|
ember.js
|
c369dcea2cc7e63be1545eb456c5cd91f308c479.json
|
avoid boolean coercion in `meta`
|
packages/ember-metal/lib/watch_key.ts
|
@@ -28,7 +28,7 @@ interface MaybeHasDidUnwatchProperty {
export function watchKey(obj: object, keyName: string, _meta?: Meta) {
let meta = _meta === undefined ? metaFor(obj) : _meta;
- let count = meta.peekWatching(keyName) || 0;
+ let count = meta.peekWatching(keyName);
meta.writeWatching(keyName, count + 1);
if (count === 0) {
| true |
Other
|
emberjs
|
ember.js
|
c369dcea2cc7e63be1545eb456c5cd91f308c479.json
|
avoid boolean coercion in `meta`
|
packages/ember-metal/lib/watch_path.ts
|
@@ -3,7 +3,7 @@ import { makeChainNode } from './chains';
export function watchPath(obj: any, keyPath: string, meta?: Meta): void {
let m = meta === undefined ? metaFor(obj) : meta;
- let counter = m.peekWatching(keyPath) || 0;
+ let counter = m.peekWatching(keyPath);
m.writeWatching(keyPath, counter + 1);
if (counter === 0) {
| true |
Other
|
emberjs
|
ember.js
|
6abd2cb7dbe5f4cd4fe6364b28c92dcdbd81c47b.json
|
remove redundant backtick in comment
|
packages/@ember/application/lib/application.js
|
@@ -915,7 +915,7 @@ const Application = Engine.extend({
// Start the app at the special demo URL
App.visit('/demo', options);
});
- ````
+ ```
Or perhaps you might want to boot two instances of your app on the same
page for a split-screen multiplayer experience:
| false |
Other
|
emberjs
|
ember.js
|
9657caeb9d8519705a5820aa7a21885aa670e851.json
|
Add URL to jQuery.Event deprecation
|
packages/ember-views/lib/system/jquery_event_deprecation.js
|
@@ -33,6 +33,7 @@ export default function addJQueryEventDeprecation(jqEvent) {
{
id: 'ember-views.event-dispatcher.jquery-event',
until: '4.0.0',
+ url: 'https://emberjs.com/deprecations/v3.x#toc_jquery-event',
}
);
return target[name];
| false |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/index.ts
|
@@ -1,8 +1,9 @@
import { FEATURES } from '@ember/canary-features';
-import { ENV, context } from 'ember-environment';
+import { context, ENV } from 'ember-environment';
import VERSION from 'ember/version';
-export const _Ember = (typeof context.imports.Ember === 'object' && context.imports.Ember) || {};
+export const _Ember =
+ (typeof (context.imports as any).Ember === 'object' && (context.imports as any).Ember) || {};
// private API used by ember-cli-htmlbars to setup ENV and FEATURES
if (!_Ember.ENV) {
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/compat.ts
|
@@ -1,8 +1,8 @@
-import precompile from './system/precompile';
import compile from './system/compile';
import { registerPlugin } from './system/compile-options';
+import precompile from './system/precompile';
-export default function setupGlobal(Ember) {
+export default function setupGlobal(Ember: any) {
let EmberHandlebars = Ember.Handlebars;
if (!EmberHandlebars) {
Ember.Handlebars = EmberHandlebars = {};
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/plugins/assert-if-helper-without-arguments.ts
|
@@ -1,14 +1,15 @@
import { assert } from '@ember/debug';
+import { AST, ASTPlugin, ASTPluginEnvironment } from '@glimmer/syntax';
import calculateLocationDisplay from '../system/calculate-location-display';
-export default function assertIfHelperWithoutArguments(env) {
+export default function assertIfHelperWithoutArguments(env: ASTPluginEnvironment): ASTPlugin {
let { moduleName } = env.meta;
return {
name: 'assert-if-helper-without-arguments',
visitor: {
- BlockStatement(node) {
+ BlockStatement(node: AST.BlockStatement) {
if (isInvalidBlockIf(node)) {
assert(
`${blockAssertMessage(node.path.original)} ${calculateLocationDisplay(
@@ -19,18 +20,18 @@ export default function assertIfHelperWithoutArguments(env) {
}
},
- MustacheStatement(node) {
+ MustacheStatement(node: AST.MustacheStatement) {
if (isInvalidInlineIf(node)) {
assert(
- `${inlineAssertMessage(node.path.original)} ${calculateLocationDisplay(
+ `${inlineAssertMessage(node.path.original as string)} ${calculateLocationDisplay(
moduleName,
node.loc
)}`
);
}
},
- SubExpression(node) {
+ SubExpression(node: AST.SubExpression) {
if (isInvalidInlineIf(node)) {
assert(
`${inlineAssertMessage(node.path.original)} ${calculateLocationDisplay(
@@ -44,21 +45,21 @@ export default function assertIfHelperWithoutArguments(env) {
};
}
-function blockAssertMessage(original) {
+function blockAssertMessage(original: string) {
return `#${original} requires a single argument.`;
}
-function inlineAssertMessage(original) {
+function inlineAssertMessage(original: string) {
return `The inline form of the '${original}' helper expects two or three arguments.`;
}
-function isInvalidInlineIf(node) {
+function isInvalidInlineIf(node: AST.BlockStatement | AST.MustacheStatement | AST.SubExpression) {
return (
node.path.original === 'if' &&
(!node.params || node.params.length < 2 || node.params.length > 3)
);
}
-function isInvalidBlockIf(node) {
+function isInvalidBlockIf(node: AST.BlockStatement | AST.MustacheStatement | AST.SubExpression) {
return node.path.original === 'if' && (!node.params || node.params.length !== 1);
}
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/plugins/assert-input-helper-without-block.ts
|
@@ -1,14 +1,15 @@
import { assert } from '@ember/debug';
+import { AST, ASTPlugin, ASTPluginEnvironment } from '@glimmer/syntax';
import calculateLocationDisplay from '../system/calculate-location-display';
-export default function errorOnInputWithContent(env) {
+export default function errorOnInputWithContent(env: ASTPluginEnvironment): ASTPlugin {
let { moduleName } = env.meta;
return {
name: 'assert-input-helper-without-block',
visitor: {
- BlockStatement(node) {
+ BlockStatement(node: AST.BlockStatement) {
if (node.path.original !== 'input') {
return;
}
@@ -19,7 +20,7 @@ export default function errorOnInputWithContent(env) {
};
}
-function assertMessage(moduleName, node) {
+function assertMessage(moduleName: string, node: AST.BlockStatement): string {
let sourceInformation = calculateLocationDisplay(moduleName, node.loc);
return `The {{input}} helper cannot be used in block form. ${sourceInformation}`;
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/plugins/assert-reserved-named-arguments.ts
|
@@ -1,19 +1,20 @@
-import { assert } from '@ember/debug';
import { EMBER_GLIMMER_NAMED_ARGUMENTS } from '@ember/canary-features';
+import { assert } from '@ember/debug';
+import { AST, ASTPlugin, ASTPluginEnvironment } from '@glimmer/syntax';
import calculateLocationDisplay from '../system/calculate-location-display';
const RESERVED = ['@arguments', '@args', '@block', '@else'];
-let isReserved, assertMessage;
+let isReserved: (name: string) => boolean, assertMessage: (name: string) => void;
-export default function assertReservedNamedArguments(env) {
+export default function assertReservedNamedArguments(env: ASTPluginEnvironment): ASTPlugin {
let { moduleName } = env.meta;
return {
name: 'assert-reserved-named-arguments',
visitor: {
- PathExpression({ original, loc }) {
+ PathExpression({ original, loc }: AST.PathExpression) {
if (isReserved(original)) {
assert(`${assertMessage(original)} ${calculateLocationDisplay(moduleName, loc)}`);
}
@@ -23,7 +24,7 @@ export default function assertReservedNamedArguments(env) {
}
if (EMBER_GLIMMER_NAMED_ARGUMENTS) {
- isReserved = name => RESERVED.indexOf(name) !== -1 || name.match(/^@[^a-z]/);
+ isReserved = name => RESERVED.indexOf(name) !== -1 || !!name.match(/^@[^a-z]/);
assertMessage = name => `'${name}' is reserved.`;
} else {
isReserved = name => name[0] === '@';
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/plugins/assert-splattribute-expression.ts
|
@@ -1,8 +1,9 @@
+import { EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION } from '@ember/canary-features';
import { assert } from '@ember/debug';
+import { ASTPlugin, ASTPluginEnvironment } from '@glimmer/syntax';
import calculateLocationDisplay from '../system/calculate-location-display';
-import { EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION } from '@ember/canary-features';
-export default function assertSplattributeExpressions(env) {
+export default function assertSplattributeExpressions(env: ASTPluginEnvironment): ASTPlugin {
let { moduleName } = env.meta;
return {
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/plugins/deprecate-render-model.ts
|
@@ -1,15 +1,16 @@
import { deprecate } from '@ember/debug';
import { RENDER_HELPER } from '@ember/deprecated-features';
+import { AST, ASTPlugin, ASTPluginEnvironment } from '@glimmer/syntax';
import calculateLocationDisplay from '../system/calculate-location-display';
// Remove after 3.4 once _ENABLE_RENDER_SUPPORT flag is no longer needed.
-export default function deprecateRenderModel(env) {
+export default function deprecateRenderModel(env: ASTPluginEnvironment): ASTPlugin | undefined {
if (RENDER_HELPER) {
let { moduleName } = env.meta;
- let deprecationMessage = (node, param) => {
+ let deprecationMessage = (node: AST.MustacheStatement, param: AST.PathExpression) => {
let sourceInformation = calculateLocationDisplay(moduleName, node.loc);
- let componentName = node.params[0].original;
+ let componentName = (node.params[0] as AST.PathExpression).original;
let modelName = param.original;
let original = `{{render "${componentName}" ${modelName}}}`;
let preferred = `{{${componentName} model=${modelName}}}`;
@@ -24,7 +25,7 @@ export default function deprecateRenderModel(env) {
name: 'deprecate-render-model',
visitor: {
- MustacheStatement(node) {
+ MustacheStatement(node: AST.MustacheStatement) {
if (node.path.original === 'render' && node.params.length > 1) {
node.params.forEach(param => {
if (param.type !== 'PathExpression') {
@@ -43,4 +44,5 @@ export default function deprecateRenderModel(env) {
},
};
}
+ return undefined;
}
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/plugins/deprecate-render.ts
|
@@ -1,15 +1,16 @@
import { deprecate } from '@ember/debug';
import { RENDER_HELPER } from '@ember/deprecated-features';
+import { AST, ASTPlugin, ASTPluginEnvironment } from '@glimmer/syntax';
import calculateLocationDisplay from '../system/calculate-location-display';
// Remove after 3.4 once _ENABLE_RENDER_SUPPORT flag is no longer needed.
-export default function deprecateRender(env) {
+export default function deprecateRender(env: ASTPluginEnvironment): ASTPlugin | undefined {
if (RENDER_HELPER) {
let { moduleName } = env.meta;
- let deprecationMessage = node => {
+ let deprecationMessage = (node: AST.MustacheStatement) => {
let sourceInformation = calculateLocationDisplay(moduleName, node.loc);
- let componentName = node.params[0].original;
+ let componentName = (node.params[0] as AST.PathExpression).original;
let original = `{{render "${componentName}"}}`;
let preferred = `{{${componentName}}}`;
@@ -23,7 +24,7 @@ export default function deprecateRender(env) {
name: 'deprecate-render',
visitor: {
- MustacheStatement(node) {
+ MustacheStatement(node: AST.MustacheStatement) {
if (node.path.original !== 'render') {
return;
}
@@ -46,4 +47,5 @@ export default function deprecateRender(env) {
},
};
}
+ return undefined;
}
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/plugins/index.ts
|
@@ -1,26 +1,29 @@
-import TransformOldBindingSyntax from './transform-old-binding-syntax';
-import TransformAngleBracketComponents from './transform-angle-bracket-components';
-import TransformTopLevelComponents from './transform-top-level-components';
-import TransformInlineLinkTo from './transform-inline-link-to';
-import TransformOldClassBindingSyntax from './transform-old-class-binding-syntax';
-import TransformQuotedBindingsIntoJustBindings from './transform-quoted-bindings-into-just-bindings';
-import DeprecateRenderModel from './deprecate-render-model';
-import DeprecateRender from './deprecate-render';
+import AssertIfHelperWithoutArguments from './assert-if-helper-without-arguments';
+import AssertInputHelperWithoutBlock from './assert-input-helper-without-block';
import AssertReservedNamedArguments from './assert-reserved-named-arguments';
+import AssertSplattributeExpressions from './assert-splattribute-expression';
+import DeprecateRender from './deprecate-render';
+import DeprecateRenderModel from './deprecate-render-model';
import TransformActionSyntax from './transform-action-syntax';
-import TransformInputTypeSyntax from './transform-input-type-syntax';
+import TransformAngleBracketComponents from './transform-angle-bracket-components';
import TransformAttrsIntoArgs from './transform-attrs-into-args';
+import TransformDotComponentInvocation from './transform-dot-component-invocation';
import TransformEachInIntoEach from './transform-each-in-into-each';
import TransformHasBlockSyntax from './transform-has-block-syntax';
-import TransformDotComponentInvocation from './transform-dot-component-invocation';
-import AssertInputHelperWithoutBlock from './assert-input-helper-without-block';
import TransformInElement from './transform-in-element';
-import AssertIfHelperWithoutArguments from './assert-if-helper-without-arguments';
-import AssertSplattributeExpressions from './assert-splattribute-expression';
+import TransformInlineLinkTo from './transform-inline-link-to';
+import TransformInputTypeSyntax from './transform-input-type-syntax';
+import TransformOldBindingSyntax from './transform-old-binding-syntax';
+import TransformOldClassBindingSyntax from './transform-old-class-binding-syntax';
+import TransformQuotedBindingsIntoJustBindings from './transform-quoted-bindings-into-just-bindings';
+import TransformTopLevelComponents from './transform-top-level-components';
import { BINDING_SUPPORT, RENDER_HELPER } from '@ember/deprecated-features';
+import { ASTPlugin, ASTPluginEnvironment } from '@glimmer/syntax';
+
+export type APluginFunc = (env: ASTPluginEnvironment) => ASTPlugin | undefined;
-const transforms = [
+const transforms: Array<APluginFunc> = [
TransformDotComponentInvocation,
TransformAngleBracketComponents,
TransformTopLevelComponents,
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/plugins/transform-action-syntax.ts
|
@@ -1,3 +1,6 @@
+import { AST, ASTPlugin, ASTPluginEnvironment } from '@glimmer/syntax';
+import { Builders } from '../types';
+
/**
@module ember
*/
@@ -23,26 +26,26 @@
@class TransformActionSyntax
*/
-export default function transformActionSyntax({ syntax }) {
+export default function transformActionSyntax({ syntax }: ASTPluginEnvironment): ASTPlugin {
let { builders: b } = syntax;
return {
name: 'transform-action-syntax',
visitor: {
- ElementModifierStatement(node) {
+ ElementModifierStatement(node: AST.ElementModifierStatement) {
if (isAction(node)) {
insertThisAsFirstParam(node, b);
}
},
- MustacheStatement(node) {
+ MustacheStatement(node: AST.MustacheStatement) {
if (isAction(node)) {
insertThisAsFirstParam(node, b);
}
},
- SubExpression(node) {
+ SubExpression(node: AST.SubExpression) {
if (isAction(node)) {
insertThisAsFirstParam(node, b);
}
@@ -51,10 +54,13 @@ export default function transformActionSyntax({ syntax }) {
};
}
-function isAction(node) {
+function isAction(node: AST.ElementModifierStatement | AST.MustacheStatement | AST.SubExpression) {
return node.path.original === 'action';
}
-function insertThisAsFirstParam(node, builders) {
+function insertThisAsFirstParam(
+ node: AST.ElementModifierStatement | AST.MustacheStatement | AST.SubExpression,
+ builders: Builders
+) {
node.params.unshift(builders.path('this'));
}
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/plugins/transform-angle-bracket-components.ts
|
@@ -1,11 +1,13 @@
-export default function transformAngleBracketComponents(/* env */) {
+import { ASTPlugin } from '@glimmer/syntax';
+
+export default function transformAngleBracketComponents(/* env */): ASTPlugin {
return {
name: 'transform-angle-bracket-components',
visitor: {
- ComponentNode(node) {
+ ComponentNode(node: any): void {
node.tag = `<${node.tag}>`;
},
},
- };
+ } as any;
}
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/plugins/transform-attrs-into-args.ts
|
@@ -1,3 +1,5 @@
+import { AST, ASTPlugin, ASTPluginEnvironment } from '@glimmer/syntax';
+
/**
@module ember
*/
@@ -22,17 +24,17 @@
@class TransformAttrsToProps
*/
-export default function transformAttrsIntoArgs(env) {
+export default function transformAttrsIntoArgs(env: ASTPluginEnvironment): ASTPlugin {
let { builders: b } = env.syntax;
- let stack = [[]];
+ let stack: string[][] = [[]];
return {
name: 'transform-attrs-into-args',
visitor: {
Program: {
- enter(node) {
+ enter(node: AST.Program) {
let parent = stack[stack.length - 1];
stack.push(parent.concat(node.blockParams));
},
@@ -41,7 +43,7 @@ export default function transformAttrsIntoArgs(env) {
},
},
- PathExpression(node) {
+ PathExpression(node: AST.PathExpression): AST.Node | void {
if (isAttrs(node, stack[stack.length - 1])) {
let path = b.path(node.original.substr(6));
path.original = `@${path.original}`;
@@ -53,7 +55,7 @@ export default function transformAttrsIntoArgs(env) {
};
}
-function isAttrs(node, symbols) {
+function isAttrs(node: AST.PathExpression, symbols: string[]) {
let name = node.parts[0];
if (symbols.indexOf(name) !== -1) {
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/plugins/transform-dot-component-invocation.ts
|
@@ -1,3 +1,6 @@
+import { AST, ASTPlugin, ASTPluginEnvironment } from '@glimmer/syntax';
+import { Builders } from '../types';
+
/**
Transforms dot invocation of closure components to be wrapped
with the component helper. This allows for a more static invocation
@@ -51,19 +54,19 @@
@private
@class TransFormDotComponentInvocation
*/
-export default function transformDotComponentInvocation(env) {
+export default function transformDotComponentInvocation(env: ASTPluginEnvironment): ASTPlugin {
let { builders: b } = env.syntax;
return {
name: 'transform-dot-component-invocation',
visitor: {
- MustacheStatement: node => {
+ MustacheStatement(node: AST.MustacheStatement): AST.Node | void {
if (isInlineInvocation(node.path, node.params, node.hash)) {
wrapInComponent(node, b);
}
},
- BlockStatement: node => {
+ BlockStatement(node: AST.BlockStatement): AST.Node | void {
if (isMultipartPath(node.path)) {
wrapInComponent(node, b);
}
@@ -72,11 +75,15 @@ export default function transformDotComponentInvocation(env) {
};
}
-function isMultipartPath(path) {
- return path.parts && path.parts.length > 1;
+function isMultipartPath(path: AST.PathExpression | AST.Literal) {
+ return (path as AST.PathExpression).parts && (path as AST.PathExpression).parts.length > 1;
}
-function isInlineInvocation(path, params, hash) {
+function isInlineInvocation(
+ path: AST.PathExpression | AST.Literal,
+ params: AST.Node[],
+ hash: AST.Hash
+) {
if (isMultipartPath(path)) {
if (params.length > 0 || hash.pairs.length > 0) {
return true;
@@ -86,7 +93,7 @@ function isInlineInvocation(path, params, hash) {
return false;
}
-function wrapInComponent(node, builder) {
+function wrapInComponent(node: AST.MustacheStatement | AST.BlockStatement, builder: Builders) {
let component = node.path;
let componentHelper = builder.path('component');
node.path = componentHelper;
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/plugins/transform-each-in-into-each.ts
|
@@ -1,3 +1,5 @@
+import { AST, ASTPlugin, ASTPluginEnvironment } from '@glimmer/syntax';
+
/**
@module ember
*/
@@ -18,14 +20,14 @@
@private
@class TransformHasBlockSyntax
*/
-export default function transformEachInIntoEach(env) {
+export default function transformEachInIntoEach(env: ASTPluginEnvironment): ASTPlugin {
let { builders: b } = env.syntax;
return {
name: 'transform-each-in-into-each',
visitor: {
- BlockStatement(node) {
+ BlockStatement(node: AST.BlockStatement): AST.Node | void {
if (node.path.original === 'each-in') {
node.params[0] = b.sexpr(b.path('-each-in'), [node.params[0]]);
@@ -38,8 +40,8 @@ export default function transformEachInIntoEach(env) {
// pick a name that won't parse so it won't shadow any real variables
blockParams = ['( unused value )', blockParams[0]];
} else {
- let key = blockParams.shift();
- let value = blockParams.shift();
+ let key = blockParams.shift()!;
+ let value = blockParams.shift()!;
blockParams = [value, key, ...blockParams];
}
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/plugins/transform-has-block-syntax.ts
|
@@ -1,3 +1,4 @@
+import { AST, ASTPlugin, ASTPluginEnvironment } from '@glimmer/syntax';
/**
@module ember
*/
@@ -24,30 +25,30 @@ const TRANSFORMATIONS = {
hasBlockParams: 'has-block-params',
};
-export default function transformHasBlockSyntax(env) {
+export default function transformHasBlockSyntax(env: ASTPluginEnvironment): ASTPlugin {
let { builders: b } = env.syntax;
return {
name: 'transform-has-block-syntax',
visitor: {
- PathExpression(node) {
+ PathExpression(node: AST.PathExpression): AST.Node | void {
if (TRANSFORMATIONS[node.original]) {
return b.sexpr(b.path(TRANSFORMATIONS[node.original]));
}
},
- MustacheStatement(node) {
- if (TRANSFORMATIONS[node.path.original]) {
+ MustacheStatement(node: AST.MustacheStatement): AST.Node | void {
+ if (typeof node.path.original === 'string' && TRANSFORMATIONS[node.path.original]) {
return b.mustache(
b.path(TRANSFORMATIONS[node.path.original]),
node.params,
node.hash,
- null,
+ undefined,
node.loc
);
}
},
- SubExpression(node) {
+ SubExpression(node: AST.SubExpression): AST.Node | void {
if (TRANSFORMATIONS[node.path.original]) {
return b.sexpr(b.path(TRANSFORMATIONS[node.path.original]), node.params, node.hash);
}
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/plugins/transform-in-element.ts
|
@@ -1,4 +1,5 @@
import { assert } from '@ember/debug';
+import { AST, ASTPlugin, ASTPluginEnvironment } from '@glimmer/syntax';
import calculateLocationDisplay from '../system/calculate-location-display';
/**
@@ -16,7 +17,6 @@ import calculateLocationDisplay from '../system/calculate-location-display';
template transpilation, but since RFC#287 is not landed and enabled by default we _also_ need
to prevent folks from starting to use `{{in-element` "for realz".
-
Tranforms:
```handlebars
@@ -44,7 +44,7 @@ import calculateLocationDisplay from '../system/calculate-location-display';
@private
@class TransformHasBlockSyntax
*/
-export default function transformInElement(env) {
+export default function transformInElement(env: ASTPluginEnvironment): ASTPlugin {
let { moduleName } = env.meta;
let { builders: b } = env.syntax;
let cursorCount = 0;
@@ -53,7 +53,7 @@ export default function transformInElement(env) {
name: 'transform-in-element',
visitor: {
- BlockStatement(node) {
+ BlockStatement(node: AST.BlockStatement) {
if (node.path.original === 'in-element') {
assert(assertMessage(moduleName, node));
} else if (node.path.original === '-in-element') {
@@ -85,7 +85,7 @@ export default function transformInElement(env) {
};
}
-function assertMessage(moduleName, node) {
+function assertMessage(moduleName: string, node: AST.BlockStatement) {
let sourceInformation = calculateLocationDisplay(moduleName, node.loc);
return `The {{in-element}} helper cannot be used. ${sourceInformation}`;
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/plugins/transform-inline-link-to.ts
|
@@ -1,33 +1,36 @@
-function buildProgram(b, content, loc) {
- return b.program([buildStatement(b, content, loc)], null, loc);
+import { AST, ASTPlugin, ASTPluginEnvironment } from '@glimmer/syntax';
+import { Builders } from '../types';
+
+function buildProgram(b: Builders, content: AST.Node, loc: AST.SourceLocation) {
+ return b.program([buildStatement(b, content, loc)], undefined, loc);
}
-function buildStatement(b, content, loc) {
+function buildStatement(b: Builders, content: AST.Node, loc: AST.SourceLocation) {
switch (content.type) {
case 'PathExpression':
- return b.mustache(content, null, null, null, loc);
+ return b.mustache(content, undefined, undefined, undefined, loc);
case 'SubExpression':
- return b.mustache(content.path, content.params, content.hash, null, loc);
+ return b.mustache(content.path, content.params, content.hash, undefined, loc);
// The default case handles literals.
default:
- return b.text(`${content.value}`, loc);
+ return b.text(`${(content as AST.Literal).value}`, loc);
}
}
-function unsafeHtml(b, expr) {
+function unsafeHtml(b: Builders, expr: AST.Expression) {
return b.sexpr('-html-safe', [expr]);
}
-export default function transformInlineLinkTo(env) {
+export default function transformInlineLinkTo(env: ASTPluginEnvironment): ASTPlugin {
let { builders: b } = env.syntax;
return {
name: 'transform-inline-link-to',
visitor: {
- MustacheStatement(node) {
+ MustacheStatement(node: AST.MustacheStatement): AST.Node | void {
if (node.path.original === 'link-to') {
let content = node.escaped ? node.params[0] : unsafeHtml(b, node.params[0]);
return b.block(
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/plugins/transform-input-type-syntax.ts
|
@@ -1,3 +1,6 @@
+import { AST, ASTPlugin, ASTPluginEnvironment } from '@glimmer/syntax';
+import { Builders } from '../types';
+
/**
@module ember
*/
@@ -23,14 +26,14 @@
@class TransformInputTypeSyntax
*/
-export default function transformInputTypeSyntax(env) {
+export default function transformInputTypeSyntax(env: ASTPluginEnvironment): ASTPlugin {
let b = env.syntax.builders;
return {
name: 'transform-input-type-syntax',
visitor: {
- MustacheStatement(node) {
+ MustacheStatement(node: AST.MustacheStatement) {
if (isInput(node)) {
insertTypeHelperParameter(node, b);
}
@@ -39,11 +42,11 @@ export default function transformInputTypeSyntax(env) {
};
}
-function isInput(node) {
+function isInput(node: AST.MustacheStatement) {
return node.path.original === 'input';
}
-function insertTypeHelperParameter(node, builders) {
+function insertTypeHelperParameter(node: AST.MustacheStatement, builders: Builders) {
let pairs = node.hash.pairs;
let pair = null;
for (let i = 0; i < pairs.length; i++) {
@@ -53,6 +56,6 @@ function insertTypeHelperParameter(node, builders) {
}
}
if (pair && pair.value.type !== 'StringLiteral') {
- node.params.unshift(builders.sexpr('-input-type', [pair.value], null, pair.loc));
+ node.params.unshift(builders.sexpr('-input-type', [pair.value], undefined, pair.loc));
}
}
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/plugins/transform-old-binding-syntax.ts
|
@@ -1,22 +1,26 @@
import { assert, deprecate } from '@ember/debug';
import { BINDING_SUPPORT } from '@ember/deprecated-features';
+import { AST, ASTPlugin, ASTPluginEnvironment } from '@glimmer/syntax';
import calculateLocationDisplay from '../system/calculate-location-display';
-export default function transformOldBindingSyntax(env) {
+export default function transformOldBindingSyntax(
+ env: ASTPluginEnvironment
+): ASTPlugin | undefined {
if (BINDING_SUPPORT) {
let { moduleName } = env.meta;
let b = env.syntax.builders;
- let exprToString = expr => {
+ let exprToString = (expr: AST.Expression) => {
switch (expr.type) {
case 'StringLiteral':
return `"${expr.original}"`;
case 'PathExpression':
return expr.original;
}
+ return '';
};
- let processHash = node => {
+ let processHash = (node: AST.BlockStatement | AST.MustacheStatement) => {
for (let i = 0; i < node.hash.pairs.length; i++) {
let pair = node.hash.pairs[i];
let { key, value } = pair;
@@ -38,7 +42,9 @@ export default function transformOldBindingSyntax(env) {
deprecate(
`You're using legacy binding syntax: ${key}=${exprToString(
value
- )} ${sourceInformation}. Please replace with ${newKey}=${value.original}`,
+ )} ${sourceInformation}. Please replace with ${newKey}=${
+ (value as AST.PathExpression).original
+ }`,
false,
{
id: 'ember-template-compiler.transform-old-binding-syntax',
@@ -63,4 +69,5 @@ export default function transformOldBindingSyntax(env) {
},
};
}
+ return undefined;
}
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/plugins/transform-old-class-binding-syntax.ts
|
@@ -1,25 +1,28 @@
-export default function transformOldClassBindingSyntax(env) {
+import { AST, ASTPlugin, ASTPluginEnvironment } from '@glimmer/syntax';
+import { Builders } from '../types';
+
+export default function transformOldClassBindingSyntax(env: ASTPluginEnvironment): ASTPlugin {
let b = env.syntax.builders;
return {
name: 'transform-old-class-binding-syntax',
visitor: {
- MustacheStatement(node) {
+ MustacheStatement(node: AST.MustacheStatement) {
process(b, node);
},
- BlockStatement(node) {
+ BlockStatement(node: AST.BlockStatement) {
process(b, node);
},
},
};
}
-function process(b, node) {
- let allOfTheMicrosyntaxes = [];
- let allOfTheMicrosyntaxIndexes = [];
- let classPair;
+function process(b: Builders, node: AST.BlockStatement | AST.MustacheStatement) {
+ let allOfTheMicrosyntaxes: AST.HashPair[] = [];
+ let allOfTheMicrosyntaxIndexes: number[] = [];
+ let classPair: AST.HashPair | undefined;
each(node.hash.pairs, (pair, index) => {
let { key } = pair;
@@ -36,13 +39,13 @@ function process(b, node) {
return;
}
- let classValue = [];
+ let classValue: AST.Expression[] = [];
if (classPair) {
classValue.push(classPair.value);
classValue.push(b.string(' '));
} else {
- classPair = b.pair('class', null);
+ classPair = b.pair('class', null as any);
node.hash.pairs.push(classPair);
}
@@ -51,7 +54,7 @@ function process(b, node) {
});
each(allOfTheMicrosyntaxes, ({ value }) => {
- let sexprs = [];
+ let sexprs: AST.Expression[] = [];
// TODO: add helpful deprecation when both `classNames` and `classNameBindings` can
// be removed.
@@ -68,7 +71,7 @@ function process(b, node) {
classPair.value = b.sexpr(b.path('concat'), classValue, hash);
}
-function buildSexprs(microsyntax, sexprs, b) {
+function buildSexprs(microsyntax: string[][], sexprs: AST.Expression[], b: Builders) {
for (let i = 0; i < microsyntax.length; i++) {
let [propName, activeClass, inactiveClass] = microsyntax[i];
let sexpr;
@@ -77,7 +80,7 @@ function buildSexprs(microsyntax, sexprs, b) {
if (propName === '') {
sexpr = b.string(activeClass);
} else {
- let params = [b.path(propName)];
+ let params: AST.Expression[] = [b.path(propName)];
if (activeClass || activeClass === '') {
params.push(b.string(activeClass));
@@ -108,18 +111,19 @@ function buildSexprs(microsyntax, sexprs, b) {
}
}
-function each(list, callback) {
+function each<T>(list: T[], callback: (t: T, i: number) => void) {
for (let i = 0; i < list.length; i++) {
callback(list[i], i);
}
}
-function parseMicrosyntax(string) {
+function parseMicrosyntax(string: string): string[][] {
let segments = string.split(' ');
+ let ret: string[][] = [];
for (let i = 0; i < segments.length; i++) {
- segments[i] = segments[i].split(':');
+ ret[i] = segments[i].split(':');
}
- return segments;
+ return ret;
}
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/plugins/transform-quoted-bindings-into-just-bindings.ts
|
@@ -1,22 +1,24 @@
-export default function transformQuotedBindingsIntoJustBindings(/* env */) {
+import { AST, ASTPlugin } from '@glimmer/syntax';
+
+export default function transformQuotedBindingsIntoJustBindings(/* env */): ASTPlugin {
return {
name: 'transform-quoted-bindings-into-just-bindings',
visitor: {
- ElementNode(node) {
+ ElementNode(node: AST.ElementNode) {
let styleAttr = getStyleAttr(node);
if (!validStyleAttr(styleAttr)) {
return;
}
- styleAttr.value = styleAttr.value.parts[0];
+ styleAttr!.value = (styleAttr!.value as AST.ConcatStatement).parts[0];
},
},
};
}
-function validStyleAttr(attr) {
+function validStyleAttr(attr: AST.AttrNode | undefined) {
if (!attr) {
return false;
}
@@ -32,12 +34,13 @@ function validStyleAttr(attr) {
return onlyPart.type === 'MustacheStatement';
}
-function getStyleAttr(node) {
+function getStyleAttr(node: AST.ElementNode): AST.AttrNode | undefined {
let attributes = node.attributes;
for (let i = 0; i < attributes.length; i++) {
if (attributes[i].name === 'style') {
return attributes[i];
}
}
+ return undefined;
}
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/plugins/transform-top-level-components.ts
|
@@ -1,10 +1,12 @@
-export default function transformTopLevelComponent(/* env */) {
+import { AST, ASTPlugin } from '@glimmer/syntax';
+
+export default function transformTopLevelComponent(/* env */): ASTPlugin {
return {
name: 'transform-top-level-component',
visitor: {
- Program(node) {
- hasSingleComponentNode(node, component => {
+ Program(node: AST.Program) {
+ hasSingleComponentNode(node, (component: any) => {
component.tag = `@${component.tag}`;
component.isStatic = true;
});
@@ -13,7 +15,10 @@ export default function transformTopLevelComponent(/* env */) {
};
}
-function hasSingleComponentNode(program, componentCallback) {
+function hasSingleComponentNode(
+ program: AST.Program,
+ componentCallback: (component: any) => void
+): boolean | void {
let { loc, body } = program;
if (!loc || loc.start.line !== 1 || loc.start.column !== 0) {
return;
@@ -35,7 +40,7 @@ function hasSingleComponentNode(program, componentCallback) {
return false;
}
- if (curr.type === 'ComponentNode' || curr.type === 'ElementNode') {
+ if (curr.type === ('ComponentNode' as any) || curr.type === 'ElementNode') {
lastComponentNode = curr;
}
}
@@ -44,7 +49,7 @@ function hasSingleComponentNode(program, componentCallback) {
return;
}
- if (lastComponentNode.type === 'ComponentNode') {
+ if (lastComponentNode.type === ('ComponentNode' as any)) {
componentCallback(lastComponentNode);
}
}
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/system/bootstrap.ts
|
@@ -4,6 +4,12 @@
import compile from './compile';
+export interface BootstrapOptions {
+ context?: NodeSelector;
+ hasTemplate(templateName: string): boolean;
+ setTemplate(templateName: string, template: string): void;
+}
+
/**
Find templates stored in the head tag as script tags and make them available
to `Ember.CoreView` in the global `Ember.TEMPLATES` object.
@@ -17,7 +23,7 @@ import compile from './compile';
@static
@param ctx
*/
-function bootstrap({ context, hasTemplate, setTemplate }) {
+function bootstrap({ context, hasTemplate, setTemplate }: BootstrapOptions) {
if (!context) {
context = document;
}
@@ -49,7 +55,7 @@ function bootstrap({ context, hasTemplate, setTemplate }) {
setTemplate(templateName, template);
// Remove script tag from DOM.
- script.parentNode.removeChild(script);
+ script.parentNode!.removeChild(script);
}
}
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/system/calculate-location-display.js
|
@@ -1,21 +0,0 @@
-export default function calculateLocationDisplay(moduleName, loc = {}) {
- let { column, line } = loc.start || {};
- let moduleInfo = '';
- if (moduleName) {
- moduleInfo += `'${moduleName}' `;
- }
-
- if (line !== undefined && column !== undefined) {
- if (moduleName) {
- // only prepend @ if the moduleName was present
- moduleInfo += '@ ';
- }
- moduleInfo += `L${line}:C${column}`;
- }
-
- if (moduleInfo) {
- moduleInfo = `(${moduleInfo}) `;
- }
-
- return moduleInfo;
-}
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/system/calculate-location-display.ts
|
@@ -0,0 +1,28 @@
+import { AST } from '@glimmer/syntax';
+
+export default function calculateLocationDisplay(
+ moduleName: string,
+ loc?: AST.SourceLocation | undefined
+): string {
+ let moduleInfo = '';
+ if (moduleName) {
+ moduleInfo += `'${moduleName}' `;
+ }
+
+ if (loc) {
+ let { column, line } = loc.start || { line: undefined, column: undefined };
+ if (line !== undefined && column !== undefined) {
+ if (moduleName) {
+ // only prepend @ if the moduleName was present
+ moduleInfo += '@ ';
+ }
+ moduleInfo += `L${line}:C${column}`;
+ }
+ }
+
+ if (moduleInfo) {
+ moduleInfo = `(${moduleInfo}) `;
+ }
+
+ return moduleInfo;
+}
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/system/compile-options.ts
|
@@ -1,9 +1,24 @@
import { assign } from '@ember/polyfills';
-import PLUGINS from '../plugins/index';
+import { PrecompileOptions } from '@glimmer/compiler';
+import { AST, ASTPlugin, ASTPluginEnvironment, Syntax } from '@glimmer/syntax';
+import PLUGINS, { APluginFunc } from '../plugins/index';
-let USER_PLUGINS = [];
+type PluginFunc = APluginFunc & {
+ __raw?: LegacyPluginClass | undefined;
+};
+let USER_PLUGINS: PluginFunc[] = [];
-export default function compileOptions(_options) {
+interface Plugins {
+ ast: PluginFunc[];
+}
+
+export interface CompileOptions {
+ meta?: any;
+ moduleName?: string | undefined;
+ plugins?: Plugins | undefined;
+}
+
+export default function compileOptions(_options: Partial<CompileOptions>): PrecompileOptions {
let options = assign({ meta: {} }, _options);
// move `moduleName` into `meta` property
@@ -18,28 +33,34 @@ export default function compileOptions(_options) {
let potententialPugins = [...USER_PLUGINS, ...PLUGINS];
let providedPlugins = options.plugins.ast.map(plugin => wrapLegacyPluginIfNeeded(plugin));
let pluginsToAdd = potententialPugins.filter(plugin => {
- return options.plugins.ast.indexOf(plugin) === -1;
+ return options.plugins!.ast.indexOf(plugin) === -1;
});
options.plugins.ast = providedPlugins.concat(pluginsToAdd);
}
return options;
}
-function wrapLegacyPluginIfNeeded(_plugin) {
+interface LegacyPlugin {
+ transform(node: AST.Program): AST.Node;
+ syntax: Syntax;
+}
+type LegacyPluginClass = new (env: ASTPluginEnvironment) => LegacyPlugin;
+
+function wrapLegacyPluginIfNeeded(_plugin: PluginFunc | LegacyPluginClass): PluginFunc {
let plugin = _plugin;
if (_plugin.prototype && _plugin.prototype.transform) {
- plugin = env => {
+ const pluginFunc: PluginFunc = (env: ASTPluginEnvironment): ASTPlugin => {
let pluginInstantiated = false;
return {
name: _plugin.constructor && _plugin.constructor.name,
visitor: {
- Program(node) {
+ Program(node: AST.Program): AST.Node | void {
if (!pluginInstantiated) {
pluginInstantiated = true;
- let plugin = new _plugin(env);
+ let plugin = new (_plugin as LegacyPluginClass)(env);
plugin.syntax = env.syntax;
@@ -50,13 +71,14 @@ function wrapLegacyPluginIfNeeded(_plugin) {
};
};
- plugin.__raw = _plugin;
+ pluginFunc.__raw = _plugin as LegacyPluginClass;
+ plugin = pluginFunc;
}
- return plugin;
+ return plugin as PluginFunc;
}
-export function registerPlugin(type, _plugin) {
+export function registerPlugin(type: string, _plugin: PluginFunc | LegacyPluginClass) {
if (type !== 'ast') {
throw new Error(
`Attempting to register ${_plugin} as "${type}" which is not a valid Glimmer plugin type.`
@@ -75,7 +97,7 @@ export function registerPlugin(type, _plugin) {
USER_PLUGINS = [plugin, ...USER_PLUGINS];
}
-export function unregisterPlugin(type, PluginClass) {
+export function unregisterPlugin(type: string, PluginClass: PluginFunc | LegacyPluginClass) {
if (type !== 'ast') {
throw new Error(
`Attempting to unregister ${PluginClass} as "${type}" which is not a valid Glimmer plugin type.`
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/system/compile.ts
|
@@ -2,8 +2,10 @@
@module ember
*/
import require, { has } from 'require';
+import { CompileOptions } from './compile-options';
import precompile from './precompile';
-let template;
+
+let template: (templateJS: () => string) => string;
/**
Uses HTMLBars `compile` function to process a string into a compiled template.
@@ -15,8 +17,9 @@ let template;
@param {String} templateString This is the string to be compiled by HTMLBars.
@param {Object} options This is an options hash to augment the compiler options.
*/
-export default function compile(templateString, options) {
+export default function compile(templateString: string, options: CompileOptions) {
if (!template && has('ember-glimmer')) {
+ // tslint:disable-next-line:no-require-imports
template = require('ember-glimmer').template;
}
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/system/initializer.ts
|
@@ -3,6 +3,7 @@ import bootstrap from './bootstrap';
// Globals mode template compiler
if (has('@ember/application') && has('ember-browser-environment') && has('ember-glimmer')) {
+ // tslint:disable:no-require-imports
let emberEnv = require('ember-browser-environment');
let emberGlimmer = require('ember-glimmer');
let emberApp = require('@ember/application');
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/system/precompile.ts
|
@@ -2,8 +2,8 @@
@module ember
*/
-import compileOptions from './compile-options';
import { precompile as glimmerPrecompile } from '@glimmer/compiler';
+import compileOptions, { CompileOptions } from './compile-options';
/**
Uses HTMLBars `compile` function to process a string into a compiled template string.
@@ -15,6 +15,6 @@ import { precompile as glimmerPrecompile } from '@glimmer/compiler';
@method precompile
@param {String} templateString This is the string to be compiled by HTMLBars.
*/
-export default function precompile(templateString, options) {
+export default function precompile(templateString: string, options: CompileOptions): string {
return glimmerPrecompile(templateString, compileOptions(options));
}
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/ember-template-compiler/lib/types.d.ts
|
@@ -0,0 +1,3 @@
+import { builders } from '@glimmer/syntax';
+
+export type Builders = typeof builders;
| true |
Other
|
emberjs
|
ember.js
|
1d5c964aa3e0bb3eb2c90138d77a01fc49eda033.json
|
convert ember-template-compiler to typescript
|
packages/node-module/require.d.ts
|
@@ -0,0 +1,4 @@
+declare module 'require' {
+ export function has(path: string): boolean;
+ export default function require(path: string): any;
+}
| true |
Other
|
emberjs
|
ember.js
|
647ae44b8f130b79689d10a47041897c5da20a53.json
|
Add AST transform to validate `...attributes`.
|
packages/ember-template-compiler/lib/plugins/assert-splattribute-expression.js
|
@@ -0,0 +1,33 @@
+import { assert } from '@ember/debug';
+import calculateLocationDisplay from '../system/calculate-location-display';
+import { EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION } from '@ember/canary-features';
+
+export default function assertSplattributeExpressions(env) {
+ let { moduleName } = env.meta;
+
+ return {
+ name: 'assert-splattribute-expressions',
+
+ visitor: {
+ AttrNode({ name, loc }) {
+ if (!EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION && name === '...attributes') {
+ assert(`${errorMessage()} ${calculateLocationDisplay(moduleName, loc)}`);
+ }
+ },
+
+ PathExpression({ original, loc }) {
+ if (original === '...attributes') {
+ assert(`${errorMessage()} ${calculateLocationDisplay(moduleName, loc)}`);
+ }
+ },
+ },
+ };
+}
+
+function errorMessage() {
+ if (EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) {
+ return `Using "...attributes" can only be used in the element position e.g. <div ...attributes />. It cannot be used as a path.`;
+ }
+
+ return `...attributes is an invalid path`;
+}
| true |
Other
|
emberjs
|
ember.js
|
647ae44b8f130b79689d10a47041897c5da20a53.json
|
Add AST transform to validate `...attributes`.
|
packages/ember-template-compiler/lib/plugins/index.js
|
@@ -16,6 +16,7 @@ import TransformDotComponentInvocation from './transform-dot-component-invocatio
import AssertInputHelperWithoutBlock from './assert-input-helper-without-block';
import TransformInElement from './transform-in-element';
import AssertIfHelperWithoutArguments from './assert-if-helper-without-arguments';
+import AssertSplattributeExpressions from './assert-splattribute-expression';
const transforms = [
TransformDotComponentInvocation,
@@ -36,6 +37,7 @@ const transforms = [
AssertInputHelperWithoutBlock,
TransformInElement,
AssertIfHelperWithoutArguments,
+ AssertSplattributeExpressions,
];
export default Object.freeze(transforms);
| true |
Other
|
emberjs
|
ember.js
|
647ae44b8f130b79689d10a47041897c5da20a53.json
|
Add AST transform to validate `...attributes`.
|
packages/ember-template-compiler/tests/plugins/assert-splattribute-expression-test.js
|
@@ -0,0 +1,58 @@
+import { EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION } from '@ember/canary-features';
+import { moduleFor, AbstractTestCase } from 'internal-test-helpers';
+import { compile } from '../../index';
+
+moduleFor(
+ 'ember-template-compiler: assert-splattribute-expression',
+ class extends AbstractTestCase {
+ '@feature(EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) ...attributes is valid in element space'(
+ assert
+ ) {
+ assert.expect(0);
+
+ compile('<div ...attributes>Foo</div>');
+ }
+
+ '@test ...attributes is not valid in element space'(assert) {
+ if (EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) {
+ assert.expect(0);
+
+ compile('<div ...attributes>Foo</div>');
+ } else {
+ expectAssertion(() => {
+ compile('<div ...attributes>Foo</div>');
+ }, `...attributes is an invalid path (L1:C5) `);
+ }
+ }
+
+ '@feature(EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) {{...attributes}} is not valid'() {
+ expectAssertion(() => {
+ compile('<div>{{...attributes}}</div>', {
+ moduleName: 'foo-bar',
+ });
+ }, `Using "...attributes" can only be used in the element position e.g. <div ...attributes />. It cannot be used as a path. ('foo-bar' @ L1:C7) `);
+ }
+
+ '@feature(EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) {{...attributes}} is not valid path expression'() {
+ expectAssertion(() => {
+ compile('<div>{{...attributes}}</div>', {
+ moduleName: 'foo-bar',
+ });
+ }, `Using "...attributes" can only be used in the element position e.g. <div ...attributes />. It cannot be used as a path. ('foo-bar' @ L1:C7) `);
+ }
+ '@feature(EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) {{...attributes}} is not valid modifier'() {
+ expectAssertion(() => {
+ compile('<div {{...attributes}}>Wat</div>', {
+ moduleName: 'foo-bar',
+ });
+ }, `Using "...attributes" can only be used in the element position e.g. <div ...attributes />. It cannot be used as a path. ('foo-bar' @ L1:C7) `);
+ }
+ '@feature(EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) {{...attributes}} is not valid attribute'() {
+ expectAssertion(() => {
+ compile('<div class={{...attributes}}>Wat</div>', {
+ moduleName: 'foo-bar',
+ });
+ }, `Using "...attributes" can only be used in the element position e.g. <div ...attributes />. It cannot be used as a path. ('foo-bar' @ L1:C13) `);
+ }
+ }
+);
| true |
Other
|
emberjs
|
ember.js
|
fad23096407e44fd74a8183ca227eed7a22d18f3.json
|
Add more tests for angle bracket invocation.
|
packages/ember-glimmer/tests/integration/components/angle-bracket-invocation-test.js
|
@@ -1,10 +1,13 @@
import { moduleFor, RenderingTest } from '../../utils/test-case';
+import { set } from 'ember-metal';
import { Component } from '../../utils/helpers';
+import { strip } from '../../utils/abstract-test-case';
+import { classes } from '../../utils/test-helpers';
moduleFor(
'AngleBracket Invocation',
class extends RenderingTest {
- '@test it can render a basic template only component'() {
+ '@feature(EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) it can render a basic template only component'() {
this.registerComponent('foo-bar', { template: 'hello' });
this.render('<FooBar />');
@@ -16,7 +19,7 @@ moduleFor(
this.assertComponentElement(this.firstChild, { content: 'hello' });
}
- '@test it can render a basic component with template and javascript'() {
+ '@feature(EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) it can render a basic component with template and javascript'() {
this.registerComponent('foo-bar', {
template: 'FIZZ BAR {{local}}',
ComponentClass: Component.extend({ local: 'hey' }),
@@ -26,5 +29,538 @@ moduleFor(
this.assertComponentElement(this.firstChild, { content: 'FIZZ BAR hey' });
}
+
+ '@feature(EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) it can render a single word component name'() {
+ this.registerComponent('foo', { template: 'hello' });
+
+ this.render('<Foo />');
+
+ this.assertComponentElement(this.firstChild, { content: 'hello' });
+
+ this.runTask(() => this.rerender());
+
+ this.assertComponentElement(this.firstChild, { content: 'hello' });
+ }
+
+ '@feature(EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) it can not render a component name without initial capital letter'(
+ assert
+ ) {
+ this.registerComponent('div', {
+ ComponentClass: Component.extend({
+ init() {
+ assert.ok(false, 'should not have created component');
+ },
+ }),
+ });
+
+ this.render('<div></div>');
+
+ this.assertElement(this.firstChild, { tagName: 'div', content: '' });
+ }
+
+ '@feature(EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) it can have a custom id and it is not bound'() {
+ this.registerComponent('foo-bar', { template: '{{id}} {{elementId}}' });
+
+ this.render('<FooBar @id={{customId}} />', {
+ customId: 'bizz',
+ });
+
+ this.assertComponentElement(this.firstChild, {
+ tagName: 'div',
+ attrs: { id: 'bizz' },
+ content: 'bizz bizz',
+ });
+
+ this.runTask(() => this.rerender());
+
+ this.assertComponentElement(this.firstChild, {
+ tagName: 'div',
+ attrs: { id: 'bizz' },
+ content: 'bizz bizz',
+ });
+
+ this.runTask(() => set(this.context, 'customId', 'bar'));
+
+ this.assertComponentElement(this.firstChild, {
+ tagName: 'div',
+ attrs: { id: 'bizz' },
+ content: 'bar bizz',
+ });
+
+ this.runTask(() => set(this.context, 'customId', 'bizz'));
+
+ this.assertComponentElement(this.firstChild, {
+ tagName: 'div',
+ attrs: { id: 'bizz' },
+ content: 'bizz bizz',
+ });
+ }
+
+ '@feature(EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) it can have a custom tagName'() {
+ let FooBarComponent = Component.extend({
+ tagName: 'foo-bar',
+ });
+
+ this.registerComponent('foo-bar', {
+ ComponentClass: FooBarComponent,
+ template: 'hello',
+ });
+
+ this.render('<FooBar></FooBar>');
+
+ this.assertComponentElement(this.firstChild, {
+ tagName: 'foo-bar',
+ content: 'hello',
+ });
+
+ this.runTask(() => this.rerender());
+
+ this.assertComponentElement(this.firstChild, {
+ tagName: 'foo-bar',
+ content: 'hello',
+ });
+ }
+
+ '@feature(EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) it can have a custom tagName from the invocation'() {
+ this.registerComponent('foo-bar', { template: 'hello' });
+
+ this.render('<FooBar @tagName="foo-bar" />');
+
+ this.assertComponentElement(this.firstChild, {
+ tagName: 'foo-bar',
+ content: 'hello',
+ });
+
+ this.runTask(() => this.rerender());
+
+ this.assertComponentElement(this.firstChild, {
+ tagName: 'foo-bar',
+ content: 'hello',
+ });
+ }
+
+ '@feature(EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) it can have custom classNames'() {
+ let FooBarComponent = Component.extend({
+ classNames: ['foo', 'bar'],
+ });
+
+ this.registerComponent('foo-bar', {
+ ComponentClass: FooBarComponent,
+ template: 'hello',
+ });
+
+ this.render('<FooBar />');
+
+ this.assertComponentElement(this.firstChild, {
+ tagName: 'div',
+ attrs: { class: classes('ember-view foo bar') },
+ content: 'hello',
+ });
+
+ this.runTask(() => this.rerender());
+
+ this.assertComponentElement(this.firstChild, {
+ tagName: 'div',
+ attrs: { class: classes('ember-view foo bar') },
+ content: 'hello',
+ });
+ }
+
+ '@feature(EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) class property on components can be dynamic'() {
+ this.registerComponent('foo-bar', { template: 'hello' });
+
+ this.render('<FooBar @class={{if fooBar "foo-bar"}} />', {
+ fooBar: true,
+ });
+
+ this.assertComponentElement(this.firstChild, {
+ content: 'hello',
+ attrs: { class: classes('ember-view foo-bar') },
+ });
+
+ this.runTask(() => this.rerender());
+
+ this.assertComponentElement(this.firstChild, {
+ content: 'hello',
+ attrs: { class: classes('ember-view foo-bar') },
+ });
+
+ this.runTask(() => set(this.context, 'fooBar', false));
+
+ this.assertComponentElement(this.firstChild, {
+ content: 'hello',
+ attrs: { class: classes('ember-view') },
+ });
+
+ this.runTask(() => set(this.context, 'fooBar', true));
+
+ this.assertComponentElement(this.firstChild, {
+ content: 'hello',
+ attrs: { class: classes('ember-view foo-bar') },
+ });
+ }
+
+ '@feature(EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) it can set custom classNames from the invocation'() {
+ let FooBarComponent = Component.extend({
+ classNames: ['foo'],
+ });
+
+ this.registerComponent('foo-bar', {
+ ComponentClass: FooBarComponent,
+ template: 'hello',
+ });
+
+ this.render(strip`
+ <FooBar @class="bar baz" />
+ <FooBar @classNames="bar baz" />
+ <FooBar />
+ `);
+
+ this.assertComponentElement(this.nthChild(0), {
+ tagName: 'div',
+ attrs: { class: classes('ember-view foo bar baz') },
+ content: 'hello',
+ });
+ this.assertComponentElement(this.nthChild(1), {
+ tagName: 'div',
+ attrs: { class: classes('ember-view foo bar baz') },
+ content: 'hello',
+ });
+ this.assertComponentElement(this.nthChild(2), {
+ tagName: 'div',
+ attrs: { class: classes('ember-view foo') },
+ content: 'hello',
+ });
+
+ this.runTask(() => this.rerender());
+
+ this.assertComponentElement(this.nthChild(0), {
+ tagName: 'div',
+ attrs: { class: classes('ember-view foo bar baz') },
+ content: 'hello',
+ });
+ this.assertComponentElement(this.nthChild(1), {
+ tagName: 'div',
+ attrs: { class: classes('ember-view foo bar baz') },
+ content: 'hello',
+ });
+ this.assertComponentElement(this.nthChild(2), {
+ tagName: 'div',
+ attrs: { class: classes('ember-view foo') },
+ content: 'hello',
+ });
+ }
+
+ '@feature(EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) it has an element'() {
+ let instance;
+
+ let FooBarComponent = Component.extend({
+ init() {
+ this._super();
+ instance = this;
+ },
+ });
+
+ this.registerComponent('foo-bar', {
+ ComponentClass: FooBarComponent,
+ template: 'hello',
+ });
+
+ this.render('<FooBar></FooBar>');
+
+ let element1 = instance.element;
+
+ this.assertComponentElement(element1, { content: 'hello' });
+
+ this.runTask(() => this.rerender());
+
+ let element2 = instance.element;
+
+ this.assertComponentElement(element2, { content: 'hello' });
+
+ this.assertSameNode(element2, element1);
+ }
+
+ '@feature(EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) it has the right parentView and childViews'(
+ assert
+ ) {
+ let fooBarInstance, fooBarBazInstance;
+
+ let FooBarComponent = Component.extend({
+ init() {
+ this._super();
+ fooBarInstance = this;
+ },
+ });
+
+ let FooBarBazComponent = Component.extend({
+ init() {
+ this._super();
+ fooBarBazInstance = this;
+ },
+ });
+
+ this.registerComponent('foo-bar', {
+ ComponentClass: FooBarComponent,
+ template: 'foo-bar {{foo-bar-baz}}',
+ });
+ this.registerComponent('foo-bar-baz', {
+ ComponentClass: FooBarBazComponent,
+ template: 'foo-bar-baz',
+ });
+
+ this.render('<FooBar />');
+ this.assertText('foo-bar foo-bar-baz');
+
+ assert.equal(fooBarInstance.parentView, this.component);
+ assert.equal(fooBarBazInstance.parentView, fooBarInstance);
+
+ assert.deepEqual(this.component.childViews, [fooBarInstance]);
+ assert.deepEqual(fooBarInstance.childViews, [fooBarBazInstance]);
+
+ this.runTask(() => this.rerender());
+ this.assertText('foo-bar foo-bar-baz');
+
+ assert.equal(fooBarInstance.parentView, this.component);
+ assert.equal(fooBarBazInstance.parentView, fooBarInstance);
+
+ assert.deepEqual(this.component.childViews, [fooBarInstance]);
+ assert.deepEqual(fooBarInstance.childViews, [fooBarBazInstance]);
+ }
+
+ '@feature(EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) it renders passed named arguments'() {
+ this.registerComponent('foo-bar', {
+ template: '{{@foo}}',
+ });
+
+ this.render('<FooBar @foo={{model.bar}} />', {
+ model: {
+ bar: 'Hola',
+ },
+ });
+
+ this.assertText('Hola');
+
+ this.runTask(() => this.rerender());
+
+ this.assertText('Hola');
+
+ this.runTask(() => this.context.set('model.bar', 'Hello'));
+
+ this.assertText('Hello');
+
+ this.runTask(() => this.context.set('model', { bar: 'Hola' }));
+
+ this.assertText('Hola');
+ }
+
+ '@feature(EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) it reflects named arguments as properties'() {
+ this.registerComponent('foo-bar', {
+ template: '{{foo}}',
+ });
+
+ this.render('<FooBar @foo={{model.bar}} />', {
+ model: {
+ bar: 'Hola',
+ },
+ });
+
+ this.assertText('Hola');
+
+ this.runTask(() => this.rerender());
+
+ this.assertText('Hola');
+
+ this.runTask(() => this.context.set('model.bar', 'Hello'));
+
+ this.assertText('Hello');
+
+ this.runTask(() => this.context.set('model', { bar: 'Hola' }));
+
+ this.assertText('Hola');
+ }
+
+ '@feature(EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) it can render a basic component with a block'() {
+ this.registerComponent('foo-bar', {
+ template: '{{yield}} - In component',
+ });
+
+ this.render('<FooBar>hello</FooBar>');
+
+ this.assertComponentElement(this.firstChild, {
+ content: 'hello - In component',
+ });
+
+ this.runTask(() => this.rerender());
+
+ this.assertComponentElement(this.firstChild, {
+ content: 'hello - In component',
+ });
+ }
+
+ '@feature(EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) it can yield internal and external properties positionally'() {
+ let instance;
+
+ let FooBarComponent = Component.extend({
+ init() {
+ this._super(...arguments);
+ instance = this;
+ },
+ greeting: 'hello',
+ });
+
+ this.registerComponent('foo-bar', {
+ ComponentClass: FooBarComponent,
+ template: '{{yield greeting greetee.firstName}}',
+ });
+
+ this.render(
+ '<FooBar @greetee={{person}} as |greeting name|>{{name}} {{person.lastName}}, {{greeting}}</FooBar>',
+ {
+ person: {
+ firstName: 'Joel',
+ lastName: 'Kang',
+ },
+ }
+ );
+
+ this.assertComponentElement(this.firstChild, {
+ content: 'Joel Kang, hello',
+ });
+
+ this.runTask(() => this.rerender());
+
+ this.assertComponentElement(this.firstChild, {
+ content: 'Joel Kang, hello',
+ });
+
+ this.runTask(() =>
+ set(this.context, 'person', {
+ firstName: 'Dora',
+ lastName: 'the Explorer',
+ })
+ );
+
+ this.assertComponentElement(this.firstChild, {
+ content: 'Dora the Explorer, hello',
+ });
+
+ this.runTask(() => set(instance, 'greeting', 'hola'));
+
+ this.assertComponentElement(this.firstChild, {
+ content: 'Dora the Explorer, hola',
+ });
+
+ this.runTask(() => {
+ set(instance, 'greeting', 'hello');
+ set(this.context, 'person', {
+ firstName: 'Joel',
+ lastName: 'Kang',
+ });
+ });
+
+ this.assertComponentElement(this.firstChild, {
+ content: 'Joel Kang, hello',
+ });
+ }
+
+ '@feature(EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) positional parameters are not allowed'() {
+ this.registerComponent('sample-component', {
+ ComponentClass: Component.extend().reopenClass({
+ positionalParams: ['name', 'age'],
+ }),
+ template: '{{name}}{{age}}',
+ });
+
+ // this is somewhat silly as the browser "corrects" for these as
+ // attribute names, but regardless the thing we care about here is that
+ // they are **not** used as positional params
+ this.render('<SampleComponent Quint 4 />');
+
+ this.assertText('');
+ }
+
+ '@skip @feature(EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) can invoke curried components with capitalized block param names'() {
+ this.registerComponent('foo-bar', { template: 'hello' });
+
+ this.render(strip`
+ {{#with (component 'foo-bar') as |Other|}}
+ <Other />
+ {{/with}}
+ `);
+
+ this.assertComponentElement(this.firstChild, { content: 'hello' });
+
+ this.runTask(() => this.rerender());
+
+ this.assertComponentElement(this.firstChild, { content: 'hello' });
+
+ this.assertStableRerender();
+ }
+
+ '@skip @feature(EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) has-block'() {
+ this.registerComponent('check-block', {
+ template: strip`
+ {{#if (has-block)}}
+ Yes
+ {{else}}
+ No
+ {{/if}}`,
+ });
+
+ this.render(strip`
+ <CheckBlock />
+ <CheckBlock></CheckBlock>`);
+
+ this.assertComponentElement(this.firstChild, { content: 'No' });
+ this.assertComponentElement(this.nthChild(1), { content: 'Yes' });
+
+ this.assertStableRerender();
+ }
+
+ '@skip @feature(EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION) includes invocation specified attributes in root element ("splattributes")'() {
+ this.registerComponent('foo-bar', {
+ ComponentClass: Component.extend(),
+ template: 'hello',
+ });
+
+ this.render('<FooBar data-foo={{foo}} data-bar={{bar}} />', { foo: 'foo', bar: 'bar' });
+
+ this.assertComponentElement(this.firstChild, {
+ tagName: 'div',
+ attrs: { 'data-foo': 'foo', 'data-bar': 'bar' },
+ content: 'hello',
+ });
+
+ this.runTask(() => this.rerender());
+
+ this.assertComponentElement(this.firstChild, {
+ tagName: 'div',
+ attrs: { 'data-foo': 'foo', 'data-bar': 'bar' },
+ content: 'hello',
+ });
+
+ this.runTask(() => {
+ set(this.context, 'foo', 'FOO');
+ set(this.context, 'bar', undefined);
+ });
+
+ this.assertComponentElement(this.firstChild, {
+ tagName: 'div',
+ attrs: { 'data-foo': 'FOO' },
+ content: 'hello',
+ });
+
+ this.runTask(() => {
+ set(this.context, 'foo', 'foo');
+ set(this.context, 'bar', 'bar');
+ });
+
+ this.assertComponentElement(this.firstChild, {
+ tagName: 'div',
+ attrs: { 'data-foo': 'foo', 'data-bar': 'bar' },
+ content: 'hello',
+ });
+ }
}
);
| false |
Other
|
emberjs
|
ember.js
|
3313226ff5360fffb498a28fefa463c91ce5adcb.json
|
Remove outdated `features.json` file.
|
features.json
|
@@ -1,47 +0,0 @@
-{
- "deprecations": {
- "container-lookupFactory": "2.12.0",
- "ember-application.injected-container": "2.3.0",
- "ember-application.app-instance-registry": "2.1.0",
- "ember-application.registry-resolver-as-function": "2.3.0",
- "ember-application.app-instance-container": "2.1.0",
- "ember-application.app-initializer-initialize-arguments": "2.1.0",
- "ember-application.validate-type": "1.13.0",
- "ember-debug.deprecate-options-missing": "2.1.0",
- "ember-debug.deprecate-id-missing": "2.1.0",
- "ember-debug.deprecate-until-missing": "2.1.0",
- "ember-debug.warn-options-missing": "2.1.0",
- "ember-debug.warn-id-missing": "2.1.0",
- "ember-routing-views.controller-wrapped-param": "2.0.0",
- "ember-htmlbars.make-bound-helper": "1.13.6",
- "ember-htmlbars.ember-handlebars-safestring": "2.8.0",
- "ember-metal.binding": "2.7.0",
- "ember-views.did-init-attrs": "2.6.0",
- "ember-metal.required": "2.0.0",
- "ember-metal.observer-argument-order": "2.0.0",
- "ember-metal.immediate-observer": "2.0.0",
- "ember-views.render-double-modify": "2.0.0",
- "ember-routing.router-resource": "2.0.0",
- "ember-routing.top-level-render-helper": "2.11.0",
- "ember-runtime.controller-content": "2.16.0",
- "ember-runtime.controller-proxy": "2.0.0",
- "ember-runtime.action-handler-_actions": "2.0.0",
- "ember-runtime.enumerable-contains": "2.7.0",
- "ember-runtime.frozen-copy": "2.0.0",
- "ember-runtime.freezable-init": "2.0.0",
- "ember-string-utils.fmt": "2.0.0",
- "ember-template-compiler.deprecate-render-model": "2.6.0",
- "ember-template-compiler.deprecate-render": "2.11.0",
- "ember-template-compiler.transform-input-on-to-onEvent.dynamic-value": "2.1.0",
- "ember-template-compiler.transform-input-on-to-onEvent.no-action": "2.1.0",
- "ember-template-compiler.transform-input-on-to-onEvent.normalized-on": "2.1.0",
- "ember-template-compiler.transform-old-binding-syntax": "2.1.0",
- "ember-testing.test-waiters": "2.7.0",
- "ember-views.lifecycle-hook-arguments": "2.12.0",
- "ember-views.render-to-element": "2.11.0",
- "ember-metal.ember-k": "2.12.0",
- "ember-metal.ember-backburner": "2.7.0",
- "ember-metal.ember.keys": "1.13.3",
- "ember-metal.ember-create": "1.13.3"
- }
-}
| false |
Other
|
emberjs
|
ember.js
|
2eba9e24867d24bcd469cd539ba41e2bd7ed1bdc.json
|
Wrap Ember.Logger for svelting...
|
packages/@ember/deprecated-features/index.ts
|
@@ -5,3 +5,4 @@ export const DEPRECATE_ID_MISSING = !!'2.1.0-beta.1';
export const DEPRECATE_UNTIL_MISSING = !!'2.1.0-beta.1';
export const RUN_SYNC = !!'3.0.0-beta.4';
export const REGISTRY_RESOLVER_AS_FUNCTION = !!'2.3.0-beta.3';
+export const LOGGER = !!'3.2.0-beta.1';
| true |
Other
|
emberjs
|
ember.js
|
2eba9e24867d24bcd469cd539ba41e2bd7ed1bdc.json
|
Wrap Ember.Logger for svelting...
|
packages/ember-console/index.js
|
@@ -1,4 +1,5 @@
import { deprecate } from '@ember/debug';
+import { LOGGER } from '@ember/deprecated-features';
// Deliver message that the function is deprecated
@@ -9,6 +10,7 @@ const DEPRECATION_URL =
/**
@module ember
*/
+
/**
Inside Ember-Metal, simply uses the methods from `imports.console`.
Override this to provide more robust logging functionality.
@@ -19,8 +21,11 @@ const DEPRECATION_URL =
@namespace Ember
@public
*/
-export default {
- /**
+let DEPRECATED_LOGGER;
+
+if (LOGGER) {
+ DEPRECATED_LOGGER = {
+ /**
Logs the arguments to the console.
You can pass as many arguments as you want and they will be joined together with a space.
@@ -35,16 +40,16 @@ export default {
@param {*} arguments
@public
*/
- log() {
- deprecate(DEPRECATION_MESSAGE, false, {
- id: DEPRECATION_ID,
- until: '4.0.0',
- url: DEPRECATION_URL,
- });
- return console.log(...arguments); // eslint-disable-line no-console
- },
-
- /**
+ log() {
+ deprecate(DEPRECATION_MESSAGE, false, {
+ id: DEPRECATION_ID,
+ until: '4.0.0',
+ url: DEPRECATION_URL,
+ });
+ return console.log(...arguments); // eslint-disable-line no-console
+ },
+
+ /**
Prints the arguments to the console with a warning icon.
You can pass as many arguments as you want and they will be joined together with a space.
@@ -58,16 +63,16 @@ export default {
@param {*} arguments
@public
*/
- warn() {
- deprecate(DEPRECATION_MESSAGE, false, {
- id: DEPRECATION_ID,
- until: '4.0.0',
- url: DEPRECATION_URL,
- });
- return console.warn(...arguments); // eslint-disable-line no-console
- },
-
- /**
+ warn() {
+ deprecate(DEPRECATION_MESSAGE, false, {
+ id: DEPRECATION_ID,
+ until: '4.0.0',
+ url: DEPRECATION_URL,
+ });
+ return console.warn(...arguments); // eslint-disable-line no-console
+ },
+
+ /**
Prints the arguments to the console with an error icon, red text and a stack trace.
You can pass as many arguments as you want and they will be joined together with a space.
@@ -81,16 +86,16 @@ export default {
@param {*} arguments
@public
*/
- error() {
- deprecate(DEPRECATION_MESSAGE, false, {
- id: DEPRECATION_ID,
- until: '4.0.0',
- url: DEPRECATION_URL,
- });
- return console.error(...arguments); // eslint-disable-line no-console
- },
-
- /**
+ error() {
+ deprecate(DEPRECATION_MESSAGE, false, {
+ id: DEPRECATION_ID,
+ until: '4.0.0',
+ url: DEPRECATION_URL,
+ });
+ return console.error(...arguments); // eslint-disable-line no-console
+ },
+
+ /**
Logs the arguments to the console.
You can pass as many arguments as you want and they will be joined together with a space.
@@ -105,16 +110,16 @@ export default {
@param {*} arguments
@public
*/
- info() {
- deprecate(DEPRECATION_MESSAGE, false, {
- id: DEPRECATION_ID,
- until: '4.0.0',
- url: DEPRECATION_URL,
- });
- return console.info(...arguments); // eslint-disable-line no-console
- },
-
- /**
+ info() {
+ deprecate(DEPRECATION_MESSAGE, false, {
+ id: DEPRECATION_ID,
+ until: '4.0.0',
+ url: DEPRECATION_URL,
+ });
+ return console.info(...arguments); // eslint-disable-line no-console
+ },
+
+ /**
Logs the arguments to the console in blue text.
You can pass as many arguments as you want and they will be joined together with a space.
@@ -129,21 +134,21 @@ export default {
@param {*} arguments
@public
*/
- debug() {
- deprecate(DEPRECATION_MESSAGE, false, {
- id: DEPRECATION_ID,
- until: '4.0.0',
- url: DEPRECATION_URL,
- });
- /* eslint-disable no-console */
- if (console.debug) {
- return console.debug(...arguments);
- }
- return console.info(...arguments);
- /* eslint-enable no-console */
- },
-
- /**
+ debug() {
+ deprecate(DEPRECATION_MESSAGE, false, {
+ id: DEPRECATION_ID,
+ until: '4.0.0',
+ url: DEPRECATION_URL,
+ });
+ /* eslint-disable no-console */
+ if (console.debug) {
+ return console.debug(...arguments);
+ }
+ return console.info(...arguments);
+ /* eslint-enable no-console */
+ },
+
+ /**
If the value passed into `Ember.Logger.assert` is not truthy it will throw an error with a stack trace.
```javascript
@@ -158,12 +163,15 @@ export default {
@param {String} message Assertion message on failed
@public
*/
- assert() {
- deprecate(DEPRECATION_MESSAGE, false, {
- id: DEPRECATION_ID,
- until: '4.0.0',
- url: DEPRECATION_URL,
- });
- return console.assert(...arguments); // eslint-disable-line no-console
- },
-};
+ assert() {
+ deprecate(DEPRECATION_MESSAGE, false, {
+ id: DEPRECATION_ID,
+ until: '4.0.0',
+ url: DEPRECATION_URL,
+ });
+ return console.assert(...arguments); // eslint-disable-line no-console
+ },
+ };
+}
+
+export default DEPRECATED_LOGGER;
| true |
Other
|
emberjs
|
ember.js
|
2eba9e24867d24bcd469cd539ba41e2bd7ed1bdc.json
|
Wrap Ember.Logger for svelting...
|
packages/ember/index.js
|
@@ -125,7 +125,7 @@ import Map from '@ember/map';
import MapWithDefault from '@ember/map/with-default';
import OrderedSet from '@ember/map/lib/ordered-set';
import { assign, merge } from '@ember/polyfills';
-import { EMBER_EXTEND_PROTOTYPES } from '@ember/deprecated-features';
+import { LOGGER, EMBER_EXTEND_PROTOTYPES } from '@ember/deprecated-features';
// ****ember-environment****
@@ -355,7 +355,9 @@ Object.defineProperty(Ember, 'testing', {
Ember._Backburner = Backburner;
// ****ember-console****
-Ember.Logger = Logger;
+if (LOGGER) {
+ Ember.Logger = Logger;
+}
// ****ember-runtime****
Ember.A = A;
| true |
Other
|
emberjs
|
ember.js
|
4738688c4cf16734e6356ca5f0a58d8de38e21de.json
|
simplify chain logic
|
packages/ember-metal/lib/chains.ts
|
@@ -273,12 +273,9 @@ class ChainNode {
chains = this._chains;
}
- let maybeNode: ChainNode | undefined = chains[key];
- let node: ChainNode;
- if (maybeNode === undefined) {
+ let node = chains[key];
+ if (node === undefined) {
node = chains[key] = new ChainNode(this, key, undefined);
- } else {
- node = maybeNode;
}
node.count++; // count chains...
| false |
Other
|
emberjs
|
ember.js
|
8e12a0cb2e19bb7bd7a03abf8385d3f3c454d5ff.json
|
Fix module cycle in ember-runtime.
|
packages/ember-runtime/index.js
|
@@ -11,6 +11,8 @@ export {
A,
MutableArray,
removeAt,
+ uniqBy,
+ isArray,
} from './lib/mixins/array';
export { default as Comparable } from './lib/mixins/comparable';
export { default as Namespace } from './lib/system/namespace';
@@ -28,6 +30,6 @@ export { default as Evented } from './lib/mixins/evented';
export { default as PromiseProxyMixin } from './lib/mixins/promise_proxy';
export { default as RSVP, onerrorDefault } from './lib/ext/rsvp'; // just for side effect of extending Ember.RSVP
-export { isArray, typeOf, uniqBy } from './lib/utils';
+export { typeOf } from './lib/type-of';
import './lib/ext/function'; // just for side effect of extending Function.prototype
| true |
Other
|
emberjs
|
ember.js
|
8e12a0cb2e19bb7bd7a03abf8385d3f3c454d5ff.json
|
Fix module cycle in ember-runtime.
|
packages/ember-runtime/lib/compare.js
|
@@ -1,4 +1,4 @@
-import { typeOf } from './utils';
+import { typeOf } from './type-of';
import Comparable from './mixins/comparable';
const TYPE_ORDER = {
| true |
Other
|
emberjs
|
ember.js
|
8e12a0cb2e19bb7bd7a03abf8385d3f3c454d5ff.json
|
Fix module cycle in ember-runtime.
|
packages/ember-runtime/lib/mixins/array.js
|
@@ -2,6 +2,9 @@
@module @ember/array
*/
+import { DEBUG } from '@glimmer/env';
+import { HAS_NATIVE_PROXY } from 'ember-utils';
+import { PROXY_CONTENT } from 'ember-metal';
import { symbol, toString } from 'ember-utils';
import {
get,
@@ -29,7 +32,7 @@ import Copyable from '../mixins/copyable';
import copy from '../copy';
import EmberError from '@ember/error';
import MutableEnumerable from './mutable_enumerable';
-import { uniqBy } from '../utils';
+import { typeOf } from '../type-of';
const EMPTY_ARRAY = Object.freeze([]);
const EMBER_ARRAY = symbol('EMBER_ARRAY');
@@ -38,6 +41,26 @@ export function isEmberArray(obj) {
return obj && obj[EMBER_ARRAY];
}
+const identityFunction = item => item;
+
+export function uniqBy(array, key = identityFunction) {
+ assert(`first argument passed to \`uniqBy\` should be array`, isArray(array));
+
+ let ret = A();
+ let seen = new Set();
+ let getter = typeof key === 'function' ? key : item => get(item, key);
+
+ array.forEach(item => {
+ let val = getter(item);
+ if (!seen.has(val)) {
+ seen.add(val);
+ ret.push(item);
+ }
+ });
+
+ return ret;
+}
+
function iter(key, value) {
let valueProvided = arguments.length === 2;
return valueProvided ? item => value === get(item, key) : item => !!get(item, key);
@@ -83,6 +106,64 @@ function indexOf(array, val, startAt = 0, withNaNCheck) {
return findIndex(array, predicate, startAt);
}
+/**
+ Returns true if the passed object is an array or Array-like.
+
+ Objects are considered Array-like if any of the following are true:
+
+ - the object is a native Array
+ - the object has an objectAt property
+ - the object is an Object, and has a length property
+
+ Unlike `typeOf` this method returns true even if the passed object is
+ not formally an array but appears to be array-like (i.e. implements `Array`)
+
+ ```javascript
+ import { isArray } from '@ember/array';
+ import ArrayProxy from '@ember/array/proxy';
+
+ isArray(); // false
+ isArray([]); // true
+ isArray(ArrayProxy.create({ content: [] })); // true
+ ```
+
+ @method isArray
+ @static
+ @for @ember/array
+ @param {Object} obj The object to test
+ @return {Boolean} true if the passed object is an array or Array-like
+ @public
+*/
+export function isArray(_obj) {
+ let obj = _obj;
+ if (DEBUG && HAS_NATIVE_PROXY && typeof _obj === 'object' && _obj !== null) {
+ let possibleProxyContent = _obj[PROXY_CONTENT];
+ if (possibleProxyContent !== undefined) {
+ obj = possibleProxyContent;
+ }
+ }
+
+ if (!obj || obj.setInterval) {
+ return false;
+ }
+ if (Array.isArray(obj)) {
+ return true;
+ }
+ if (ArrayMixin.detect(obj)) {
+ return true;
+ }
+
+ let type = typeOf(obj);
+ if ('array' === type) {
+ return true;
+ }
+ let length = obj.length;
+ if (typeof length === 'number' && length === length && 'object' === type) {
+ return true;
+ }
+ return false;
+}
+
// ..........................................................
// ARRAY
//
| true |
Other
|
emberjs
|
ember.js
|
8e12a0cb2e19bb7bd7a03abf8385d3f3c454d5ff.json
|
Fix module cycle in ember-runtime.
|
packages/ember-runtime/lib/system/array_proxy.js
|
@@ -11,9 +11,8 @@ import {
addArrayObserver,
removeArrayObserver,
} from 'ember-metal';
-import { isArray } from '../utils';
import EmberObject from './object';
-import { MutableArray } from '../mixins/array';
+import { isArray, MutableArray } from '../mixins/array';
import { assert } from '@ember/debug';
const ARRAY_OBSERVER_MAPPING = {
| true |
Other
|
emberjs
|
ember.js
|
8e12a0cb2e19bb7bd7a03abf8385d3f3c454d5ff.json
|
Fix module cycle in ember-runtime.
|
packages/ember-runtime/lib/type-of.js
|
@@ -1,9 +1,4 @@
-import { DEBUG } from '@glimmer/env';
-import { PROXY_CONTENT, get } from 'ember-metal';
-import { HAS_NATIVE_PROXY } from 'ember-utils';
-import EmberArray, { A } from './mixins/array';
import EmberObject from './system/object';
-import { assert } from '@ember/debug';
// ........................................
// TYPING & ARRAY MESSAGING
@@ -21,66 +16,7 @@ const TYPE_MAP = {
};
const { toString } = Object.prototype;
-/**
- @module @ember/array
-*/
-/**
- Returns true if the passed object is an array or Array-like.
-
- Objects are considered Array-like if any of the following are true:
-
- - the object is a native Array
- - the object has an objectAt property
- - the object is an Object, and has a length property
-
- Unlike `typeOf` this method returns true even if the passed object is
- not formally an array but appears to be array-like (i.e. implements `Array`)
-
- ```javascript
- import { isArray } from '@ember/array';
- import ArrayProxy from '@ember/array/proxy';
-
- isArray(); // false
- isArray([]); // true
- isArray(ArrayProxy.create({ content: [] })); // true
- ```
-
- @method isArray
- @static
- @for @ember/array
- @param {Object} obj The object to test
- @return {Boolean} true if the passed object is an array or Array-like
- @public
-*/
-export function isArray(_obj) {
- let obj = _obj;
- if (DEBUG && HAS_NATIVE_PROXY && typeof _obj === 'object' && _obj !== null) {
- let possibleProxyContent = _obj[PROXY_CONTENT];
- if (possibleProxyContent !== undefined) {
- obj = possibleProxyContent;
- }
- }
- if (!obj || obj.setInterval) {
- return false;
- }
- if (Array.isArray(obj)) {
- return true;
- }
- if (EmberArray.detect(obj)) {
- return true;
- }
-
- let type = typeOf(obj);
- if ('array' === type) {
- return true;
- }
- let length = obj.length;
- if (typeof length === 'number' && length === length && 'object' === type) {
- return true;
- }
- return false;
-}
/**
@module @ember/utils
*/
@@ -169,23 +105,3 @@ export function typeOf(item) {
return ret;
}
-
-const identityFunction = item => item;
-
-export function uniqBy(array, key = identityFunction) {
- assert(`first argument passed to \`uniqBy\` should be array`, isArray(array));
-
- let ret = A();
- let seen = new Set();
- let getter = typeof key === 'function' ? key : item => get(item, key);
-
- array.forEach(item => {
- let val = getter(item);
- if (!seen.has(val)) {
- seen.add(val);
- ret.push(item);
- }
- });
-
- return ret;
-}
| true |
Other
|
emberjs
|
ember.js
|
8e12a0cb2e19bb7bd7a03abf8385d3f3c454d5ff.json
|
Fix module cycle in ember-runtime.
|
packages/ember-runtime/tests/core/compare_test.js
|
@@ -1,4 +1,4 @@
-import { typeOf } from '../../lib/utils';
+import { typeOf } from '../../lib/type-of';
import EmberObject from '../../lib/system/object';
import compare from '../../lib/compare';
import Comparable from '../../lib/mixins/comparable';
| true |
Other
|
emberjs
|
ember.js
|
8e12a0cb2e19bb7bd7a03abf8385d3f3c454d5ff.json
|
Fix module cycle in ember-runtime.
|
packages/ember-runtime/tests/core/is_array_test.js
|
@@ -1,5 +1,4 @@
-import { isArray } from '../../lib/utils';
-import { A as emberA } from '../../lib/mixins/array';
+import { A as emberA, isArray } from '../../lib/mixins/array';
import ArrayProxy from '../../lib/system/array_proxy';
import EmberObject from '../../lib/system/object';
import { window } from 'ember-browser-environment';
| true |
Other
|
emberjs
|
ember.js
|
8e12a0cb2e19bb7bd7a03abf8385d3f3c454d5ff.json
|
Fix module cycle in ember-runtime.
|
packages/ember-runtime/tests/core/type_of_test.js
|
@@ -1,4 +1,4 @@
-import { typeOf } from '../../lib/utils';
+import { typeOf } from '../../lib/type-of';
import EmberObject from '../../lib/system/object';
import { window } from 'ember-browser-environment';
import { moduleFor, AbstractTestCase } from 'internal-test-helpers';
| true |
Other
|
emberjs
|
ember.js
|
594e222968e0622dc226de87ce71079b95ac6f5f.json
|
Fix module cycle in @ember/application package.
|
packages/@ember/application/lib/application.js
|
@@ -9,7 +9,7 @@ import { assert, isTesting } from '@ember/debug';
import { DEBUG } from '@glimmer/env';
import { bind, join, once, run, schedule } from '@ember/runloop';
import { libraries, processAllNamespaces, setNamespaceSearchDisabled } from 'ember-metal';
-import { _loaded, runLoadHooks } from '@ember/application';
+import { _loaded, runLoadHooks } from './lazy_load';
import { RSVP } from 'ember-runtime';
import { EventDispatcher, jQuery, jQueryDisabled } from 'ember-views';
import {
@@ -21,7 +21,7 @@ import {
NoneLocation,
BucketCache,
} from 'ember-routing';
-import ApplicationInstance from '@ember/application/instance';
+import ApplicationInstance from '../instance';
import Engine from '@ember/engine';
import { privatize as P } from 'container';
import { setupApplicationRegistry } from 'ember-glimmer';
| false |
Other
|
emberjs
|
ember.js
|
ae39947c7f5deba08c69a6aea4c548ae087612d3.json
|
Fix module cycle in @ember/engine package.
|
packages/@ember/engine/index.js
|
@@ -1,6 +1,9 @@
/**
@module @ember/engine
*/
+
+export { getEngineParent, setEngineParent } from './lib/engine-parent';
+
import { canInvoke } from 'ember-utils';
import Controller from '@ember/controller';
import { Namespace, RegistryProxyMixin } from 'ember-runtime';
@@ -14,35 +17,7 @@ import { RoutingService } from 'ember-routing';
import { ContainerDebugAdapter } from 'ember-extension-support';
import { ComponentLookup } from 'ember-views';
import { setupEngineRegistry } from 'ember-glimmer';
-import { symbol } from 'ember-utils';
-
-const ENGINE_PARENT = symbol('ENGINE_PARENT');
-
-/**
- `getEngineParent` retrieves an engine instance's parent instance.
-
- @method getEngineParent
- @param {EngineInstance} engine An engine instance.
- @return {EngineInstance} The parent engine instance.
- @for @ember/engine
- @static
- @private
-*/
-export function getEngineParent(engine) {
- return engine[ENGINE_PARENT];
-}
-
-/**
- `setEngineParent` sets an engine instance's parent instance.
- @method setEngineParent
- @param {EngineInstance} engine An engine instance.
- @param {EngineInstance} parent The parent engine instance.
- @private
-*/
-export function setEngineParent(engine, parent) {
- engine[ENGINE_PARENT] = parent;
-}
function props(obj) {
let properties = [];
| true |
Other
|
emberjs
|
ember.js
|
ae39947c7f5deba08c69a6aea4c548ae087612d3.json
|
Fix module cycle in @ember/engine package.
|
packages/@ember/engine/instance.js
|
@@ -12,7 +12,7 @@ import {
import { assert } from '@ember/debug';
import EmberError from '@ember/error';
import { Registry, privatize as P } from 'container';
-import { getEngineParent, setEngineParent } from '@ember/engine';
+import { getEngineParent, setEngineParent } from './lib/engine-parent';
/**
The `EngineInstance` encapsulates all of the stateful aspects of a
| true |
Other
|
emberjs
|
ember.js
|
ae39947c7f5deba08c69a6aea4c548ae087612d3.json
|
Fix module cycle in @ember/engine package.
|
packages/@ember/engine/lib/engine-parent.js
|
@@ -0,0 +1,32 @@
+/**
+@module @ember/engine
+*/
+import { symbol } from 'ember-utils';
+
+const ENGINE_PARENT = symbol('ENGINE_PARENT');
+
+/**
+ `getEngineParent` retrieves an engine instance's parent instance.
+
+ @method getEngineParent
+ @param {EngineInstance} engine An engine instance.
+ @return {EngineInstance} The parent engine instance.
+ @for @ember/engine
+ @static
+ @private
+*/
+export function getEngineParent(engine) {
+ return engine[ENGINE_PARENT];
+}
+
+/**
+ `setEngineParent` sets an engine instance's parent instance.
+
+ @method setEngineParent
+ @param {EngineInstance} engine An engine instance.
+ @param {EngineInstance} parent The parent engine instance.
+ @private
+*/
+export function setEngineParent(engine, parent) {
+ engine[ENGINE_PARENT] = parent;
+}
| true |
Other
|
emberjs
|
ember.js
|
9918c2c2a579b3729e4a787d84e38eeaaa08cbb2.json
|
simplify exported type def
|
packages/ember-metal/index.d.ts
|
@@ -6,17 +6,7 @@ export const PROPERTY_DID_CHANGE: symbol;
export function setHasViews(fn: () => boolean): null;
-export type MethodKey<T> = { [K in keyof T]: T[K] extends (() => void) ? K : never }[keyof T];
-export type RunInTransactionFunc = <T extends object, K extends MethodKey<T>>(
- context: T,
- methodName: K
-) => boolean;
-export type DidRenderFunc = (object: any, key: string, reference: any) => void;
-export type AssertNotRenderedFunc = (obj: object, keyName: string) => void;
-
-export const runInTransaction: RunInTransactionFunc;
-export const didRender: DidRenderFunc;
-export const assertNotRendered: AssertNotRenderedFunc;
+export { default as runInTransaction, didRender, assertNotRendered } from './lib/transaction';
export function get(obj: any, keyName: string): any;
| false |
Other
|
emberjs
|
ember.js
|
c486d7a87f6015d7aac9ce59463f1a9927043ef8.json
|
Add test for issue #16427
Test that a CP descriptor still works with notifyPropertyChange
when it is not setup correctly via Ember.defineProperty.
|
packages/ember-metal/tests/computed_test.js
|
@@ -9,6 +9,7 @@ import {
set,
isWatching,
addObserver,
+ notifyPropertyChange,
} from '..';
import { meta as metaFor } from 'ember-meta';
import { moduleFor, AbstractTestCase } from 'internal-test-helpers';
@@ -60,6 +61,26 @@ moduleFor(
assert.equal(count, 1, 'should have invoked computed property');
}
+ ['@test `notifyPropertyChange` works for a computed property not setup using Ember.defineProperty #GH16427'](
+ assert
+ ) {
+ let obj = {
+ a: 50,
+ b: computed(function() {
+ return this.a / 5;
+ }),
+ };
+
+ expectDeprecation(function() {
+ assert.equal(get(obj, 'b'), 10);
+ });
+
+ obj.a = 10;
+ notifyPropertyChange(obj, 'b');
+
+ assert.equal(get(obj, 'b'), 2);
+ }
+
['@test defining computed property should invoke property on get'](assert) {
let obj = {};
let count = 0;
| false |
Other
|
emberjs
|
ember.js
|
0d1a3df96b464fceefcb3811c701f994937d88b3.json
|
convert @ember/instrumentation to typescript
|
packages/@ember/instrumentation/index.d.ts
|
@@ -1,7 +0,0 @@
-export const flaggedInstrument: any;
-
-export function _instrumentStart(
- name: string,
- _payload: (_payloadParam: any) => any,
- _payloadParam: any
-): () => void;
| true |
Other
|
emberjs
|
ember.js
|
0d1a3df96b464fceefcb3811c701f994937d88b3.json
|
convert @ember/instrumentation to typescript
|
packages/@ember/instrumentation/index.ts
|
@@ -1,8 +1,35 @@
/* eslint no-console:off */
/* global console */
-import { ENV } from 'ember-environment';
import { EMBER_IMPROVED_INSTRUMENTATION } from '@ember/canary-features';
+import { ENV } from 'ember-environment';
+
+export interface Listener<T> {
+ before: (name: string, timestamp: number, payload: object) => T;
+ after: (name: string, timestamp: number, payload: object, beforeValue: T) => void;
+}
+
+export interface Subscriber<T> {
+ pattern: string;
+ regex: RegExp;
+ object: Listener<T>;
+}
+
+export interface PayloadWithException {
+ exception?: any;
+}
+
+export interface StructuredProfilePayload {
+ object: string | object;
+}
+
+interface MaybePerf {
+ now?: () => number;
+ mozNow?: () => number;
+ webkitNow?: () => number;
+ msNow?: () => number;
+ oNow?: () => number;
+}
/**
@module @ember/instrumentation
@@ -59,11 +86,11 @@ import { EMBER_IMPROVED_INSTRUMENTATION } from '@ember/canary-features';
@static
@private
*/
-export let subscribers = [];
-let cache = {};
+export let subscribers: Subscriber<any>[] = [];
+let cache: { [key: string]: Listener<any>[] } = {};
-function populateListeners(name) {
- let listeners = [];
+function populateListeners(name: string) {
+ let listeners: Listener<any>[] = [];
let subscriber;
for (let i = 0; i < subscribers.length; i++) {
@@ -77,8 +104,8 @@ function populateListeners(name) {
return listeners;
}
-const time = (() => {
- let perf = 'undefined' !== typeof window ? window.performance || {} : {};
+const time = ((): (() => number) => {
+ let perf: MaybePerf = 'undefined' !== typeof window ? window.performance || {} : {};
let fn = perf.now || perf.mozNow || perf.webkitNow || perf.msNow || perf.oNow;
// fn.bind will be available in all the browsers that support the advanced window.performance... ;-)
return fn
@@ -95,21 +122,39 @@ const time = (() => {
@for @ember/instrumentation
@static
@param {String} [name] Namespaced event name.
- @param {Object} _payload
+ @param {Object} payload
@param {Function} callback Function that you're instrumenting.
@param {Object} binding Context that instrument function is called with.
@private
*/
-export function instrument(name, _payload, callback, binding) {
- if (arguments.length <= 3 && typeof _payload === 'function') {
- binding = callback;
- callback = _payload;
- _payload = undefined;
+export function instrument<T extends object>(name: string, callback: () => T, binding: object): T;
+export function instrument<TPayload extends object>(
+ name: string,
+ payload: object,
+ callback: () => TPayload,
+ binding: object
+): TPayload;
+export function instrument<TPayload extends object>(
+ name: string,
+ p1: (() => TPayload) | TPayload,
+ p2: TPayload | (() => TPayload),
+ p3?: object
+): TPayload {
+ let payload: TPayload;
+ let callback: () => TPayload;
+ let binding: object;
+ if (arguments.length <= 3 && typeof p1 === 'function') {
+ payload = {} as TPayload;
+ callback = p1;
+ binding = p2;
+ } else {
+ payload = (p1 || {}) as TPayload;
+ callback = p2 as () => TPayload;
+ binding = p3 as TPayload;
}
if (subscribers.length === 0) {
return callback.call(binding);
}
- let payload = _payload || {};
let finalizer = _instrumentStart(name, () => payload);
if (finalizer) {
@@ -119,20 +164,26 @@ export function instrument(name, _payload, callback, binding) {
}
}
-let flaggedInstrument;
+let flaggedInstrument: <T, TPayload>(name: string, payload: TPayload, callback: () => T) => T;
if (EMBER_IMPROVED_INSTRUMENTATION) {
- flaggedInstrument = instrument;
+ flaggedInstrument = instrument as typeof flaggedInstrument;
} else {
- flaggedInstrument = (name, payload, callback) => callback();
+ flaggedInstrument = <T, TPayload>(_name: string, _payload: TPayload, callback: () => T) =>
+ callback();
}
export { flaggedInstrument };
-function withFinalizer(callback, finalizer, payload, binding) {
- let result;
+function withFinalizer<T extends object>(
+ callback: () => T,
+ finalizer: () => void,
+ payload: T,
+ binding: object
+): T & PayloadWithException {
+ let result: T;
try {
result = callback.call(binding);
} catch (e) {
- payload.exception = e;
+ (payload as PayloadWithException).exception = e;
result = payload;
} finally {
finalizer();
@@ -143,7 +194,17 @@ function withFinalizer(callback, finalizer, payload, binding) {
function NOOP() {}
// private for now
-export function _instrumentStart(name, _payload, _payloadParam) {
+export function _instrumentStart<TPayloadParam>(
+ name: string,
+ _payload: (_payloadParam: TPayloadParam) => object,
+ _payloadParam: TPayloadParam
+): () => void;
+export function _instrumentStart<TPayloadParam>(name: string, _payload: () => object): () => void;
+export function _instrumentStart<TPayloadParam>(
+ name: string,
+ _payload: (_payloadParam: TPayloadParam) => object,
+ _payloadParam?: TPayloadParam
+): () => void {
if (subscribers.length === 0) {
return NOOP;
}
@@ -158,25 +219,27 @@ export function _instrumentStart(name, _payload, _payloadParam) {
return NOOP;
}
- let payload = _payload(_payloadParam);
+ let payload = _payload(_payloadParam!);
let STRUCTURED_PROFILE = ENV.STRUCTURED_PROFILE;
- let timeName;
+ let timeName: string;
if (STRUCTURED_PROFILE) {
- timeName = `${name}: ${payload.object}`;
+ timeName = `${name}: ${(payload as StructuredProfilePayload).object}`;
console.time(timeName);
}
let beforeValues = new Array(listeners.length);
- let i, listener;
+ let i: number;
+ let listener: Listener<any>;
let timestamp = time();
for (i = 0; i < listeners.length; i++) {
listener = listeners[i];
beforeValues[i] = listener.before(name, timestamp, payload);
}
- return function _instrumentEnd() {
- let i, listener;
+ return function _instrumentEnd(): void {
+ let i: number;
+ let listener: Listener<any>;
let timestamp = time();
for (i = 0; i < listeners.length; i++) {
listener = listeners[i];
@@ -204,21 +267,21 @@ export function _instrumentStart(name, _payload, _payloadParam) {
@return {Subscriber}
@private
*/
-export function subscribe(pattern, object) {
+export function subscribe<T>(pattern: string, object: Listener<T>): Subscriber<T> {
let paths = pattern.split('.');
let path;
- let regex = [];
+ let regexes: string[] = [];
for (let i = 0; i < paths.length; i++) {
path = paths[i];
if (path === '*') {
- regex.push('[^\\.]*');
+ regexes.push('[^\\.]*');
} else {
- regex.push(path);
+ regexes.push(path);
}
}
- regex = regex.join('\\.');
+ let regex = regexes.join('\\.');
regex = `${regex}(\\..*)?`;
let subscriber = {
@@ -243,8 +306,8 @@ export function subscribe(pattern, object) {
@param {Object} [subscriber]
@private
*/
-export function unsubscribe(subscriber) {
- let index;
+export function unsubscribe(subscriber: Subscriber<any>): void {
+ let index = 0;
for (let i = 0; i < subscribers.length; i++) {
if (subscribers[i] === subscriber) {
@@ -264,7 +327,7 @@ export function unsubscribe(subscriber) {
@static
@private
*/
-export function reset() {
+export function reset(): void {
subscribers.length = 0;
cache = {};
}
| true |
Other
|
emberjs
|
ember.js
|
0d1a3df96b464fceefcb3811c701f994937d88b3.json
|
convert @ember/instrumentation to typescript
|
packages/ember-environment/lib/env.ts
|
@@ -65,6 +65,8 @@ export const ENV = {
RAISE_ON_DEPRECATION: false,
+ STRUCTURED_PROFILE: false,
+
/**
Whether to insert a `<div class="ember-view" />` wrapper around the
application template. See RFC #280.
| true |
Other
|
emberjs
|
ember.js
|
008ef25ba94106776da1486dae232e14bf15ef4b.json
|
convert @ember/string to typescript
|
packages/@ember/string/index.d.ts
|
@@ -1,2 +0,0 @@
-export function dasherize(s: string): string;
-export function loc(s: string, ...args: string[]): string;
| true |
Other
|
emberjs
|
ember.js
|
008ef25ba94106776da1486dae232e14bf15ef4b.json
|
convert @ember/string to typescript
|
packages/@ember/string/index.ts
|
@@ -10,26 +10,27 @@ import { getString } from './lib/string_registry';
const STRING_DASHERIZE_REGEXP = /[ _]/g;
-const STRING_DASHERIZE_CACHE = new Cache(1000, key =>
+const STRING_DASHERIZE_CACHE = new Cache<string, string>(1000, key =>
decamelize(key).replace(STRING_DASHERIZE_REGEXP, '-')
);
const STRING_CAMELIZE_REGEXP_1 = /(\-|\_|\.|\s)+(.)?/g;
const STRING_CAMELIZE_REGEXP_2 = /(^|\/)([A-Z])/g;
-const CAMELIZE_CACHE = new Cache(1000, key =>
+const CAMELIZE_CACHE = new Cache<string, string>(1000, key =>
key
- .replace(STRING_CAMELIZE_REGEXP_1, (match, separator, chr) => (chr ? chr.toUpperCase() : ''))
+ .replace(STRING_CAMELIZE_REGEXP_1, (_match, _separator, chr) => (chr ? chr.toUpperCase() : ''))
.replace(STRING_CAMELIZE_REGEXP_2, (match /*, separator, chr */) => match.toLowerCase())
);
const STRING_CLASSIFY_REGEXP_1 = /^(\-|_)+(.)?/;
const STRING_CLASSIFY_REGEXP_2 = /(.)(\-|\_|\.|\s)+(.)?/g;
const STRING_CLASSIFY_REGEXP_3 = /(^|\/|\.)([a-z])/g;
-const CLASSIFY_CACHE = new Cache(1000, str => {
- let replace1 = (match, separator, chr) => (chr ? `_${chr.toUpperCase()}` : '');
- let replace2 = (match, initialChar, separator, chr) =>
+const CLASSIFY_CACHE = new Cache<string, string>(1000, str => {
+ let replace1 = (_match: string, _separator: string, chr: string) =>
+ chr ? `_${chr.toUpperCase()}` : '';
+ let replace2 = (_match: string, initialChar: string, _separator: string, chr: string) =>
initialChar + (chr ? chr.toUpperCase() : '');
let parts = str.split('/');
for (let i = 0; i < parts.length; i++) {
@@ -45,7 +46,7 @@ const CLASSIFY_CACHE = new Cache(1000, str => {
const STRING_UNDERSCORE_REGEXP_1 = /([a-z\d])([A-Z]+)/g;
const STRING_UNDERSCORE_REGEXP_2 = /\-|\s+/g;
-const UNDERSCORE_CACHE = new Cache(1000, str =>
+const UNDERSCORE_CACHE = new Cache<string, string>(1000, str =>
str
.replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2')
.replace(STRING_UNDERSCORE_REGEXP_2, '_')
@@ -54,13 +55,13 @@ const UNDERSCORE_CACHE = new Cache(1000, str =>
const STRING_CAPITALIZE_REGEXP = /(^|\/)([a-z\u00C0-\u024F])/g;
-const CAPITALIZE_CACHE = new Cache(1000, str =>
+const CAPITALIZE_CACHE = new Cache<string, string>(1000, str =>
str.replace(STRING_CAPITALIZE_REGEXP, (match /*, separator, chr */) => match.toUpperCase())
);
const STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g;
-const DECAMELIZE_CACHE = new Cache(1000, str =>
+const DECAMELIZE_CACHE = new Cache<string, string>(1000, str =>
str.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase()
);
@@ -73,10 +74,10 @@ const DECAMELIZE_CACHE = new Cache(1000, str =>
@public
*/
-function _fmt(str, formats) {
+function _fmt(str: string, formats: any[]) {
// first, replace any ORDERED replacements.
let idx = 0; // the current index for non-numerical replacements
- return str.replace(/%@([0-9]+)?/g, (s, argIndex) => {
+ return str.replace(/%@([0-9]+)?/g, (_s: string, argIndex: string) => {
let i = argIndex ? parseInt(argIndex, 10) - 1 : idx++;
let r = i < formats.length ? formats[i] : undefined;
return typeof r === 'string' ? r : r === null ? '(null)' : r === undefined ? '' : '' + r;
@@ -109,7 +110,7 @@ function _fmt(str, formats) {
@return {String} formatted string
@public
*/
-export function loc(str, formats) {
+export function loc(str: string, formats: any[]): string {
if (!Array.isArray(formats) || arguments.length > 2) {
formats = Array.prototype.slice.call(arguments, 1);
}
@@ -140,7 +141,7 @@ export function loc(str, formats) {
@return {Array} array containing the split strings
@public
*/
-export function w(str) {
+export function w(str: string): string[] {
return str.split(/\s+/);
}
@@ -159,7 +160,7 @@ export function w(str) {
@return {String} the decamelized string.
@public
*/
-export function decamelize(str) {
+export function decamelize(str: string): string {
return DECAMELIZE_CACHE.get(str);
}
@@ -179,7 +180,7 @@ export function decamelize(str) {
@return {String} the dasherized string.
@public
*/
-export function dasherize(str) {
+export function dasherize(str: string): string {
return STRING_DASHERIZE_CACHE.get(str);
}
@@ -200,7 +201,7 @@ export function dasherize(str) {
@return {String} the camelized string.
@public
*/
-export function camelize(str) {
+export function camelize(str: string): string {
return CAMELIZE_CACHE.get(str);
}
@@ -220,7 +221,7 @@ export function camelize(str) {
@return {String} the classified string
@public
*/
-export function classify(str) {
+export function classify(str: string): string {
return CLASSIFY_CACHE.get(str);
}
@@ -241,7 +242,7 @@ export function classify(str) {
@return {String} the underscored string.
@public
*/
-export function underscore(str) {
+export function underscore(str: string): string {
return UNDERSCORE_CACHE.get(str);
}
@@ -261,7 +262,7 @@ export function underscore(str) {
@return {String} The capitalized string.
@public
*/
-export function capitalize(str) {
+export function capitalize(str: string): string {
return CAPITALIZE_CACHE.get(str);
}
@@ -296,7 +297,7 @@ if (ENV.EXTEND_PROTOTYPES.String) {
configurable: true,
enumerable: false,
writeable: true,
- value: function(...args) {
+ value: function(this: string, ...args: any[]) {
return loc(this, args);
},
},
| true |
Other
|
emberjs
|
ember.js
|
008ef25ba94106776da1486dae232e14bf15ef4b.json
|
convert @ember/string to typescript
|
packages/@ember/string/lib/string_registry.js
|
@@ -1,16 +0,0 @@
-// STATE within a module is frowned upon, this exists
-// to support Ember.STRINGS but shield ember internals from this legacy global
-// API.
-let STRINGS = {};
-
-export function setStrings(strings) {
- STRINGS = strings;
-}
-
-export function getStrings() {
- return STRINGS;
-}
-
-export function getString(name) {
- return STRINGS[name];
-}
| true |
Other
|
emberjs
|
ember.js
|
008ef25ba94106776da1486dae232e14bf15ef4b.json
|
convert @ember/string to typescript
|
packages/@ember/string/lib/string_registry.ts
|
@@ -0,0 +1,16 @@
+// STATE within a module is frowned upon, this exists
+// to support Ember.STRINGS but shield ember internals from this legacy global
+// API.
+let STRINGS: { [key: string]: string } = {};
+
+export function setStrings(strings: { [key: string]: string }) {
+ STRINGS = strings;
+}
+
+export function getStrings(): { [key: string]: string } {
+ return STRINGS;
+}
+
+export function getString(name: string): string | undefined {
+ return STRINGS[name];
+}
| true |
Other
|
emberjs
|
ember.js
|
a4fc9a5cdc9dacca9aa5e179d1885abb10e5c91a.json
|
start meta package
add types and change imports
|
packages/ember-meta/index.ts
|
@@ -0,0 +1 @@
+export * from './lib/meta';
| true |
Other
|
emberjs
|
ember.js
|
a4fc9a5cdc9dacca9aa5e179d1885abb10e5c91a.json
|
start meta package
add types and change imports
|
packages/ember-meta/lib/meta.ts
|
@@ -1,15 +1,94 @@
-import { lookupDescriptor, symbol, toString } from 'ember-utils';
-import { protoMethods as listenerMethods } from './meta_listeners';
import { assert } from '@ember/debug';
import { DEBUG } from '@glimmer/env';
-import { removeChainWatcher } from './chains';
+import { Tag } from '@glimmer/reference';
import { ENV } from 'ember-environment';
+import { lookupDescriptor, symbol, toString } from 'ember-utils';
+
+// TODO move chains into ember-meta
+function removeChainWatcher(obj: object, keyName: string, node: any, meta: Meta) {
+ meta.readableChainWatchers().remove(keyName, node);
+ unwatchKey(obj, keyName, meta);
+}
+
+// TODO move unwatch key into meta
+function unwatchKey(obj: object, keyName: string, meta: Meta) {
+ // do nothing of this object has already been destroyed
+ if (meta.isSourceDestroyed()) {
+ return;
+ }
+
+ let count = meta.peekWatching(keyName);
+ if (count === 1) {
+ meta.writeWatching(keyName, 0);
+
+ let possibleDesc = descriptorFor(obj, keyName, meta);
+ let isDescriptor = possibleDesc !== undefined;
+
+ if (isDescriptor && possibleDesc.didUnwatch) {
+ possibleDesc.didUnwatch(obj, keyName, meta);
+ }
+
+ if (typeof (obj as any).didUnwatchProperty === 'function') {
+ (obj as any).didUnwatchProperty(keyName);
+ }
+
+ if (DEBUG) {
+ // It is true, the following code looks quite WAT. But have no fear, It
+ // exists purely to improve development ergonomics and is removed from
+ // ember.min.js and ember.prod.js builds.
+ //
+ // Some further context: Once a property is watched by ember, bypassing `set`
+ // for mutation, will bypass observation. This code exists to assert when
+ // that occurs, and attempt to provide more helpful feedback. The alternative
+ // is tricky to debug partially observable properties.
+ if (!isDescriptor && keyName in obj) {
+ let maybeMandatoryDescriptor = lookupDescriptor(obj, keyName);
+
+ // TODO extract function isMandatorySetter
+ // likely should just make mandatory setter inert instead of uninstalling and reinstalling
+ if (
+ maybeMandatoryDescriptor!.set &&
+ (maybeMandatoryDescriptor!.set! as any).isMandatorySetter
+ ) {
+ if (
+ maybeMandatoryDescriptor!.get &&
+ (maybeMandatoryDescriptor!.get! as any).isInheritingGetter
+ ) {
+ let possibleValue = meta.readInheritedValue('values', keyName);
+ if (possibleValue === UNDEFINED) {
+ delete obj[keyName];
+ return;
+ }
+ }
-let counters;
+ Object.defineProperty(obj, keyName, {
+ configurable: true,
+ enumerable: Object.prototype.propertyIsEnumerable.call(obj, keyName),
+ writable: true,
+ value: meta.peekValues(keyName),
+ });
+ meta.deleteFromValues(keyName);
+ }
+ }
+ }
+ } else if (count > 1) {
+ meta.writeWatching(keyName, count - 1);
+ }
+}
+
+export interface MetaCounters {
+ peekCalls: number;
+ peekPrototypeWalks: number;
+ setCalls: number;
+ deleteCalls: number;
+ metaCalls: number;
+ metaInstantiated: number;
+}
+
+let counters: MetaCounters | undefined;
if (DEBUG) {
counters = {
peekCalls: 0,
- peekParentCalls: 0,
peekPrototypeWalks: 0,
setCalls: 0,
deleteCalls: 0,
@@ -29,12 +108,31 @@ const SOURCE_DESTROYING = 1 << 1;
const SOURCE_DESTROYED = 1 << 2;
const META_DESTROYED = 1 << 3;
-const NODE_STACK = [];
+const NODE_STACK: any[] = [];
export class Meta {
- constructor(obj, parentMeta) {
+ _descriptors: any | undefined;
+ _watching: any | undefined;
+ _mixins: any | undefined;
+ _deps: any | undefined;
+ _chainWatchers: any | undefined;
+ _chains: any | undefined;
+ _tag: Tag | undefined;
+ _tags: any | undefined;
+ _flags: number;
+ source: object;
+ proto: object | undefined;
+ parent: Meta | undefined;
+ _listeners: any | undefined;
+ _listenersFinalized: boolean;
+
+ // DEBUG
+ _values: any | undefined;
+ _bindings: any | undefined;
+
+ constructor(obj: object, parentMeta: Meta | undefined) {
if (DEBUG) {
- counters.metaInstantiated++;
+ counters!.metaInstantiated++;
this._values = undefined;
}
this._descriptors = undefined;
@@ -70,7 +168,7 @@ export class Meta {
this._listenersFinalized = false;
}
- isInitialized(obj) {
+ isInitialized(obj: object) {
return this.proto !== obj;
}
@@ -142,20 +240,20 @@ export class Meta {
this._flags |= META_DESTROYED;
}
- _hasFlag(flag) {
+ _hasFlag(flag: number) {
return (this._flags & flag) === flag;
}
- _getOrCreateOwnMap(key) {
+ _getOrCreateOwnMap(key: string) {
return this[key] || (this[key] = Object.create(null));
}
- _getOrCreateOwnSet(key) {
+ _getOrCreateOwnSet(key: string) {
return this[key] || (this[key] = new Set());
}
- _getInherited(key) {
- let pointer = this;
+ _getInherited(key: string) {
+ let pointer: Meta | undefined = this;
while (pointer !== undefined) {
let map = pointer[key];
if (map !== undefined) {
@@ -165,8 +263,8 @@ export class Meta {
}
}
- _findInherited(key, subkey) {
- let pointer = this;
+ _findInherited(key: string, subkey: string): any | undefined {
+ let pointer: Meta | undefined = this;
while (pointer !== undefined) {
let map = pointer[key];
if (map !== undefined) {
@@ -179,8 +277,8 @@ export class Meta {
}
}
- _hasInInheritedSet(key, value) {
- let pointer = this;
+ _hasInInheritedSet(key: string, value: any) {
+ let pointer: Meta | undefined = this;
while (pointer !== undefined) {
let set = pointer[key];
if (set !== undefined) {
@@ -195,12 +293,13 @@ export class Meta {
// Implements a member that provides a lazily created map of maps,
// with inheritance at both levels.
- writeDeps(subkey, itemkey, value) {
+ writeDeps(subkey: string, itemkey: string, value: any) {
assert(
- this.isMetaDestroyed() &&
- `Cannot modify dependent keys for \`${itemkey}\` on \`${toString(
- this.source
- )}\` after it has been destroyed.`,
+ this.isMetaDestroyed()
+ ? `Cannot modify dependent keys for \`${itemkey}\` on \`${toString(
+ this.source
+ )}\` after it has been destroyed.`
+ : '',
!this.isMetaDestroyed()
);
@@ -212,8 +311,8 @@ export class Meta {
innerMap[itemkey] = value;
}
- peekDeps(subkey, itemkey) {
- let pointer = this;
+ peekDeps(subkey: string, itemkey: string) {
+ let pointer: Meta | undefined = this;
while (pointer !== undefined) {
let map = pointer._deps;
if (map !== undefined) {
@@ -229,8 +328,8 @@ export class Meta {
}
}
- hasDeps(subkey) {
- let pointer = this;
+ hasDeps(subkey: string) {
+ let pointer: Meta | undefined = this;
while (pointer !== undefined) {
let deps = pointer._deps;
if (deps !== undefined && deps[subkey] !== undefined) {
@@ -241,14 +340,14 @@ export class Meta {
return false;
}
- forEachInDeps(subkey, fn) {
+ forEachInDeps(subkey: string, fn: Function) {
return this._forEachIn('_deps', subkey, fn);
}
- _forEachIn(key, subkey, fn) {
- let pointer = this;
- let seen;
- let calls;
+ _forEachIn(key: string, subkey: string, fn: Function) {
+ let pointer: Meta | undefined = this;
+ let seen: Set<any> | undefined;
+ let calls: any[] | undefined;
while (pointer !== undefined) {
let map = pointer[key];
if (map !== undefined) {
@@ -281,10 +380,11 @@ export class Meta {
return this._tags;
}
- writableTag(create) {
+ writableTag(create: (obj: object) => Tag) {
assert(
- this.isMetaDestroyed() &&
- `Cannot create a new tag for \`${toString(this.source)}\` after it has been destroyed.`,
+ this.isMetaDestroyed()
+ ? `Cannot create a new tag for \`${toString(this.source)}\` after it has been destroyed.`
+ : '',
!this.isMetaDestroyed()
);
let ret = this._tag;
@@ -298,12 +398,13 @@ export class Meta {
return this._tag;
}
- writableChainWatchers(create) {
+ writableChainWatchers(create: (source: object) => any) {
assert(
- this.isMetaDestroyed() &&
- `Cannot create a new chain watcher for \`${toString(
- this.source
- )}\` after it has been destroyed.`,
+ this.isMetaDestroyed()
+ ? `Cannot create a new chain watcher for \`${toString(
+ this.source
+ )}\` after it has been destroyed.`
+ : '',
!this.isMetaDestroyed()
);
let ret = this._chainWatchers;
@@ -317,10 +418,11 @@ export class Meta {
return this._chainWatchers;
}
- writableChains(create) {
+ writableChains(create: (source: object) => any) {
assert(
- this.isMetaDestroyed() &&
- `Cannot create a new chains for \`${toString(this.source)}\` after it has been destroyed.`,
+ this.isMetaDestroyed()
+ ? `Cannot create a new chains for \`${toString(this.source)}\` after it has been destroyed.`
+ : '',
!this.isMetaDestroyed()
);
let ret = this._chains;
@@ -339,48 +441,51 @@ export class Meta {
return this._getInherited('_chains');
}
- writeWatching(subkey, value) {
+ writeWatching(subkey: string, value: any) {
assert(
- this.isMetaDestroyed() &&
- `Cannot update watchers for \`${subkey}\` on \`${toString(
- this.source
- )}\` after it has been destroyed.`,
+ this.isMetaDestroyed()
+ ? `Cannot update watchers for \`${subkey}\` on \`${toString(
+ this.source
+ )}\` after it has been destroyed.`
+ : '',
!this.isMetaDestroyed()
);
let map = this._getOrCreateOwnMap('_watching');
map[subkey] = value;
}
- peekWatching(subkey) {
+ peekWatching(subkey: string) {
return this._findInherited('_watching', subkey);
}
- addMixin(mixin) {
+ addMixin(mixin: any) {
assert(
- this.isMetaDestroyed() &&
- `Cannot add mixins of \`${toString(mixin)}\` on \`${toString(
- this.source
- )}\` call addMixin after it has been destroyed.`,
+ this.isMetaDestroyed()
+ ? `Cannot add mixins of \`${toString(mixin)}\` on \`${toString(
+ this.source
+ )}\` call addMixin after it has been destroyed.`
+ : '',
!this.isMetaDestroyed()
);
let set = this._getOrCreateOwnSet('_mixins');
set.add(mixin);
}
- hasMixin(mixin) {
+ hasMixin(mixin: any) {
return this._hasInInheritedSet('_mixins', mixin);
}
- forEachMixins(fn) {
- let pointer = this;
- let seen;
+ forEachMixins(fn: Function) {
+ let pointer: Meta | undefined = this;
+ let seen: Set<any> | undefined;
while (pointer !== undefined) {
let set = pointer._mixins;
if (set !== undefined) {
seen = seen === undefined ? new Set() : seen;
- set.forEach(mixin => {
- if (!seen.has(mixin)) {
- seen.add(mixin);
+ // TODO cleanup typing here
+ set.forEach((mixin: any) => {
+ if (!seen!.has(mixin)) {
+ seen!.add(mixin);
fn(mixin);
}
});
@@ -389,46 +494,48 @@ export class Meta {
}
}
- writeBindings(subkey, value) {
+ writeBindings(subkey: string, value: any) {
assert(
'Cannot invoke `meta.writeBindings` when EmberENV._ENABLE_BINDING_SUPPORT is not set',
ENV._ENABLE_BINDING_SUPPORT
);
assert(
- this.isMetaDestroyed() &&
- `Cannot add a binding for \`${subkey}\` on \`${toString(
- this.source
- )}\` after it has been destroyed.`,
+ this.isMetaDestroyed()
+ ? `Cannot add a binding for \`${subkey}\` on \`${toString(
+ this.source
+ )}\` after it has been destroyed.`
+ : '',
!this.isMetaDestroyed()
);
let map = this._getOrCreateOwnMap('_bindings');
map[subkey] = value;
}
- peekBindings(subkey) {
+ peekBindings(subkey: string) {
assert(
'Cannot invoke `meta.peekBindings` when EmberENV._ENABLE_BINDING_SUPPORT is not set',
ENV._ENABLE_BINDING_SUPPORT
);
return this._findInherited('_bindings', subkey);
}
- forEachBindings(fn) {
+ forEachBindings(fn: Function) {
assert(
'Cannot invoke `meta.forEachBindings` when EmberENV._ENABLE_BINDING_SUPPORT is not set',
ENV._ENABLE_BINDING_SUPPORT
);
- let pointer = this;
- let seen;
+ let pointer: Meta | undefined = this;
+ let seen: { [key: string]: any } | undefined;
while (pointer !== undefined) {
let map = pointer._bindings;
if (map !== undefined) {
for (let key in map) {
- seen = seen || Object.create(null);
- if (seen[key] === undefined) {
- seen[key] = true;
+ // cleanup typing
+ seen = seen === undefined ? Object.create(null) : seen;
+ if (seen![key] === undefined) {
+ seen![key] = true;
fn(key, map[key]);
}
}
@@ -443,37 +550,39 @@ export class Meta {
ENV._ENABLE_BINDING_SUPPORT
);
assert(
- this.isMetaDestroyed() &&
- `Cannot clear bindings on \`${toString(this.source)}\` after it has been destroyed.`,
+ this.isMetaDestroyed()
+ ? `Cannot clear bindings on \`${toString(this.source)}\` after it has been destroyed.`
+ : '',
!this.isMetaDestroyed()
);
this._bindings = undefined;
}
- writeDescriptors(subkey, value) {
+ writeDescriptors(subkey: string, value: any) {
assert(
- this.isMetaDestroyed() &&
- `Cannot update descriptors for \`${subkey}\` on \`${toString(
- this.source
- )}\` after it has been destroyed.`,
+ this.isMetaDestroyed()
+ ? `Cannot update descriptors for \`${subkey}\` on \`${toString(
+ this.source
+ )}\` after it has been destroyed.`
+ : '',
!this.isMetaDestroyed()
);
let map = this._getOrCreateOwnMap('_descriptors');
map[subkey] = value;
}
- peekDescriptors(subkey) {
+ peekDescriptors(subkey: string) {
let possibleDesc = this._findInherited('_descriptors', subkey);
return possibleDesc === UNDEFINED ? undefined : possibleDesc;
}
- removeDescriptors(subkey) {
+ removeDescriptors(subkey: string) {
this.writeDescriptors(subkey, UNDEFINED);
}
- forEachDescriptors(fn) {
- let pointer = this;
- let seen;
+ forEachDescriptors(fn: Function) {
+ let pointer: Meta | undefined = this;
+ let seen: Set<any> | undefined;
while (pointer !== undefined) {
let map = pointer._descriptors;
if (map !== undefined) {
@@ -491,38 +600,122 @@ export class Meta {
pointer = pointer.parent;
}
}
+
+ addToListeners(eventName: string, target: object, method: Function | string, once: boolean) {
+ if (this._listeners === undefined) {
+ this._listeners = [];
+ }
+ this._listeners.push(eventName, target, method, once);
+ }
+
+ _finalizeListeners() {
+ if (this._listenersFinalized) {
+ return;
+ }
+ if (this._listeners === undefined) {
+ this._listeners = [];
+ }
+ let pointer = this.parent;
+ while (pointer !== undefined) {
+ let listeners = pointer._listeners;
+ if (listeners !== undefined) {
+ this._listeners = this._listeners.concat(listeners);
+ }
+ if (pointer._listenersFinalized) {
+ break;
+ }
+ pointer = pointer.parent;
+ }
+ this._listenersFinalized = true;
+ }
+
+ removeFromListeners(eventName: string, target: any, method: Function | string): void {
+ let pointer: Meta | undefined = this;
+ while (pointer !== undefined) {
+ let listeners = pointer._listeners;
+ if (listeners !== undefined) {
+ for (let index = listeners.length - 4; index >= 0; index -= 4) {
+ if (
+ listeners[index] === eventName &&
+ (!method || (listeners[index + 1] === target && listeners[index + 2] === method))
+ ) {
+ if (pointer === this) {
+ listeners.splice(index, 4); // we are modifying our own list, so we edit directly
+ } else {
+ // we are trying to remove an inherited listener, so we do
+ // just-in-time copying to detach our own listeners from
+ // our inheritance chain.
+ this._finalizeListeners();
+ return this.removeFromListeners(eventName, target, method);
+ }
+ }
+ }
+ }
+ if (pointer._listenersFinalized) {
+ break;
+ }
+ pointer = pointer.parent;
+ }
+ }
+
+ matchingListeners(eventName: string) {
+ let pointer: Meta | undefined = this;
+ // fix type
+ let result: any[] | undefined;
+ while (pointer !== undefined) {
+ let listeners = pointer._listeners;
+ if (listeners !== undefined) {
+ for (let index = 0; index < listeners.length; index += 4) {
+ if (listeners[index] === eventName) {
+ result = result || [];
+ pushUniqueListener(result, listeners, index);
+ }
+ }
+ }
+ if (pointer._listenersFinalized) {
+ break;
+ }
+ pointer = pointer.parent;
+ }
+ return result;
+ }
}
-for (let name in listenerMethods) {
- Meta.prototype[name] = listenerMethods[name];
+export interface Meta {
+ writeValues(subkey: string, value: any): void;
+ peekValues(key: string): any;
+ deleteFromValues(key: string): any;
+ readInheritedValue(key: string, subkey: string): any;
+ writeValue(obj: object, key: string, value: any): any;
}
if (DEBUG) {
- Meta.prototype.writeValues = function(subkey, value) {
+ Meta.prototype.writeValues = function(subkey: string, value: any) {
assert(
- this.isMetaDestroyed() &&
- `Cannot set the value of \`${subkey}\` on \`${toString(
- this.source
- )}\` after it has been destroyed.`,
+ this.isMetaDestroyed()
+ ? `Cannot set the value of \`${subkey}\` on \`${toString(
+ this.source
+ )}\` after it has been destroyed.`
+ : '',
!this.isMetaDestroyed()
);
let map = this._getOrCreateOwnMap('_values');
map[subkey] = value;
};
- Meta.prototype.peekValues = function(subkey) {
+ Meta.prototype.peekValues = function(subkey: string) {
return this._findInherited('_values', subkey);
};
- Meta.prototype.deleteFromValues = function(subkey) {
+ Meta.prototype.deleteFromValues = function(subkey: string) {
delete this._getOrCreateOwnMap('_values')[subkey];
};
Meta.prototype.readInheritedValue = function(key, subkey) {
let internalKey = `_${key}`;
- let pointer = this;
+ let pointer: Meta | undefined = this;
while (pointer !== undefined) {
let map = pointer[internalKey];
@@ -538,10 +731,10 @@ if (DEBUG) {
return UNDEFINED;
};
- Meta.prototype.writeValue = function(obj, key, value) {
+ Meta.prototype.writeValue = function(obj: object, key: string, value: any) {
let descriptor = lookupDescriptor(obj, key);
let isMandatorySetter =
- descriptor !== null && descriptor.set && descriptor.set.isMandatorySetter;
+ descriptor !== null && descriptor.set && (descriptor.set as any).isMandatorySetter;
if (isMandatorySetter) {
this.writeValues(key, value);
@@ -554,7 +747,7 @@ if (DEBUG) {
const getPrototypeOf = Object.getPrototypeOf;
const metaStore = new WeakMap();
-export function setMeta(obj, meta) {
+export function setMeta(obj: object, meta: Meta) {
assert('Cannot call `setMeta` on null', obj !== null);
assert('Cannot call `setMeta` on undefined', obj !== undefined);
assert(
@@ -563,12 +756,12 @@ export function setMeta(obj, meta) {
);
if (DEBUG) {
- counters.setCalls++;
+ counters!.setCalls++;
}
metaStore.set(obj, meta);
}
-export function peekMeta(obj) {
+export function peekMeta(obj: object) {
assert('Cannot call `peekMeta` on null', obj !== null);
assert('Cannot call `peekMeta` on undefined', obj !== undefined);
assert(
@@ -582,15 +775,15 @@ export function peekMeta(obj) {
meta = metaStore.get(pointer);
// jshint loopfunc:true
if (DEBUG) {
- counters.peekCalls++;
+ counters!.peekCalls++;
}
if (meta !== undefined) {
return meta;
}
pointer = getPrototypeOf(pointer);
if (DEBUG) {
- counters.peekPrototypeWalks++;
+ counters!.peekPrototypeWalks++;
}
}
}
@@ -605,7 +798,7 @@ export function peekMeta(obj) {
@return {void}
@private
*/
-export function deleteMeta(obj) {
+export function deleteMeta(obj: object) {
assert('Cannot call `deleteMeta` on null', obj !== null);
assert('Cannot call `deleteMeta` on undefined', obj !== undefined);
assert(
@@ -614,7 +807,7 @@ export function deleteMeta(obj) {
);
if (DEBUG) {
- counters.deleteCalls++;
+ counters!.deleteCalls++;
}
let meta = peekMeta(obj);
@@ -641,7 +834,10 @@ export function deleteMeta(obj) {
the meta hash, allowing the method to avoid making an unnecessary copy.
@return {Object} the meta hash for an object
*/
-export function meta(obj) {
+export const meta: {
+ (obj: object): Meta;
+ _counters?: MetaCounters;
+} = function meta(obj: object) {
assert('Cannot call `meta` on null', obj !== null);
assert('Cannot call `meta` on undefined', obj !== undefined);
assert(
@@ -650,7 +846,7 @@ export function meta(obj) {
);
if (DEBUG) {
- counters.metaCalls++;
+ counters!.metaCalls++;
}
let maybeMeta = peekMeta(obj);
@@ -667,7 +863,7 @@ export function meta(obj) {
let newMeta = new Meta(obj, parent);
setMeta(obj, newMeta);
return newMeta;
-}
+};
if (DEBUG) {
meta._counters = counters;
@@ -682,7 +878,7 @@ if (DEBUG) {
@return {Descriptor}
@private
*/
-export function descriptorFor(obj, keyName, _meta) {
+export function descriptorFor(obj: object, keyName: string, _meta?: Meta) {
assert('Cannot call `descriptorFor` on null', obj !== null);
assert('Cannot call `descriptorFor` on undefined', obj !== undefined);
assert(
@@ -705,8 +901,31 @@ export function descriptorFor(obj, keyName, _meta) {
@return {boolean}
@private
*/
-export function isDescriptor(possibleDesc) {
+export function isDescriptor(possibleDesc: any | undefined | null): boolean {
+ // TODO make this return possibleDesc is Descriptor
return possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor;
}
export { counters };
+
+/*
+ When we render a rich template hierarchy, the set of events that
+ *might* happen tends to be much larger than the set of events that
+ actually happen. This implies that we should make listener creation &
+ destruction cheap, even at the cost of making event dispatch more
+ expensive.
+
+ Thus we store a new listener with a single push and no new
+ allocations, without even bothering to do deduplication -- we can
+ save that for dispatch time, if an event actually happens.
+ */
+function pushUniqueListener(destination: any[], source: any[], index: number) {
+ let target = source[index + 1];
+ let method = source[index + 2];
+ for (let destinationIndex = 0; destinationIndex < destination.length; destinationIndex += 3) {
+ if (destination[destinationIndex] === target && destination[destinationIndex + 1] === method) {
+ return;
+ }
+ }
+ destination.push(target, method, source[index + 3]);
+}
| true |
Other
|
emberjs
|
ember.js
|
a4fc9a5cdc9dacca9aa5e179d1885abb10e5c91a.json
|
start meta package
add types and change imports
|
packages/ember-metal/index.js
|
@@ -8,7 +8,7 @@ export {
} from './lib/computed';
export { default as alias } from './lib/alias';
export { deprecateProperty } from './lib/deprecate_property';
-export { descriptorFor, meta, peekMeta, deleteMeta } from './lib/meta';
+export { descriptorFor, meta, peekMeta, deleteMeta } from 'ember-meta';
export { PROXY_CONTENT, _getPath, get, getWithDefault } from './lib/property_get';
export { set, trySet } from './lib/property_set';
export {
| true |
Other
|
emberjs
|
ember.js
|
a4fc9a5cdc9dacca9aa5e179d1885abb10e5c91a.json
|
start meta package
add types and change imports
|
packages/ember-metal/lib/alias.js
|
@@ -5,7 +5,7 @@ import { get } from './property_get';
import { set } from './property_set';
import { Descriptor, defineProperty } from './properties';
import { ComputedProperty, getCacheFor } from './computed';
-import { meta as metaFor } from './meta';
+import { meta as metaFor } from 'ember-meta';
import { addDependentKeys, removeDependentKeys } from './dependent_keys';
const CONSUMED = {};
| true |
Other
|
emberjs
|
ember.js
|
a4fc9a5cdc9dacca9aa5e179d1885abb10e5c91a.json
|
start meta package
add types and change imports
|
packages/ember-metal/lib/array.js
|
@@ -1,6 +1,6 @@
import { notifyPropertyChange } from './property_events';
import { eachProxyArrayDidChange, eachProxyArrayWillChange } from './each_proxy';
-import { peekMeta } from './meta';
+import { peekMeta } from 'ember-meta';
import { sendEvent, removeListener, addListener } from './events';
import { peekCacheFor } from './computed';
import { get } from './property_get';
| true |
Other
|
emberjs
|
ember.js
|
a4fc9a5cdc9dacca9aa5e179d1885abb10e5c91a.json
|
start meta package
add types and change imports
|
packages/ember-metal/lib/chains.js
|
@@ -1,5 +1,5 @@
import { get } from './property_get';
-import { descriptorFor, meta as metaFor, peekMeta } from './meta';
+import { descriptorFor, meta as metaFor, peekMeta } from 'ember-meta';
import { watchKey, unwatchKey } from './watch_key';
import { getCachedValueFor } from './computed';
import { eachProxyFor } from './each_proxy';
| true |
Other
|
emberjs
|
ember.js
|
a4fc9a5cdc9dacca9aa5e179d1885abb10e5c91a.json
|
start meta package
add types and change imports
|
packages/ember-metal/lib/computed.js
|
@@ -2,7 +2,7 @@ import { inspect } from 'ember-utils';
import { assert, warn } from '@ember/debug';
import EmberError from '@ember/error';
import { set } from './property_set';
-import { meta as metaFor, peekMeta } from './meta';
+import { meta as metaFor, peekMeta } from 'ember-meta';
import { EMBER_METAL_TRACKED_PROPERTIES } from '@ember/canary-features';
import expandProperties from './expand_properties';
import { Descriptor, defineProperty } from './properties';
| true |
Other
|
emberjs
|
ember.js
|
a4fc9a5cdc9dacca9aa5e179d1885abb10e5c91a.json
|
start meta package
add types and change imports
|
packages/ember-metal/lib/each_proxy.js
|
@@ -1,7 +1,7 @@
import { assert } from '@ember/debug';
import { notifyPropertyChange } from './property_events';
import { addObserver, removeObserver } from './observer';
-import { meta, peekMeta } from './meta';
+import { meta, peekMeta } from 'ember-meta';
import { objectAt } from './array';
const EACH_PROXIES = new WeakMap();
| true |
Other
|
emberjs
|
ember.js
|
a4fc9a5cdc9dacca9aa5e179d1885abb10e5c91a.json
|
start meta package
add types and change imports
|
packages/ember-metal/lib/events.js
|
@@ -4,7 +4,7 @@
import { ENV } from 'ember-environment';
import { assert, deprecate } from '@ember/debug';
import { setListeners } from 'ember-utils';
-import { meta as metaFor, peekMeta } from './meta';
+import { meta as metaFor, peekMeta } from 'ember-meta';
/*
The event system uses a series of nested hashes to store listeners on an
| true |
Other
|
emberjs
|
ember.js
|
a4fc9a5cdc9dacca9aa5e179d1885abb10e5c91a.json
|
start meta package
add types and change imports
|
packages/ember-metal/lib/injected_property.js
|
@@ -1,7 +1,7 @@
import { getOwner } from 'ember-owner';
import { assert } from '@ember/debug';
import { ComputedProperty } from './computed';
-import { descriptorFor } from './meta';
+import { descriptorFor } from 'ember-meta';
import { EMBER_MODULE_UNIFICATION } from '@ember/canary-features';
/**
| true |
Other
|
emberjs
|
ember.js
|
a4fc9a5cdc9dacca9aa5e179d1885abb10e5c91a.json
|
start meta package
add types and change imports
|
packages/ember-metal/lib/meta_listeners.js
|
@@ -1,102 +0,0 @@
-/*
- When we render a rich template hierarchy, the set of events that
- *might* happen tends to be much larger than the set of events that
- actually happen. This implies that we should make listener creation &
- destruction cheap, even at the cost of making event dispatch more
- expensive.
-
- Thus we store a new listener with a single push and no new
- allocations, without even bothering to do deduplication -- we can
- save that for dispatch time, if an event actually happens.
- */
-
-export const protoMethods = {
- addToListeners(eventName, target, method, once) {
- if (this._listeners === undefined) {
- this._listeners = [];
- }
- this._listeners.push(eventName, target, method, once);
- },
-
- _finalizeListeners() {
- if (this._listenersFinalized) {
- return;
- }
- if (this._listeners === undefined) {
- this._listeners = [];
- }
- let pointer = this.parent;
- while (pointer !== undefined) {
- let listeners = pointer._listeners;
- if (listeners !== undefined) {
- this._listeners = this._listeners.concat(listeners);
- }
- if (pointer._listenersFinalized) {
- break;
- }
- pointer = pointer.parent;
- }
- this._listenersFinalized = true;
- },
-
- removeFromListeners(eventName, target, method) {
- let pointer = this;
- while (pointer !== undefined) {
- let listeners = pointer._listeners;
- if (listeners !== undefined) {
- for (let index = listeners.length - 4; index >= 0; index -= 4) {
- if (
- listeners[index] === eventName &&
- (!method || (listeners[index + 1] === target && listeners[index + 2] === method))
- ) {
- if (pointer === this) {
- listeners.splice(index, 4); // we are modifying our own list, so we edit directly
- } else {
- // we are trying to remove an inherited listener, so we do
- // just-in-time copying to detach our own listeners from
- // our inheritance chain.
- this._finalizeListeners();
- return this.removeFromListeners(eventName, target, method);
- }
- }
- }
- }
- if (pointer._listenersFinalized) {
- break;
- }
- pointer = pointer.parent;
- }
- },
-
- matchingListeners(eventName) {
- let pointer = this;
- let result;
- while (pointer !== undefined) {
- let listeners = pointer._listeners;
- if (listeners !== undefined) {
- for (let index = 0; index < listeners.length; index += 4) {
- if (listeners[index] === eventName) {
- result = result || [];
- pushUniqueListener(result, listeners, index);
- }
- }
- }
- if (pointer._listenersFinalized) {
- break;
- }
- pointer = pointer.parent;
- }
- return result;
- },
-};
-
-function pushUniqueListener(destination, source, index) {
- let target = source[index + 1];
- let method = source[index + 2];
- for (let destinationIndex = 0; destinationIndex < destination.length; destinationIndex += 3) {
- if (destination[destinationIndex] === target && destination[destinationIndex + 1] === method) {
- return;
- }
- }
- destination.push(target, method, source[index + 3]);
-}
| true |
Other
|
emberjs
|
ember.js
|
a4fc9a5cdc9dacca9aa5e179d1885abb10e5c91a.json
|
start meta package
add types and change imports
|
packages/ember-metal/lib/mixin.js
|
@@ -15,7 +15,7 @@ import {
import { assert } from '@ember/debug';
import { DEBUG } from '@glimmer/env';
import { ENV } from 'ember-environment';
-import { descriptorFor, meta as metaFor, peekMeta } from './meta';
+import { descriptorFor, meta as metaFor, peekMeta } from 'ember-meta';
import expandProperties from './expand_properties';
import { Descriptor, defineProperty } from './properties';
import { ComputedProperty } from './computed';
| true |
Other
|
emberjs
|
ember.js
|
a4fc9a5cdc9dacca9aa5e179d1885abb10e5c91a.json
|
start meta package
add types and change imports
|
packages/ember-metal/lib/properties.js
|
@@ -4,7 +4,7 @@
import { assert } from '@ember/debug';
import { DEBUG } from '@glimmer/env';
-import { descriptorFor, meta as metaFor, peekMeta, UNDEFINED } from './meta';
+import { descriptorFor, meta as metaFor, peekMeta, UNDEFINED } from 'ember-meta';
import { overrideChains } from './property_events';
// ..........................................................
| true |
Other
|
emberjs
|
ember.js
|
a4fc9a5cdc9dacca9aa5e179d1885abb10e5c91a.json
|
start meta package
add types and change imports
|
packages/ember-metal/lib/property_events.js
|
@@ -1,5 +1,5 @@
import { symbol } from 'ember-utils';
-import { descriptorFor, peekMeta } from './meta';
+import { descriptorFor, peekMeta } from 'ember-meta';
import { sendEvent } from './events';
import { markObjectAsDirty } from './tags';
import ObserverSet from './observer_set';
| true |
Other
|
emberjs
|
ember.js
|
a4fc9a5cdc9dacca9aa5e179d1885abb10e5c91a.json
|
start meta package
add types and change imports
|
packages/ember-metal/lib/property_get.js
|
@@ -6,7 +6,7 @@ import { assert, deprecate } from '@ember/debug';
import { HAS_NATIVE_PROXY, symbol } from 'ember-utils';
import { EMBER_METAL_TRACKED_PROPERTIES } from '@ember/canary-features';
import { isPath } from './path_cache';
-import { isDescriptor, descriptorFor } from './meta';
+import { isDescriptor, descriptorFor } from 'ember-meta';
import { getCurrentTracker } from './tracked';
import { tagForProperty } from './tags';
| true |
Other
|
emberjs
|
ember.js
|
a4fc9a5cdc9dacca9aa5e179d1885abb10e5c91a.json
|
start meta package
add types and change imports
|
packages/ember-metal/lib/property_set.js
|
@@ -6,7 +6,7 @@ import { getPossibleMandatoryProxyValue, _getPath as getPath } from './property_
import { notifyPropertyChange } from './property_events';
import { isPath } from './path_cache';
-import { isDescriptor, peekMeta, descriptorFor } from './meta';
+import { isDescriptor, peekMeta, descriptorFor } from 'ember-meta';
/**
@module @ember/object
| true |
Other
|
emberjs
|
ember.js
|
a4fc9a5cdc9dacca9aa5e179d1885abb10e5c91a.json
|
start meta package
add types and change imports
|
packages/ember-metal/lib/tags.js
|
@@ -1,7 +1,7 @@
import { CONSTANT_TAG, UpdatableTag, DirtyableTag, combine } from '@glimmer/reference';
import { isProxy } from 'ember-utils';
import { EMBER_METAL_TRACKED_PROPERTIES } from '@ember/canary-features';
-import { meta as metaFor } from './meta';
+import { meta as metaFor } from 'ember-meta';
import { backburner } from '@ember/runloop';
let hasViews = () => false;
| true |
Other
|
emberjs
|
ember.js
|
a4fc9a5cdc9dacca9aa5e179d1885abb10e5c91a.json
|
start meta package
add types and change imports
|
packages/ember-metal/lib/watch_key.js
|
@@ -1,6 +1,6 @@
import { lookupDescriptor } from 'ember-utils';
import { DEBUG } from '@glimmer/env';
-import { descriptorFor, isDescriptor, meta as metaFor, peekMeta, UNDEFINED } from './meta';
+import { descriptorFor, isDescriptor, meta as metaFor, peekMeta, UNDEFINED } from 'ember-meta';
import {
MANDATORY_SETTER_FUNCTION,
DEFAULT_GETTER_FUNCTION,
| true |
Other
|
emberjs
|
ember.js
|
a4fc9a5cdc9dacca9aa5e179d1885abb10e5c91a.json
|
start meta package
add types and change imports
|
packages/ember-metal/lib/watch_path.js
|
@@ -1,4 +1,4 @@
-import { meta as metaFor, peekMeta } from './meta';
+import { meta as metaFor, peekMeta } from 'ember-meta';
import { makeChainNode } from './chains';
export function watchPath(obj, keyPath, meta) {
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.