From d95cb4c7765e5ea0f9f09797d945df38b7966fe3 Mon Sep 17 00:00:00 2001 From: Stefan Penner Date: Sun, 12 Jun 2016 16:38:41 -0700 Subject: [PATCH] cleanup --- .../lib/system/application-instance.js | 16 +- .../lib/system/application.js | 42 +- .../lib/system/engine-instance.js | 8 +- .../ember-application/lib/system/engine.js | 28 +- .../ember-application/lib/system/resolver.js | 42 +- .../tests/system/application_instance_test.js | 60 +-- .../tests/system/application_test.js | 108 ++-- .../custom_resolver_test.js | 12 +- .../default_resolver_test.js | 50 +- .../normalization_test.js | 4 +- .../dependency_injection/to_string_test.js | 16 +- .../tests/system/dependency_injection_test.js | 16 +- .../tests/system/engine_initializers_test.js | 14 +- .../engine_instance_initializers_test.js | 16 +- .../tests/system/engine_instance_test.js | 18 +- .../tests/system/engine_test.js | 8 +- .../tests/system/initializers_test.js | 114 +++-- .../system/instance_initializers_test.js | 92 ++-- .../tests/system/logging_test.js | 28 +- .../tests/system/readiness_test.js | 27 +- .../tests/system/reset_test.js | 46 +- .../tests/system/visit_test.js | 26 +- packages/ember-debug/lib/index.js | 10 +- packages/ember-debug/tests/handlers-test.js | 4 +- packages/ember-debug/tests/main_test.js | 34 +- ...rn_if_using_stripped_feature_flags_test.js | 4 +- .../lib/container_debug_adapter.js | 14 +- .../lib/data_adapter.js | 85 ++-- .../tests/container_debug_adapter_test.js | 11 +- .../tests/data_adapter_test.js | 74 +-- .../lib/system/template.js | 7 +- .../tests/plugins-test.js | 2 +- .../components/attribute-bindings-test.js | 1 - .../components/curly-components-test.js | 8 +- .../tests/integration/helpers/-class-test.js | 1 - .../tests/integration/helpers/concat-test.js | 1 - .../tests/integration/helpers/hash-test.js | 1 - .../tests/integration/helpers/input-test.js | 1 - .../tests/integration/helpers/loc-test.js | 1 - ...nsform-closure-component-attrs-into-mut.js | 15 +- .../transform-component-attrs-into-mut.js | 19 +- .../transform-component-curly-to-readonly.js | 22 +- .../transform-old-class-binding-syntax.js | 14 +- .../lib/system/compile-options.js | 14 +- .../lib/system/compile.js | 2 +- .../lib/system/template.js | 6 +- .../tests/system/compile_test.js | 4 +- packages/ember-htmlbars/lib/compat.js | 2 +- packages/ember-htmlbars/lib/component.js | 10 +- .../ember-htmlbars/lib/components/link-to.js | 4 +- .../lib/components/text_field.js | 6 +- packages/ember-htmlbars/lib/env.js | 4 +- packages/ember-htmlbars/lib/helper.js | 6 +- packages/ember-htmlbars/lib/helpers.js | 2 +- .../lib/helpers/-join-classes.js | 2 +- .../lib/helpers/-normalize-class.js | 6 +- .../ember-htmlbars/lib/helpers/each-in.js | 10 +- packages/ember-htmlbars/lib/helpers/each.js | 6 +- .../lib/hooks/bind-shadow-scope.js | 2 +- .../ember-htmlbars/lib/hooks/component.js | 2 +- .../lib/hooks/destroy-render-node.js | 2 +- packages/ember-htmlbars/lib/hooks/element.js | 6 +- packages/ember-htmlbars/lib/hooks/get-root.js | 2 +- .../ember-htmlbars/lib/hooks/has-helper.js | 2 +- .../ember-htmlbars/lib/hooks/invoke-helper.js | 6 +- .../lib/hooks/link-render-node.js | 4 +- packages/ember-htmlbars/lib/hooks/subexpr.js | 22 +- packages/ember-htmlbars/lib/keywords.js | 2 +- .../lib/keywords/closure-action.js | 10 +- .../lib/keywords/closure-component.js | 2 +- .../ember-htmlbars/lib/keywords/debugger.js | 4 +- .../lib/keywords/element-action.js | 36 +- packages/ember-htmlbars/lib/keywords/get.js | 24 +- packages/ember-htmlbars/lib/keywords/input.js | 8 +- packages/ember-htmlbars/lib/keywords/mut.js | 8 +- .../ember-htmlbars/lib/keywords/outlet.js | 10 +- .../ember-htmlbars/lib/keywords/partial.js | 4 +- .../ember-htmlbars/lib/keywords/render.js | 42 +- .../ember-htmlbars/lib/keywords/unbound.js | 2 +- .../ember-htmlbars/lib/morphs/attr-morph.js | 2 +- packages/ember-htmlbars/lib/morphs/morph.js | 10 +- .../node-managers/component-node-manager.js | 12 +- .../lib/node-managers/view-node-manager.js | 24 +- packages/ember-htmlbars/lib/renderer.js | 24 +- .../lib/streams/built-in-helper.js | 4 +- .../lib/streams/class_name_binding.js | 16 +- .../ember-htmlbars/lib/streams/dependency.js | 4 +- .../lib/streams/helper-factory.js | 4 +- .../lib/streams/helper-instance.js | 4 +- .../ember-htmlbars/lib/streams/key-stream.js | 6 +- .../lib/streams/should_display.js | 10 +- packages/ember-htmlbars/lib/streams/stream.js | 56 +-- .../ember-htmlbars/lib/streams/subscriber.js | 8 +- packages/ember-htmlbars/lib/streams/utils.js | 70 ++- .../lib/system/append-templated-view.js | 4 +- .../lib/system/build-component-template.js | 38 +- .../ember-htmlbars/lib/system/dom-helper.js | 6 +- .../lib/system/instrumentation-support.js | 2 +- .../lib/system/lookup-helper.js | 15 +- .../ember-htmlbars/lib/system/render-view.js | 4 +- .../lib/utils/decode-each-key.js | 2 +- .../ember-htmlbars/lib/utils/new-stream.js | 2 +- .../ember-htmlbars/lib/utils/subscribe.js | 6 +- .../ember-htmlbars/lib/utils/update-scope.js | 4 +- packages/ember-htmlbars/lib/views/outlet.js | 6 +- .../tests/helpers/-html-safe-test.js | 4 +- .../tests/helpers/link-to_test.js | 16 +- .../tests/helpers/outlet_test.js | 58 +-- .../tests/helpers/render_test.js | 116 +++-- .../ember-htmlbars/tests/htmlbars_test.js | 6 +- .../integration/component_invocation_test.js | 12 +- .../integration/component_lifecycle_test.js | 40 +- .../tests/streams/concat_test.js | 12 +- .../tests/streams/key-stream-test.js | 44 +- .../tests/streams/proxy-stream-test.js | 6 +- .../tests/streams/should-display-test.js | 8 +- .../tests/streams/stream-test.js | 6 +- .../tests/system/lookup-helper_test.js | 48 +- packages/ember-htmlbars/tests/utils.js | 12 +- .../ember-htmlbars/tests/utils/string_test.js | 6 +- packages/ember-metal/lib/alias.js | 4 +- packages/ember-metal/lib/cache.js | 4 +- packages/ember-metal/lib/chains.js | 38 +- packages/ember-metal/lib/computed.js | 23 +- packages/ember-metal/lib/dependent_keys.js | 11 +- packages/ember-metal/lib/dictionary.js | 2 +- packages/ember-metal/lib/empty_object.js | 2 +- packages/ember-metal/lib/error.js | 6 +- packages/ember-metal/lib/events.js | 54 +- packages/ember-metal/lib/expand_properties.js | 12 +- packages/ember-metal/lib/get_properties.js | 6 +- packages/ember-metal/lib/index.js | 24 +- packages/ember-metal/lib/injected_property.js | 13 +- packages/ember-metal/lib/instrumentation.js | 66 ++- packages/ember-metal/lib/is_empty.js | 12 +- packages/ember-metal/lib/libraries.js | 12 +- packages/ember-metal/lib/map.js | 77 ++- packages/ember-metal/lib/merge.js | 10 +- packages/ember-metal/lib/meta.js | 2 +- packages/ember-metal/lib/meta_listeners.js | 6 +- packages/ember-metal/lib/mixin.js | 138 +++--- packages/ember-metal/lib/observer.js | 6 +- packages/ember-metal/lib/observer_set.js | 18 +- packages/ember-metal/lib/path_cache.js | 35 +- packages/ember-metal/lib/properties.js | 8 +- packages/ember-metal/lib/property_events.js | 46 +- packages/ember-metal/lib/property_get.js | 8 +- packages/ember-metal/lib/property_set.js | 6 +- packages/ember-metal/lib/replace.js | 20 +- packages/ember-metal/lib/run_loop.js | 28 +- packages/ember-metal/lib/set_properties.js | 8 +- packages/ember-metal/lib/tags.js | 2 +- packages/ember-metal/lib/utils.js | 50 +- packages/ember-metal/lib/watch_key.js | 22 +- packages/ember-metal/lib/watch_path.js | 4 +- packages/ember-metal/lib/watching.js | 10 +- .../tests/accessors/get_path_test.js | 4 +- .../tests/accessors/get_properties_test.js | 2 +- .../ember-metal/tests/accessors/get_test.js | 68 +-- .../tests/accessors/mandatory_setters_test.js | 32 +- .../tests/accessors/set_path_test.js | 8 +- .../ember-metal/tests/accessors/set_test.js | 42 +- packages/ember-metal/tests/alias_test.js | 14 +- packages/ember-metal/tests/assign_test.js | 8 +- .../ember-metal/tests/binding/connect_test.js | 57 +-- .../ember-metal/tests/binding/sync_test.js | 62 +-- packages/ember-metal/tests/cache_test.js | 14 +- packages/ember-metal/tests/chains_test.js | 7 +- packages/ember-metal/tests/computed_test.js | 130 +++-- .../ember-metal/tests/core/inspect_test.js | 4 +- packages/ember-metal/tests/error_test.js | 6 +- packages/ember-metal/tests/events_test.js | 70 +-- .../tests/expand_properties_test.js | 14 +- .../tests/injected_property_test.js | 10 +- .../ember-metal/tests/instrumentation_test.js | 24 +- packages/ember-metal/tests/is_blank_test.js | 6 +- packages/ember-metal/tests/is_empty_test.js | 10 +- packages/ember-metal/tests/is_none_test.js | 4 +- packages/ember-metal/tests/is_present_test.js | 6 +- packages/ember-metal/tests/libraries_test.js | 2 +- packages/ember-metal/tests/main_test.js | 4 +- packages/ember-metal/tests/map_test.js | 72 ++- packages/ember-metal/tests/meta_test.js | 4 +- .../tests/mixin/alias_method_test.js | 26 +- .../ember-metal/tests/mixin/apply_test.js | 12 +- .../ember-metal/tests/mixin/computed_test.js | 32 +- .../mixin/concatenated_properties_test.js | 42 +- .../ember-metal/tests/mixin/detect_test.js | 16 +- .../tests/mixin/introspection_test.js | 23 +- .../tests/mixin/merged_properties_test.js | 56 +-- .../ember-metal/tests/mixin/method_test.js | 52 +- .../ember-metal/tests/mixin/observer_test.js | 66 +-- .../ember-metal/tests/mixin/reopen_test.js | 12 +- .../ember-metal/tests/mixin/required_test.js | 4 +- .../ember-metal/tests/mixin/without_test.js | 6 +- packages/ember-metal/tests/observer_test.js | 246 ++++----- .../ember-metal/tests/performance_test.js | 10 +- packages/ember-metal/tests/properties_test.js | 20 +- packages/ember-metal/tests/props_helper.js | 14 +- .../tests/run_loop/add_queue_test.js | 4 +- .../tests/run_loop/debounce_test.js | 7 +- .../ember-metal/tests/run_loop/later_test.js | 64 +-- .../ember-metal/tests/run_loop/next_test.js | 26 +- .../ember-metal/tests/run_loop/once_test.js | 29 +- .../tests/run_loop/run_bind_test.js | 12 +- .../ember-metal/tests/run_loop/run_test.js | 4 +- .../tests/run_loop/schedule_test.js | 44 +- .../ember-metal/tests/run_loop/sync_test.js | 4 +- .../ember-metal/tests/run_loop/unwind_test.js | 8 +- .../tests/utils/can_invoke_test.js | 2 +- .../tests/utils/generate_guid_test.js | 2 +- .../ember-metal/tests/utils/guid_for_test.js | 48 +- .../tests/utils/try_invoke_test.js | 2 +- .../tests/watching/is_watching_test.js | 37 +- .../tests/watching/unwatch_test.js | 25 +- .../ember-metal/tests/watching/watch_test.js | 50 +- packages/ember-metal/tests/weak_map_test.js | 24 +- packages/ember-routing/lib/ext/controller.js | 14 +- packages/ember-routing/lib/location/api.js | 4 +- .../lib/location/auto_location.js | 48 +- .../lib/location/hash_location.js | 10 +- .../lib/location/history_location.js | 32 +- .../ember-routing/lib/services/routing.js | 24 +- packages/ember-routing/lib/system/cache.js | 9 +- packages/ember-routing/lib/system/dsl.js | 20 +- .../lib/system/generate_controller.js | 10 +- packages/ember-routing/lib/system/route.js | 266 +++++----- packages/ember-routing/lib/system/router.js | 238 ++++----- .../ember-routing/lib/system/router_state.js | 14 +- packages/ember-routing/lib/utils.js | 55 ++- .../tests/location/auto_location_test.js | 40 +- .../tests/location/hash_location_test.js | 20 +- .../tests/location/history_location_test.js | 10 +- .../tests/location/none_location_test.js | 4 +- .../ember-routing/tests/location/util_test.js | 12 +- .../tests/system/controller_for_test.js | 26 +- .../ember-routing/tests/system/dsl_test.js | 22 +- .../ember-routing/tests/system/route_test.js | 32 +- .../ember-routing/tests/system/router_test.js | 32 +- packages/ember-routing/tests/utils_test.js | 24 +- packages/ember-runtime/lib/compare.js | 20 +- .../lib/computed/computed_macros.js | 86 ++-- .../lib/computed/reduce_computed_macros.js | 104 ++-- .../lib/controllers/controller.js | 2 +- packages/ember-runtime/lib/copy.js | 2 +- packages/ember-runtime/lib/ext/function.js | 8 +- packages/ember-runtime/lib/inject.js | 15 +- packages/ember-runtime/lib/mixins/-proxy.js | 15 +- .../lib/mixins/action_handler.js | 25 +- packages/ember-runtime/lib/mixins/array.js | 56 +-- .../lib/mixins/container_proxy.js | 16 +- ...troller_content_model_alias_deprecation.js | 2 +- .../ember-runtime/lib/mixins/enumerable.js | 180 +++---- .../ember-runtime/lib/mixins/mutable_array.js | 48 +- .../lib/mixins/mutable_enumerable.js | 4 +- .../ember-runtime/lib/mixins/promise_proxy.js | 10 +- .../lib/mixins/registry_proxy.js | 34 +- .../lib/mixins/target_action_support.js | 32 +- .../ember-runtime/lib/system/array_proxy.js | 55 +-- .../ember-runtime/lib/system/each_proxy.js | 4 +- .../ember-runtime/lib/system/lazy_load.js | 10 +- .../ember-runtime/lib/system/namespace.js | 36 +- .../ember-runtime/lib/system/native_array.js | 14 +- packages/ember-runtime/lib/system/object.js | 6 +- packages/ember-runtime/lib/system/string.js | 46 +- packages/ember-runtime/lib/utils.js | 6 +- .../tests/computed/computed_macros_test.js | 50 +- .../computed/reduce_computed_macros_test.js | 132 ++--- .../tests/controllers/controller_test.js | 36 +- .../ember-runtime/tests/core/compare_test.js | 12 +- .../ember-runtime/tests/core/copy_test.js | 12 +- .../ember-runtime/tests/core/isEqual_test.js | 2 +- .../ember-runtime/tests/core/is_array_test.js | 18 +- .../ember-runtime/tests/core/is_empty_test.js | 2 +- .../ember-runtime/tests/core/type_of_test.js | 18 +- .../ember-runtime/tests/ext/function_test.js | 16 +- .../ember-runtime/tests/ext/mixin_test.js | 21 +- packages/ember-runtime/tests/inject_test.js | 10 +- .../mixins/observable/chained_test.js | 22 +- .../mixins/observable/propertyChanges_test.js | 8 +- .../tests/legacy_1x/system/binding_test.js | 34 +- .../legacy_1x/system/object/base_test.js | 2 +- .../legacy_1x/system/object/bindings_test.js | 35 +- .../system/object/concatenated_test.js | 51 +- .../tests/legacy_1x/system/run_loop_test.js | 10 +- .../ember-runtime/tests/mixins/array_test.js | 46 +- .../tests/mixins/comparable_test.js | 9 +- .../tests/mixins/copyable_test.js | 7 +- .../tests/mixins/enumerable_test.js | 76 ++- .../tests/mixins/mutable_array_test.js | 8 +- .../tests/mixins/mutable_enumerable_test.js | 7 +- .../tests/mixins/observable_test.js | 22 +- .../tests/mixins/promise_proxy_test.js | 72 ++- .../mixins/target_action_support_test.js | 34 +- packages/ember-runtime/tests/suites/array.js | 8 +- .../tests/suites/array/includes.js | 18 +- .../tests/suites/array/indexOf.js | 15 +- .../tests/suites/array/lastIndexOf.js | 41 +- .../tests/suites/array/objectAt.js | 13 +- .../ember-runtime/tests/suites/copyable.js | 2 +- .../tests/suites/copyable/copy.js | 6 +- .../tests/suites/copyable/frozenCopy.js | 4 +- .../ember-runtime/tests/suites/enumerable.js | 25 +- .../tests/suites/enumerable/any.js | 44 +- .../tests/suites/enumerable/compact.js | 6 +- .../tests/suites/enumerable/contains.js | 10 +- .../tests/suites/enumerable/every.js | 30 +- .../tests/suites/enumerable/filter.js | 26 +- .../tests/suites/enumerable/find.js | 30 +- .../tests/suites/enumerable/firstObject.js | 10 +- .../tests/suites/enumerable/forEach.js | 37 +- .../tests/suites/enumerable/includes.js | 10 +- .../tests/suites/enumerable/invoke.js | 4 +- .../tests/suites/enumerable/is_any.js | 12 +- .../tests/suites/enumerable/lastObject.js | 12 +- .../tests/suites/enumerable/map.js | 33 +- .../tests/suites/enumerable/mapBy.js | 6 +- .../tests/suites/enumerable/reduce.js | 14 +- .../tests/suites/enumerable/reject.js | 28 +- .../tests/suites/enumerable/sortBy.js | 10 +- .../tests/suites/enumerable/toArray.js | 4 +- .../tests/suites/enumerable/uniq.js | 6 +- .../tests/suites/enumerable/uniqBy.js | 4 +- .../tests/suites/enumerable/without.js | 8 +- .../tests/suites/mutable_array.js | 2 +- .../tests/suites/mutable_array/addObject.js | 29 +- .../tests/suites/mutable_array/clear.js | 11 +- .../tests/suites/mutable_array/insertAt.js | 86 ++-- .../tests/suites/mutable_array/popObject.js | 29 +- .../tests/suites/mutable_array/pushObject.js | 27 +- .../tests/suites/mutable_array/pushObjects.js | 8 +- .../tests/suites/mutable_array/removeAt.js | 53 +- .../suites/mutable_array/removeObject.js | 28 +- .../tests/suites/mutable_array/replace.js | 68 ++- .../suites/mutable_array/reverseObjects.js | 11 +- .../tests/suites/mutable_array/setObjects.js | 20 +- .../tests/suites/mutable_array/shiftObject.js | 29 +- .../suites/mutable_array/unshiftObject.js | 41 +- .../suites/mutable_array/unshiftObjects.js | 38 +- .../tests/suites/mutable_enumerable.js | 2 +- .../suites/mutable_enumerable/addObject.js | 37 +- .../suites/mutable_enumerable/removeObject.js | 36 +- .../mutable_enumerable/removeObjects.js | 81 ++- packages/ember-runtime/tests/suites/suite.js | 22 +- .../array_proxy/arranged_content_test.js | 71 ++- .../system/array_proxy/content_change_test.js | 28 +- .../system/array_proxy/content_update_test.js | 6 +- .../tests/system/array_proxy/length_test.js | 28 +- .../tests/system/array_proxy/suite_test.js | 4 +- .../tests/system/core_object_test.js | 6 +- .../tests/system/lazy_load_test.js | 26 +- .../tests/system/namespace/base_test.js | 30 +- .../native_array/copyable_suite_test.js | 4 +- .../tests/system/native_array/suite_test.js | 2 - .../tests/system/object/computed_test.js | 46 +- .../tests/system/object/create_test.js | 38 +- .../tests/system/object/destroy_test.js | 52 +- .../system/object/detectInstance_test.js | 14 +- .../tests/system/object/detect_test.js | 6 +- .../tests/system/object/events_test.js | 44 +- .../tests/system/object/extend_test.js | 42 +- .../tests/system/object/observer_test.js | 44 +- .../tests/system/object/reopenClass_test.js | 6 +- .../tests/system/object/reopen_test.js | 9 +- .../tests/system/object/strict-mode-test.js | 8 +- .../tests/system/object/subclasses_test.js | 8 +- .../tests/system/object/toString_test.js | 24 +- .../tests/system/object_proxy_test.js | 44 +- .../tests/system/string/loc_test.js | 2 +- .../lib/compat/precompile.js | 8 +- .../transform-angle-bracket-components.js | 8 +- .../plugins/transform-input-on-to-onEvent.js | 6 +- .../lib/plugins/transform-item-class.js | 17 +- .../plugins/transform-old-binding-syntax.js | 13 +- .../plugins/transform-top-level-components.js | 4 +- .../plugins/deprecate-render-model-test.js | 2 +- .../tests/plugins/transform-input-on-test.js | 8 +- .../tests/system/compile_test.js | 10 +- .../tests/system/template_test.js | 4 +- packages/ember-templates/lib/bootstrap.js | 10 +- .../ember-templates/tests/bootstrap_test.js | 66 +-- .../ember-testing/lib/adapters/adapter.js | 4 +- packages/ember-testing/lib/ext/application.js | 4 +- packages/ember-testing/lib/helpers/fill_in.js | 4 +- .../lib/helpers/find_with_assert.js | 2 +- .../ember-testing/lib/helpers/key_event.js | 2 +- .../lib/helpers/trigger_event.js | 8 +- packages/ember-testing/lib/helpers/visit.js | 2 +- packages/ember-testing/lib/helpers/wait.js | 2 +- packages/ember-testing/lib/initializers.js | 2 +- packages/ember-testing/lib/support.js | 2 +- .../lib/test/on_inject_helpers.js | 2 +- .../ember-views/lib/compat/attrs-proxy.js | 2 +- packages/ember-views/lib/index.js | 2 +- .../lib/mixins/class_names_support.js | 2 +- .../lib/mixins/instrumentation_support.js | 4 +- .../lib/mixins/legacy_view_support.js | 8 +- .../lib/mixins/template_support.js | 8 +- .../ember-views/lib/mixins/text_support.js | 14 +- .../lib/mixins/view_child_views_support.js | 12 +- .../lib/mixins/view_context_support.js | 4 +- .../lib/mixins/view_state_support.js | 4 +- .../ember-views/lib/mixins/view_support.js | 34 +- .../lib/mixins/visibility_support.js | 18 +- .../ember-views/lib/system/action_manager.js | 4 +- .../lib/system/event_dispatcher.js | 44 +- packages/ember-views/lib/system/jquery.js | 2 +- packages/ember-views/lib/system/platform.js | 6 +- packages/ember-views/lib/system/utils.js | 10 +- packages/ember-views/lib/views/core_view.js | 14 +- packages/ember-views/lib/views/states.js | 6 +- .../lib/views/states/destroying.js | 2 +- .../lib/views/states/has_element.js | 6 +- .../ember-views/lib/views/states/in_dom.js | 6 +- .../mixins/view_target_action_support_test.js | 6 +- .../tests/system/event_dispatcher_test.js | 48 +- .../tests/system/jquery_ext_test.js | 22 +- .../tests/system/view_utils_test.js | 18 +- .../tests/test-helpers/equal-html.js | 10 +- .../tests/test-helpers/get-element-style.js | 2 +- .../ember-views/tests/views/checkbox_test.js | 38 +- .../ember-views/tests/views/component_test.js | 52 +- .../tests/views/instrumentation_test.js | 4 +- .../ember-views/tests/views/text_area_test.js | 52 +- .../tests/views/text_field_test.js | 134 +++-- .../tests/views/view/actions_test.js | 14 +- .../tests/views/view/append_to_test.js | 48 +- .../views/view/class_name_bindings_test.js | 14 +- .../views/view/create_child_view_test.js | 20 +- .../tests/views/view/create_element_test.js | 15 +- .../tests/views/view/destroy_element_test.js | 26 +- .../tests/views/view/destroy_test.js | 14 +- .../tests/views/view/element_test.js | 14 +- .../tests/views/view/evented_test.js | 24 +- .../tests/views/view/inject_test.js | 4 +- .../tests/views/view/is_visible_test.js | 56 +-- .../tests/views/view/jquery_test.js | 10 +- .../tests/views/view/remove_test.js | 24 +- .../views/view/render_to_element_test.js | 16 +- .../tests/views/view/view_lifecycle_test.js | 115 ++--- .../ember/tests/application_lifecycle_test.js | 14 +- .../tests/component_registration_test.js | 66 ++- packages/ember/tests/controller_test.js | 8 +- .../ember/tests/default_initializers_test.js | 8 +- packages/ember/tests/global-api-test.js | 2 +- .../tests/helpers/helper_registration_test.js | 36 +- packages/ember/tests/helpers/link_to_test.js | 365 +++++--------- .../link_to_transitioning_classes_test.js | 28 +- .../link_to_with_query_params_test.js | 103 ++-- packages/ember/tests/homepage_example_test.js | 10 +- .../tests/integration/multiple-app-test.js | 12 +- packages/ember/tests/routing/basic_test.js | 467 ++++++++---------- .../ember/tests/routing/query_params_test.js | 216 ++++---- ..._dependent_state_with_query_params_test.js | 40 +- .../overlapping_query_params_test.js | 42 +- .../query_params_paramless_link_to_test.js | 20 +- .../ember/tests/routing/router_map_test.js | 10 +- .../ember/tests/routing/substates_test.js | 78 ++- .../ember/tests/routing/toplevel_dom_test.js | 8 +- .../ember/tests/view_instrumentation_test.js | 8 +- 460 files changed, 5328 insertions(+), 6362 deletions(-) diff --git a/packages/ember-application/lib/system/application-instance.js b/packages/ember-application/lib/system/application-instance.js index b850ea9ef68..76c835802ba 100644 --- a/packages/ember-application/lib/system/application-instance.js +++ b/packages/ember-application/lib/system/application-instance.js @@ -176,7 +176,7 @@ const ApplicationInstance = EngineInstance.extend({ @private */ startRouting() { - var router = get(this, 'router'); + let router = get(this, 'router'); router.startRouting(); this._didSetupRouter = true; }, @@ -194,7 +194,7 @@ const ApplicationInstance = EngineInstance.extend({ if (this._didSetupRouter) { return; } this._didSetupRouter = true; - var router = get(this, 'router'); + let router = get(this, 'router'); router.setupRouter(); }, @@ -206,7 +206,7 @@ const ApplicationInstance = EngineInstance.extend({ @private */ handleURL(url) { - var router = get(this, 'router'); + let router = get(this, 'router'); this.setupRouter(); return router.handleURL(url); @@ -216,11 +216,11 @@ const ApplicationInstance = EngineInstance.extend({ @private */ setupEventDispatcher() { - var dispatcher = this.lookup('event_dispatcher:main'); - var applicationCustomEvents = get(this.application, 'customEvents'); - var instanceCustomEvents = get(this, 'customEvents'); + let dispatcher = this.lookup('event_dispatcher:main'); + let applicationCustomEvents = get(this.application, 'customEvents'); + let instanceCustomEvents = get(this, 'customEvents'); - var customEvents = assign({}, applicationCustomEvents, instanceCustomEvents); + let customEvents = assign({}, applicationCustomEvents, instanceCustomEvents); dispatcher.setup(customEvents, this.rootElement); return dispatcher; @@ -482,7 +482,7 @@ Object.defineProperty(ApplicationInstance.prototype, 'container', { configurable: true, enumerable: false, get() { - var instance = this; + let instance = this; return { lookup() { deprecate( diff --git a/packages/ember-application/lib/system/application.js b/packages/ember-application/lib/system/application.js index d7999f261b0..42cf6e270e7 100644 --- a/packages/ember-application/lib/system/application.js +++ b/packages/ember-application/lib/system/application.js @@ -31,7 +31,7 @@ import RSVP from 'ember-runtime/ext/rsvp'; import Engine, { GLIMMER } from './engine'; import require from 'require'; -var librariesRegistered = false; +let librariesRegistered = false; let warnedAboutLegacyViewAddon = false; let warnedAboutLegacyControllerAddon = false; @@ -103,7 +103,7 @@ export function _resetLegacyAddonWarnings() { names by setting the application's `customEvents` property: ```javascript - var App = Ember.Application.create({ + let App = Ember.Application.create({ customEvents: { // add support for the paste event paste: 'paste' @@ -116,7 +116,7 @@ export function _resetLegacyAddonWarnings() { property: ```javascript - var App = Ember.Application.create({ + let App = Ember.Application.create({ customEvents: { // prevent listeners for mouseenter/mouseleave events mouseenter: null, @@ -134,7 +134,7 @@ export function _resetLegacyAddonWarnings() { should be delegated, set your application's `rootElement` property: ```javascript - var App = Ember.Application.create({ + let App = Ember.Application.create({ rootElement: '#ember-app' }); ``` @@ -177,7 +177,7 @@ export function _resetLegacyAddonWarnings() { the `LOG_TRANSITIONS_INTERNAL` flag: ```javascript - var App = Ember.Application.create({ + let App = Ember.Application.create({ LOG_TRANSITIONS: true, // basic logging of successful transitions LOG_TRANSITIONS_INTERNAL: true // detailed logging of all routing steps }); @@ -253,7 +253,7 @@ const Application = Engine.extend({ To add new events to be listened to: ```javascript - var App = Ember.Application.create({ + let App = Ember.Application.create({ customEvents: { // add support for the paste event paste: 'paste' @@ -264,7 +264,7 @@ const Application = Engine.extend({ To prevent default events from being listened to: ```javascript - var App = Ember.Application.create({ + let App = Ember.Application.create({ customEvents: { // remove support for mouseenter / mouseleave events mouseenter: null, @@ -299,7 +299,7 @@ const Application = Engine.extend({ classes. ```javascript - var App = Ember.Application.create({ + let App = Ember.Application.create({ ... }); @@ -499,7 +499,7 @@ const Application = Engine.extend({ Example: ```javascript - var App = Ember.Application.create(); + let App = Ember.Application.create(); App.deferReadiness(); @@ -623,7 +623,7 @@ const Application = Engine.extend({ Typical Example: ```javascript - var App; + let App; run(function() { App = Ember.Application.create(); @@ -651,7 +651,7 @@ const Application = Engine.extend({ to the app becoming ready. ```javascript - var App; + let App; run(function() { App = Ember.Application.create(); @@ -686,7 +686,7 @@ const Application = Engine.extend({ create new \`Ember.ApplicationInstance\`s and dispose them via their \`destroy()\` method instead.`, this._globalsMode && this.autoboot); - var instance = this.__deprecatedInstance__; + let instance = this.__deprecatedInstance__; this._readinessDeferrals = 1; this._bootPromise = null; @@ -1026,10 +1026,10 @@ Application.reopenClass({ commonSetupRegistry(registry); if (options[GLIMMER]) { - var glimmerSetupRegistry = require('ember-glimmer/setup-registry').setupApplicationRegistry; + let glimmerSetupRegistry = require('ember-glimmer/setup-registry').setupApplicationRegistry; glimmerSetupRegistry(registry); } else { - var htmlbarsSetupRegistry = require('ember-htmlbars/setup-registry').setupApplicationRegistry; + let htmlbarsSetupRegistry = require('ember-htmlbars/setup-registry').setupApplicationRegistry; htmlbarsSetupRegistry(registry); } @@ -1067,18 +1067,16 @@ function logLibraryVersions() { if (ENV.LOG_VERSION) { // we only need to see this once per Application#init ENV.LOG_VERSION = false; - var libs = libraries._registry; + let libs = libraries._registry; - var nameLengths = libs.map(function(item) { - return get(item, 'name.length'); - }); + let nameLengths = libs.map(item => get(item, 'name.length')); - var maxNameLength = Math.max.apply(this, nameLengths); + let maxNameLength = Math.max.apply(this, nameLengths); debug('-------------------------------'); - for (var i = 0; i < libs.length; i++) { - var lib = libs[i]; - var spaces = new Array(maxNameLength - lib.name.length + 1).join(' '); + for (let i = 0; i < libs.length; i++) { + let lib = libs[i]; + let spaces = new Array(maxNameLength - lib.name.length + 1).join(' '); debug([lib.name, spaces, ' : ', lib.version].join('')); } debug('-------------------------------'); diff --git a/packages/ember-application/lib/system/engine-instance.js b/packages/ember-application/lib/system/engine-instance.js index c82685ee000..99ba1ac87a6 100644 --- a/packages/ember-application/lib/system/engine-instance.js +++ b/packages/ember-application/lib/system/engine-instance.js @@ -175,16 +175,12 @@ if (isEnabled('ember-application-engines')) { 'event_dispatcher:main', P`-bucket-cache:main`, 'service:-routing' - ].forEach((key) => { - this.register(key, parent.resolveRegistration(key)); - }); + ].forEach(key => this.register(key, parent.resolveRegistration(key))); [ 'router:main', '-view-registry:main' - ].forEach((key) => { - this.register(key, parent.lookup(key), { instantiate: false }); - }); + ].forEach(key => this.register(key, parent.lookup(key), { instantiate: false })); } }); } diff --git a/packages/ember-application/lib/system/engine.js b/packages/ember-application/lib/system/engine.js index 8fb703f1c6f..17ec503b052 100644 --- a/packages/ember-application/lib/system/engine.js +++ b/packages/ember-application/lib/system/engine.js @@ -26,7 +26,7 @@ export const GLIMMER = symbol('GLIMMER'); function props(obj) { var properties = []; - for (var key in obj) { + for (let key in obj) { properties.push(key); } @@ -104,7 +104,7 @@ const Engine = Namespace.extend(RegistryProxy, { @return {Ember.Registry} the configured registry */ buildRegistry() { - var registry = this.__registry__ = this.constructor.buildRegistry(this, { + let registry = this.__registry__ = this.constructor.buildRegistry(this, { [GLIMMER]: this[GLIMMER] }); @@ -163,19 +163,17 @@ const Engine = Namespace.extend(RegistryProxy, { }, _runInitializer(bucketName, cb) { - var initializersByName = get(this.constructor, bucketName); - var initializers = props(initializersByName); - var graph = new DAG(); - var initializer; + let initializersByName = get(this.constructor, bucketName); + let initializers = props(initializersByName); + let graph = new DAG(); + let initializer; - for (var i = 0; i < initializers.length; i++) { + for (let i = 0; i < initializers.length; i++) { initializer = initializersByName[initializers[i]]; graph.addEdges(initializer.name, initializer, initializer.before, initializer.after); } - graph.topsort(function (vertex) { - cb(vertex.name, vertex.value); - }); + graph.topsort(vertex => cb(vertex.name, vertex.value)); } }); @@ -395,7 +393,7 @@ Engine.reopenClass({ @public */ buildRegistry(namespace, options = {}) { - var registry = new Registry({ + let registry = new Registry({ resolver: resolverFor(namespace) }); @@ -406,10 +404,10 @@ Engine.reopenClass({ commonSetupRegistry(registry); if (options[GLIMMER]) { - var glimmerSetupRegistry = require('ember-glimmer/setup-registry').setupEngineRegistry; + let glimmerSetupRegistry = require('ember-glimmer/setup-registry').setupEngineRegistry; glimmerSetupRegistry(registry); } else { - var htmlbarsSetupRegistry = require('ember-htmlbars/setup-registry').setupEngineRegistry; + let htmlbarsSetupRegistry = require('ember-htmlbars/setup-registry').setupEngineRegistry; htmlbarsSetupRegistry(registry); } @@ -466,7 +464,7 @@ function buildInitializerMethod(bucketName, humanName) { // prototypal inheritance. Without this, attempting to add initializers to the subclass would // pollute the parent class as well as other subclasses. if (this.superclass[bucketName] !== undefined && this.superclass[bucketName] === this[bucketName]) { - var attrs = {}; + let attrs = {}; attrs[bucketName] = Object.create(this[bucketName]); this.reopenClass(attrs); } @@ -503,8 +501,6 @@ function commonSetupRegistry(registry) { registry.injection('route', 'router', 'router:main'); - - // Register the routing service... registry.register('service:-routing', RoutingService); // Then inject the app router into it diff --git a/packages/ember-application/lib/system/resolver.js b/packages/ember-application/lib/system/resolver.js index 2209a7f77b0..fa05531f62b 100644 --- a/packages/ember-application/lib/system/resolver.js +++ b/packages/ember-application/lib/system/resolver.js @@ -69,7 +69,7 @@ export const Resolver = EmberObject.extend({ App = Ember.Application.create({ Resolver: Ember.DefaultResolver.extend({ resolveTemplate: function(parsedName) { - var resolvedTemplate = this._super(parsedName); + let resolvedTemplate = this._super(parsedName); if (resolvedTemplate) { return resolvedTemplate; } return Ember.TEMPLATES['not_found']; } @@ -212,7 +212,7 @@ export default EmberObject.extend({ }, _parseName(fullName) { - var [ + let [ type, fullNameWithoutType ] = fullName.split(':'); @@ -224,9 +224,9 @@ export default EmberObject.extend({ let dirname = lastSlashIndex !== -1 ? name.slice(0, lastSlashIndex) : null; if (type !== 'template' && lastSlashIndex !== -1) { - var parts = name.split('/'); + let parts = name.split('/'); name = parts[parts.length - 1]; - var namespaceName = capitalize(parts.slice(0, -1).join('.')); + let namespaceName = capitalize(parts.slice(0, -1).join('.')); root = Namespace.byName(namespaceName); assert( @@ -236,19 +236,19 @@ export default EmberObject.extend({ ); } - var resolveMethodName = fullNameWithoutType === 'main' ? 'Main' : classify(type); + let resolveMethodName = fullNameWithoutType === 'main' ? 'Main' : classify(type); if (!(name && type)) { throw new TypeError('Invalid fullName: `' + fullName + '`, must be of the form `type:name` '); } return { - fullName: fullName, - type: type, - fullNameWithoutType: fullNameWithoutType, + fullName, + type, + fullNameWithoutType, dirname, - name: name, - root: root, + name, + root, resolveMethodName: 'resolve' + resolveMethodName }; }, @@ -265,8 +265,8 @@ export default EmberObject.extend({ @public */ lookupDescription(fullName) { - var parsedName = this.parseName(fullName); - var description; + let parsedName = this.parseName(fullName); + let description; if (parsedName.type === 'template') { return 'template at ' + parsedName.fullNameWithoutType.replace(/\./g, '/'); @@ -311,7 +311,7 @@ export default EmberObject.extend({ @public */ resolveTemplate(parsedName) { - var templateName = parsedName.fullNameWithoutType.replace(/\./g, '/'); + let templateName = parsedName.fullNameWithoutType.replace(/\./g, '/'); return getTemplate(templateName) || getTemplate(decamelize(templateName)); }, @@ -367,10 +367,10 @@ export default EmberObject.extend({ @public */ resolveModel(parsedName) { - var className = classify(parsedName.name); - var factory = get(parsedName.root, className); + let className = classify(parsedName.name); + let factory = get(parsedName.root, className); - if (factory) { return factory; } + return factory; }, /** Look up the specified object (from parsedName) on the appropriate @@ -396,13 +396,13 @@ export default EmberObject.extend({ @public */ resolveOther(parsedName) { - var className = classify(parsedName.name) + classify(parsedName.type); - var factory = get(parsedName.root, className); - if (factory) { return factory; } + let className = classify(parsedName.name) + classify(parsedName.type); + let factory = get(parsedName.root, className); + return factory; }, resolveMain(parsedName) { - var className = classify(parsedName.type); + let className = classify(parsedName.type); return get(parsedName.root, className); }, @@ -413,7 +413,7 @@ export default EmberObject.extend({ @private */ _logLookup(found, parsedName) { - var symbol, padding; + let symbol, padding; if (found) { symbol = '[✓]'; diff --git a/packages/ember-application/tests/system/application_instance_test.js b/packages/ember-application/tests/system/application_instance_test.js index 623edf4b869..0b395d14615 100644 --- a/packages/ember-application/tests/system/application_instance_test.js +++ b/packages/ember-application/tests/system/application_instance_test.js @@ -7,14 +7,12 @@ import factory from 'container/tests/test-helpers/factory'; import isEnabled from 'ember-metal/features'; import { privatize as P } from 'container/registry'; -let app, appInstance; +let application, appInstance; QUnit.module('Ember.ApplicationInstance', { setup() { jQuery('#qunit-fixture').html('
HI
HI
'); - run(function() { - app = Application.create({ rootElement: '#one', router: null }); - }); + application = run(() => Application.create({ rootElement: '#one', router: null })); }, teardown() { @@ -24,27 +22,23 @@ QUnit.module('Ember.ApplicationInstance', { run(appInstance, 'destroy'); } - if (app) { - run(app, 'destroy'); + if (application) { + run(application, 'destroy'); } } }); QUnit.test('an application instance can be created based upon an application', function() { - run(function() { - appInstance = ApplicationInstance.create({ application: app }); - }); + appInstance = run(() => appInstance = ApplicationInstance.create({ application })); ok(appInstance, 'instance should be created'); - equal(appInstance.application, app, 'application should be set to parent'); + equal(appInstance.application, application, 'application should be set to parent'); }); QUnit.test('properties (and aliases) are correctly assigned for accessing the container and registry', function() { expect(9); - run(function() { - appInstance = ApplicationInstance.create({ application: app }); - }); + appInstance = run(() => ApplicationInstance.create({ application })); ok(appInstance, 'instance should be created'); ok(appInstance.__container__, '#__container__ is accessible'); @@ -57,7 +51,7 @@ QUnit.test('properties (and aliases) are correctly assigned for accessing the co ok(true, '#loookup alias is called correctly'); }; - expectDeprecation(function() { + expectDeprecation(() => { appInstance.container.lookup(); }, /Using `ApplicationInstance.container.lookup` is deprecated. Please use `ApplicationInstance.lookup` instead./); @@ -67,7 +61,7 @@ QUnit.test('properties (and aliases) are correctly assigned for accessing the co ok(true, '#register alias is called correctly'); }; - expectDeprecation(function() { + expectDeprecation(() => { appInstance.registry.register(); }, /Using `ApplicationInstance.registry.register` is deprecated. Please use `ApplicationInstance.register` instead./); }); @@ -75,15 +69,13 @@ QUnit.test('properties (and aliases) are correctly assigned for accessing the co QUnit.test('customEvents added to the application before setupEventDispatcher', function(assert) { assert.expect(1); - run(function() { - appInstance = ApplicationInstance.create({ application: app }); - }); + appInstance = run(() => ApplicationInstance.create({ application })); - app.customEvents = { + application.customEvents = { awesome: 'sauce' }; - var eventDispatcher = appInstance.lookup('event_dispatcher:main'); + let eventDispatcher = appInstance.lookup('event_dispatcher:main'); eventDispatcher.setup = function(events) { assert.equal(events.awesome, 'sauce'); }; @@ -94,15 +86,13 @@ QUnit.test('customEvents added to the application before setupEventDispatcher', QUnit.test('customEvents added to the application before setupEventDispatcher', function(assert) { assert.expect(1); - run(function() { - appInstance = ApplicationInstance.create({ application: app }); - }); + run(() => appInstance = ApplicationInstance.create({ application })); - app.customEvents = { + application.customEvents = { awesome: 'sauce' }; - var eventDispatcher = appInstance.lookup('event_dispatcher:main'); + let eventDispatcher = appInstance.lookup('event_dispatcher:main'); eventDispatcher.setup = function(events) { assert.equal(events.awesome, 'sauce'); }; @@ -113,15 +103,13 @@ QUnit.test('customEvents added to the application before setupEventDispatcher', QUnit.test('customEvents added to the application instance before setupEventDispatcher', function(assert) { assert.expect(1); - run(function() { - appInstance = ApplicationInstance.create({ application: app }); - }); + appInstance = run(() => ApplicationInstance.create({ application })); appInstance.customEvents = { awesome: 'sauce' }; - var eventDispatcher = appInstance.lookup('event_dispatcher:main'); + let eventDispatcher = appInstance.lookup('event_dispatcher:main'); eventDispatcher.setup = function(events) { assert.equal(events.awesome, 'sauce'); }; @@ -132,9 +120,7 @@ QUnit.test('customEvents added to the application instance before setupEventDisp QUnit.test('unregistering a factory clears all cached instances of that factory', function(assert) { assert.expect(3); - run(function() { - appInstance = ApplicationInstance.create({ application: app }); - }); + appInstance = run(() => ApplicationInstance.create({ application })); let PostController = factory(); @@ -159,10 +145,10 @@ if (isEnabled('ember-application-engines')) { let ChatEngine = Engine.extend(); let chatEngineInstance; - app.register('engine:chat', ChatEngine); + application.register('engine:chat', ChatEngine); - run(function() { - appInstance = ApplicationInstance.create({ application: app }); + run(() => { + appInstance = ApplicationInstance.create({ application }); chatEngineInstance = appInstance.buildChildEngineInstance('chat'); }); @@ -175,7 +161,7 @@ if (isEnabled('ember-application-engines')) { 'event_dispatcher:main', P`-bucket-cache:main`, 'service:-routing' - ].forEach((key) => { + ].forEach(key => { assert.strictEqual( chatEngineInstance.resolveRegistration(key), appInstance.resolveRegistration(key), @@ -185,7 +171,7 @@ if (isEnabled('ember-application-engines')) { [ 'router:main', '-view-registry:main' - ].forEach((key) => { + ].forEach(key => { assert.strictEqual( chatEngineInstance.lookup(key), appInstance.lookup(key), diff --git a/packages/ember-application/tests/system/application_test.js b/packages/ember-application/tests/system/application_test.js index ea10edf43a5..52b80975345 100644 --- a/packages/ember-application/tests/system/application_test.js +++ b/packages/ember-application/tests/system/application_test.js @@ -21,9 +21,9 @@ import { setTemplates, set as setTemplate } from 'ember-templates/template_regis import { privatize as P } from 'container/registry'; import { verifyInjection, verifyRegistration } from '../test-helpers/registry-check'; -var trim = jQuery.trim; +let { trim } = jQuery; -var app, application, originalLookup, originalDebug, originalWarn; +let app, application, originalLookup, originalDebug, originalWarn; QUnit.module('Ember.Application', { setup() { @@ -32,9 +32,7 @@ QUnit.module('Ember.Application', { originalWarn = getDebugFunction('warn'); jQuery('#qunit-fixture').html('
HI
HI
'); - run(function() { - application = Application.create({ rootElement: '#one', router: null }); - }); + application = run(() => Application.create({ rootElement: '#one', router: null })); }, teardown() { @@ -55,51 +53,41 @@ QUnit.module('Ember.Application', { }); QUnit.test('you can make a new application in a non-overlapping element', function() { - run(function() { - app = Application.create({ rootElement: '#two', router: null }); - }); + app = run(() => Application.create({ rootElement: '#two', router: null })); run(app, 'destroy'); ok(true, 'should not raise'); }); QUnit.test('you cannot make a new application that is a parent of an existing application', function() { - expectAssertion(function() { - run(function() { - Application.create({ rootElement: '#qunit-fixture' }); - }); + expectAssertion(() => { + run(() => Application.create({ rootElement: '#qunit-fixture' })); }); }); QUnit.test('you cannot make a new application that is a descendant of an existing application', function() { - expectAssertion(function() { - run(function() { - Application.create({ rootElement: '#one-child' }); - }); + expectAssertion(() => { + run(() => Application.create({ rootElement: '#one-child' })); }); }); QUnit.test('you cannot make a new application that is a duplicate of an existing application', function() { - expectAssertion(function() { - run(function() { - Application.create({ rootElement: '#one' }); - }); + expectAssertion(() => { + run(() => Application.create({ rootElement: '#one' })); }); }); QUnit.test('you cannot make two default applications without a rootElement error', function() { - expectAssertion(function() { - run(function() { - Application.create({ router: false }); - }); + expectAssertion(() => { + run(() => Application.create({ router: false })); }); }); QUnit.test('acts like a namespace', function() { - var lookup = context.lookup = {}; + let lookup = context.lookup = {}; - run(function() { - app = lookup.TestApp = Application.create({ rootElement: '#two', router: false }); + app = run(() => { + return lookup.TestApp = Application.create({ rootElement: '#two', router: false }); }); setNamespaceSearchDisabled(false); @@ -116,7 +104,7 @@ QUnit.test('includes deprecated access to `application.registry`', function() { ok(true, '#register alias is called correctly'); }; - expectDeprecation(function() { + expectDeprecation(() => { application.registry.register(); }, /Using `Application.registry.register` is deprecated. Please use `Application.register` instead./); }); @@ -202,7 +190,7 @@ QUnit.module('Ember.Application initialization', { }); QUnit.test('initialized application goes to initial route', function() { - run(function() { + run(() => { app = Application.create({ rootElement: '#qunit-fixture' }); @@ -226,18 +214,18 @@ QUnit.test('initialized application goes to initial route', function() { QUnit.test('ready hook is called before routing begins', function() { expect(2); - run(function() { + run(() => { function registerRoute(application, name, callback) { - var route = EmberRoute.extend({ + let route = EmberRoute.extend({ activate: callback }); application.register('route:' + name, route); } - var MyApplication = Application.extend({ + let MyApplication = Application.extend({ ready() { - registerRoute(this, 'index', function() { + registerRoute(this, 'index', () => { ok(true, 'last-minute route is activated'); }); } @@ -251,14 +239,12 @@ QUnit.test('ready hook is called before routing begins', function() { location: 'none' }); - registerRoute(app, 'application', function() { - ok(true, 'normal route is activated'); - }); + registerRoute(app, 'application', () => ok(true, 'normal route is activated')); }); }); QUnit.test('initialize application via initialize call', function() { - run(function() { + run(() => { app = Application.create({ rootElement: '#qunit-fixture' }); @@ -274,13 +260,13 @@ QUnit.test('initialize application via initialize call', function() { // This is not a public way to access the container; we just // need to make some assertions about the created router - var router = app.__container__.lookup('router:main'); + let router = app.__container__.lookup('router:main'); equal(router instanceof Router, true, 'Router was set from initialize call'); equal(router.location instanceof NoneLocation, true, 'Location was set from location implementation name'); }); QUnit.test('initialize application with stateManager via initialize call from Router class', function() { - run(function() { + run(() => { app = Application.create({ rootElement: '#qunit-fixture' }); @@ -292,13 +278,13 @@ QUnit.test('initialize application with stateManager via initialize call from Ro app.register('template:application', compile('

Hello!

')); }); - var router = app.__container__.lookup('router:main'); + let router = app.__container__.lookup('router:main'); equal(router instanceof Router, true, 'Router was set from initialize call'); equal(jQuery('#qunit-fixture h1').text(), 'Hello!'); }); QUnit.test('ApplicationView is inserted into the page', function() { - run(function() { + run(() => { app = Application.create({ rootElement: '#qunit-fixture' }); @@ -317,8 +303,8 @@ QUnit.test('ApplicationView is inserted into the page', function() { QUnit.test('Minimal Application initialized with just an application template', function() { jQuery('#qunit-fixture').html(''); - run(function () { - app = Application.create({ + app = run(() => { + return Application.create({ rootElement: '#qunit-fixture' }); }); @@ -332,18 +318,16 @@ QUnit.test('enable log of libraries with an ENV var', function() { return; } - var messages = []; + let messages = []; ENV.LOG_VERSION = true; - setDebugFunction('debug', function(message) { - messages.push(message); - }); + setDebugFunction('debug', message => messages.push(message)); libraries.register('my-lib', '2.0.0a'); - run(function() { - app = Application.create({ + app = run(() => { + return Application.create({ rootElement: '#qunit-fixture' }); }); @@ -356,17 +340,15 @@ QUnit.test('enable log of libraries with an ENV var', function() { }); QUnit.test('disable log version of libraries with an ENV var', function() { - var logged = false; + let logged = false; ENV.LOG_VERSION = false; - setDebugFunction('debug', function(message) { - logged = true; - }); + setDebugFunction('debug', () => logged = true); jQuery('#qunit-fixture').empty(); - run(function() { + run(() => { app = Application.create({ rootElement: '#qunit-fixture' }); @@ -380,9 +362,9 @@ QUnit.test('disable log version of libraries with an ENV var', function() { }); QUnit.test('can resolve custom router', function() { - var CustomRouter = Router.extend(); + let CustomRouter = Router.extend(); - var CustomResolver = DefaultResolver.extend({ + let Resolver = DefaultResolver.extend({ resolveMain(parsedName) { if (parsedName.type === 'router') { return CustomRouter; @@ -392,9 +374,9 @@ QUnit.test('can resolve custom router', function() { } }); - app = run(function() { + app = run(() => { return Application.create({ - Resolver: CustomResolver + Resolver }); }); @@ -402,20 +384,18 @@ QUnit.test('can resolve custom router', function() { }); QUnit.test('can specify custom router', function() { - var CustomRouter = Router.extend(); - - app = run(function() { + app = run(() => { return Application.create({ - Router: CustomRouter + Router: Router.extend() }); }); - ok(app.__container__.lookup('router:main') instanceof CustomRouter, 'application resolved the correct router'); + ok(app.__container__.lookup('router:main') instanceof Router, 'application resolved the correct router'); }); QUnit.test('does not leak itself in onLoad._loaded', function() { equal(_loaded.application, undefined); - var app = run(Application, 'create'); + let app = run(Application, 'create'); equal(_loaded.application, app); run(app, 'destroy'); equal(_loaded.application, undefined); diff --git a/packages/ember-application/tests/system/dependency_injection/custom_resolver_test.js b/packages/ember-application/tests/system/dependency_injection/custom_resolver_test.js index ddec6a41821..73d453e18ae 100644 --- a/packages/ember-application/tests/system/dependency_injection/custom_resolver_test.js +++ b/packages/ember-application/tests/system/dependency_injection/custom_resolver_test.js @@ -4,15 +4,15 @@ import Application from 'ember-application/system/application'; import DefaultResolver from 'ember-application/system/resolver'; import { compile } from 'ember-template-compiler/tests/utils/helpers'; -var application; +let application; QUnit.module('Ember.Application Dependency Injection – customResolver', { setup() { - var fallbackTemplate = compile('

Fallback

'); + let fallbackTemplate = compile('

Fallback

'); - var Resolver = DefaultResolver.extend({ + let Resolver = DefaultResolver.extend({ resolveTemplate(resolvable) { - var resolvedTemplate = this._super(resolvable); + let resolvedTemplate = this._super(resolvable); if (resolvedTemplate) { return resolvedTemplate; } if (resolvable.fullNameWithoutType === 'application') { return fallbackTemplate; @@ -22,14 +22,14 @@ QUnit.module('Ember.Application Dependency Injection – customResolver', { } }); - application = run(function() { + application = run(() => { return Application.create({ Resolver: Resolver, rootElement: '#qunit-fixture' - }); }); }, + teardown() { run(application, 'destroy'); } diff --git a/packages/ember-application/tests/system/dependency_injection/default_resolver_test.js b/packages/ember-application/tests/system/dependency_injection/default_resolver_test.js index 3f0cf54dce5..3678acdad55 100644 --- a/packages/ember-application/tests/system/dependency_injection/default_resolver_test.js +++ b/packages/ember-application/tests/system/dependency_injection/default_resolver_test.js @@ -17,7 +17,7 @@ import { } from 'ember-htmlbars/helpers'; import { setTemplates, set as setTemplate } from 'ember-templates/template_registry'; -var registry, locator, application, originalLookup, originalInfo; +let registry, locator, application, originalLookup, originalInfo; QUnit.module('Ember.Application Dependency Injection - default resolver', { setup() { @@ -33,7 +33,7 @@ QUnit.module('Ember.Application Dependency Injection - default resolver', { setTemplates({}); context.lookup = originalLookup; run(application, 'destroy'); - var UserInterfaceNamespace = Namespace.NAMESPACES_BY_ID['UserInterface']; + let UserInterfaceNamespace = Namespace.NAMESPACES_BY_ID['UserInterface']; if (UserInterfaceNamespace) { run(UserInterfaceNamespace, 'destroy'); } setDebugFunction('info', originalInfo); @@ -41,10 +41,10 @@ QUnit.module('Ember.Application Dependency Injection - default resolver', { }); QUnit.test('the default resolver can look things up in other namespaces', function() { - var UserInterface = context.lookup.UserInterface = Namespace.create(); + let UserInterface = context.lookup.UserInterface = Namespace.create(); UserInterface.NavigationController = Controller.extend(); - var nav = locator.lookup('controller:userInterface/navigation'); + let nav = locator.lookup('controller:userInterface/navigation'); ok(nav instanceof UserInterface.NavigationController, 'the result should be an instance of the specified class'); }); @@ -108,7 +108,7 @@ QUnit.test('the default resolver resolves helpers', function() { }); QUnit.test('the default resolver resolves container-registered helpers', function() { - let shorthandHelper = makeHelper(function() {}); + let shorthandHelper = makeHelper(() => {}); let helper = Helper.extend(); application.register('helper:shorthand', shorthandHelper); @@ -123,12 +123,12 @@ QUnit.test('the default resolver resolves container-registered helpers', functio }); QUnit.test('the default resolver resolves helpers on the namespace', function() { - let ShorthandHelper = makeHelper(function() {}); + let ShorthandHelper = makeHelper(() => {}); let CompleteHelper = Helper.extend(); let LegacyHTMLBarsBoundHelper; - expectDeprecation(function() { - LegacyHTMLBarsBoundHelper = makeHTMLBarsBoundHelper(function() {}); + expectDeprecation(() => { + LegacyHTMLBarsBoundHelper = makeHTMLBarsBoundHelper(() => {}); }, 'Using `Ember.HTMLBars.makeBoundHelper` is deprecated. Please refactor to use `Ember.Helper` or `Ember.Helper.helper`.'); application.ShorthandHelper = ShorthandHelper; @@ -151,14 +151,14 @@ QUnit.test('the default resolver resolves to the same instance, no matter the no }); QUnit.test('the default resolver throws an error if the fullName to resolve is invalid', function() { - throws(function() { registry.resolve(undefined);}, TypeError, /Invalid fullName/ ); - throws(function() { registry.resolve(null); }, TypeError, /Invalid fullName/ ); - throws(function() { registry.resolve(''); }, TypeError, /Invalid fullName/ ); - throws(function() { registry.resolve(''); }, TypeError, /Invalid fullName/ ); - throws(function() { registry.resolve(':'); }, TypeError, /Invalid fullName/ ); - throws(function() { registry.resolve('model'); }, TypeError, /Invalid fullName/ ); - throws(function() { registry.resolve('model:'); }, TypeError, /Invalid fullName/ ); - throws(function() { registry.resolve(':type'); }, TypeError, /Invalid fullName/ ); + throws(() => { registry.resolve(undefined);}, TypeError, /Invalid fullName/ ); + throws(() => { registry.resolve(null); }, TypeError, /Invalid fullName/ ); + throws(() => { registry.resolve(''); }, TypeError, /Invalid fullName/ ); + throws(() => { registry.resolve(''); }, TypeError, /Invalid fullName/ ); + throws(() => { registry.resolve(':'); }, TypeError, /Invalid fullName/ ); + throws(() => { registry.resolve('model'); }, TypeError, /Invalid fullName/ ); + throws(() => { registry.resolve('model:'); }, TypeError, /Invalid fullName/ ); + throws(() => { registry.resolve(':type'); }, TypeError, /Invalid fullName/ ); }); QUnit.test('the default resolver logs hits if `LOG_RESOLVER` is set', function() { @@ -171,7 +171,7 @@ QUnit.test('the default resolver logs hits if `LOG_RESOLVER` is set', function() application.LOG_RESOLVER = true; application.ScoobyDoo = EmberObject.extend(); - application.toString = function() { return 'App'; }; + application.toString = () => 'App'; setDebugFunction('info', function(symbol, name, padding, lookupDescription) { equal(symbol, '[✓]', 'proper symbol is printed when a module is found'); @@ -191,7 +191,7 @@ QUnit.test('the default resolver logs misses if `LOG_RESOLVER` is set', function expect(3); application.LOG_RESOLVER = true; - application.toString = function() { return 'App'; }; + application.toString = () => 'App'; setDebugFunction('info', function(symbol, name, padding, lookupDescription) { equal(symbol, '[ ]', 'proper symbol is printed when a module is not found'); @@ -208,13 +208,11 @@ QUnit.test('doesn\'t log without LOG_RESOLVER', function() { return; } - var infoCount = 0; + let infoCount = 0; application.ScoobyDoo = EmberObject.extend(); - setDebugFunction('info', function(symbol, name) { - infoCount = infoCount + 1; - }); + setDebugFunction('info', (symbol, name) => infoCount = infoCount + 1 ); registry.resolve('doo:scooby'); registry.resolve('doo:scrappy'); @@ -222,7 +220,7 @@ QUnit.test('doesn\'t log without LOG_RESOLVER', function() { }); QUnit.test('lookup description', function() { - application.toString = function() { return 'App'; }; + application.toString = () => 'App'; equal(registry.describe('controller:foo'), 'App.FooController', 'Type gets appended at the end'); equal(registry.describe('controller:foo.bar'), 'App.FooBarController', 'dots are removed'); @@ -232,9 +230,7 @@ QUnit.test('lookup description', function() { QUnit.test('assertion for routes without isRouteFactory property', function() { application.FooRoute = Component.extend(); - expectAssertion(function() { - registry.resolve(`route:foo`); - }, /to resolve to an Ember.Route/, 'Should assert'); + expectAssertion(() => registry.resolve(`route:foo`), /to resolve to an Ember.Route/, 'Should assert'); }); QUnit.test('no assertion for routes that extend from Ember.Route', function() { @@ -298,7 +294,7 @@ QUnit.test('knownForType returns each item for a given type found', function() { QUnit.test('knownForType is not required to be present on the resolver', function() { delete registry.resolver.knownForType; - registry.resolver.knownForType('helper', function() { }); + registry.resolver.knownForType('helper', () => { }); ok(true, 'does not error'); }); diff --git a/packages/ember-application/tests/system/dependency_injection/normalization_test.js b/packages/ember-application/tests/system/dependency_injection/normalization_test.js index a989e5b4335..da23f52b1a8 100644 --- a/packages/ember-application/tests/system/dependency_injection/normalization_test.js +++ b/packages/ember-application/tests/system/dependency_injection/normalization_test.js @@ -1,7 +1,7 @@ import run from 'ember-metal/run_loop'; import Application from 'ember-application/system/application'; -var application, registry; +let application, registry; QUnit.module('Ember.Application Dependency Injection – normalization', { setup() { @@ -39,7 +39,7 @@ QUnit.test('normalization', function() { }); QUnit.test('normalization is indempotent', function() { - var examples = ['controller:posts', 'controller:posts.post.index', 'controller:blog/posts.post_index', 'template:foo_bar']; + let examples = ['controller:posts', 'controller:posts.post.index', 'controller:blog/posts.post_index', 'template:foo_bar']; examples.forEach((example) => { equal(registry.normalize(registry.normalize(example)), registry.normalize(example)); diff --git a/packages/ember-application/tests/system/dependency_injection/to_string_test.js b/packages/ember-application/tests/system/dependency_injection/to_string_test.js index fe6775bcf82..8c7c308c7b2 100644 --- a/packages/ember-application/tests/system/dependency_injection/to_string_test.js +++ b/packages/ember-application/tests/system/dependency_injection/to_string_test.js @@ -5,7 +5,7 @@ import EmberObject from 'ember-runtime/system/object'; import DefaultResolver from 'ember-application/system/resolver'; import { guidFor } from 'ember-metal/utils'; -var originalLookup, App, originalModelInjections; +let originalLookup, App, originalModelInjections; QUnit.module('Ember.Application Dependency Injection – toString', { setup() { @@ -14,7 +14,7 @@ QUnit.module('Ember.Application Dependency Injection – toString', { originalLookup = context.lookup; - run(function() { + run(() => { App = Application.create(); context.lookup = { App: App @@ -32,13 +32,13 @@ QUnit.module('Ember.Application Dependency Injection – toString', { }); QUnit.test('factories', function() { - var PostFactory = App.__container__.lookupFactory('model:post'); + let PostFactory = App.__container__.lookupFactory('model:post'); equal(PostFactory.toString(), 'App.Post', 'expecting the model to be post'); }); QUnit.test('instances', function() { - var post = App.__container__.lookup('model:post'); - var guid = guidFor(post); + let post = App.__container__.lookup('model:post'); + let guid = guidFor(post); equal(post.toString(), '', 'expecting the model to be post'); }); @@ -46,7 +46,7 @@ QUnit.test('instances', function() { QUnit.test('with a custom resolver', function() { run(App, 'destroy'); - run(function() { + run(() => { App = Application.create({ Resolver: DefaultResolver.extend({ makeToString(factory, fullName) { @@ -58,8 +58,8 @@ QUnit.test('with a custom resolver', function() { App.register('model:peter', EmberObject.extend()); - var peter = App.__container__.lookup('model:peter'); - var guid = guidFor(peter); + let peter = App.__container__.lookup('model:peter'); + let guid = guidFor(peter); equal(peter.toString(), '', 'expecting the supermodel to be peter'); }); diff --git a/packages/ember-application/tests/system/dependency_injection_test.js b/packages/ember-application/tests/system/dependency_injection_test.js index 09fd72296c7..c7b3d498990 100644 --- a/packages/ember-application/tests/system/dependency_injection_test.js +++ b/packages/ember-application/tests/system/dependency_injection_test.js @@ -3,10 +3,10 @@ import run from 'ember-metal/run_loop'; import EmberObject from 'ember-runtime/system/object'; import Application from 'ember-application/system/application'; -var EmberApplication = Application; +let EmberApplication = Application; -var originalLookup = context.lookup; -var registry, locator, lookup, application, originalModelInjections; +let originalLookup = context.lookup; +let registry, locator, lookup, application, originalModelInjections; QUnit.module('Ember.Application Dependency Injection', { setup() { @@ -41,8 +41,8 @@ QUnit.module('Ember.Application Dependency Injection', { }); QUnit.test('container lookup is normalized', function() { - var dotNotationController = locator.lookup('controller:post.index'); - var camelCaseController = locator.lookup('controller:postIndex'); + let dotNotationController = locator.lookup('controller:post.index'); + let camelCaseController = locator.lookup('controller:postIndex'); ok(dotNotationController instanceof application.PostIndexController); ok(camelCaseController instanceof application.PostIndexController); @@ -66,9 +66,9 @@ QUnit.test('injections', function() { application.inject('model', 'fruit', 'fruit:favorite'); application.inject('model:user', 'communication', 'communication:main'); - var user = locator.lookup('model:user'); - var person = locator.lookup('model:person'); - var fruit = locator.lookup('fruit:favorite'); + let user = locator.lookup('model:user'); + let person = locator.lookup('model:person'); + let fruit = locator.lookup('fruit:favorite'); equal(user.get('fruit'), fruit); equal(person.get('fruit'), fruit); diff --git a/packages/ember-application/tests/system/engine_initializers_test.js b/packages/ember-application/tests/system/engine_initializers_test.js index 48b840309a2..fe5797fdd1b 100644 --- a/packages/ember-application/tests/system/engine_initializers_test.js +++ b/packages/ember-application/tests/system/engine_initializers_test.js @@ -1,16 +1,14 @@ import run from 'ember-metal/run_loop'; import Engine from 'ember-application/system/engine'; -let MyEngine, - myEngine, - myEngineInstance; +let MyEngine, myEngine, myEngineInstance; QUnit.module('Ember.Engine initializers', { setup() { }, teardown() { - run(function() { + run(() => { if (myEngineInstance) { myEngineInstance.destroy(); } @@ -25,14 +23,14 @@ QUnit.module('Ember.Engine initializers', { QUnit.test('initializers require proper \'name\' and \'initialize\' properties', function() { MyEngine = Engine.extend(); - expectAssertion(function() { - run(function() { + expectAssertion(() => { + run(() => { MyEngine.initializer({ name: 'initializer' }); }); }); - expectAssertion(function() { - run(function() { + expectAssertion(() => { + run(() => { MyEngine.initializer({ initialize() {} }); }); }); diff --git a/packages/ember-application/tests/system/engine_instance_initializers_test.js b/packages/ember-application/tests/system/engine_instance_initializers_test.js index b963d012dc0..31c20bba0a7 100644 --- a/packages/ember-application/tests/system/engine_instance_initializers_test.js +++ b/packages/ember-application/tests/system/engine_instance_initializers_test.js @@ -21,7 +21,7 @@ QUnit.module('Ember.Engine instance initializers', { }, teardown() { - run(function() { + run(() => { if (myEngineInstance) { myEngineInstance.destroy(); } @@ -36,14 +36,14 @@ QUnit.module('Ember.Engine instance initializers', { QUnit.test('initializers require proper \'name\' and \'initialize\' properties', function() { MyEngine = Engine.extend(); - expectAssertion(function() { - run(function() { + expectAssertion(() => { + run(() => { MyEngine.instanceInitializer({ name: 'initializer' }); }); }); - expectAssertion(function() { - run(function() { + expectAssertion(() => { + run(() => { MyEngine.instanceInitializer({ initialize() {} }); }); }); @@ -281,7 +281,7 @@ QUnit.test('initializers set on Engine subclasses should not be shared between e equal(firstInitializerRunCount, 1, 'second initializer only was run'); equal(secondInitializerRunCount, 1, 'second initializer only was run'); - run(function() { + run(() => { firstEngineInstance.destroy(); secondEngineInstance.destroy(); @@ -331,7 +331,7 @@ QUnit.test('initializers are concatenated', function() { equal(firstInitializerRunCount, 1, 'first initializer was run when subclass created'); equal(secondInitializerRunCount, 1, 'second initializers was run when subclass created'); - run(function() { + run(() => { firstEngineInstance.destroy(); secondEngineInstance.destroy(); @@ -351,7 +351,7 @@ QUnit.test('initializers are per-engine', function() { initialize(engine) {} }); - expectAssertion(function() { + expectAssertion(() => { FirstEngine.instanceInitializer({ name: 'abc', initialize(engine) {} diff --git a/packages/ember-application/tests/system/engine_instance_test.js b/packages/ember-application/tests/system/engine_instance_test.js index 76441b9870e..1f17fb85bac 100644 --- a/packages/ember-application/tests/system/engine_instance_test.js +++ b/packages/ember-application/tests/system/engine_instance_test.js @@ -9,7 +9,7 @@ let engine, engineInstance; QUnit.module('Ember.EngineInstance', { setup() { - run(function() { + run(() => { engine = Engine.create({ router: null }); }); }, @@ -26,7 +26,7 @@ QUnit.module('Ember.EngineInstance', { }); QUnit.test('an engine instance can be created based upon a base engine', function() { - run(function() { + run(() => { engineInstance = EngineInstance.create({ base: engine }); }); @@ -37,9 +37,7 @@ QUnit.test('an engine instance can be created based upon a base engine', functio QUnit.test('unregistering a factory clears all cached instances of that factory', function(assert) { assert.expect(3); - run(function() { - engineInstance = EngineInstance.create({ base: engine }); - }); + engineInstance = run(() => EngineInstance.create({ base: engine })); let PostComponent = factory(); @@ -61,11 +59,9 @@ if (isEnabled('ember-application-engines')) { QUnit.test('can be booted when its parent has been set', function(assert) { assert.expect(3); - run(function() { - engineInstance = EngineInstance.create({ base: engine }); - }); + engineInstance = run(() => EngineInstance.create({ base: engine })); - expectAssertion(function() { + expectAssertion(() => { engineInstance._bootSync(); }, 'An engine instance\'s parent must be set via `setEngineParent(engine, parent)` prior to calling `engine.boot()`.'); @@ -88,11 +84,11 @@ if (isEnabled('ember-application-engines')) { engine.register('engine:chat', ChatEngine); - run(function() { + run(() => { engineInstance = EngineInstance.create({ base: engine }); // Try to build an unregistered engine. - throws(function() { + throws(() => { engineInstance.buildChildEngineInstance('fake'); }, `You attempted to mount the engine 'fake', but it is not registered with its parent.`); diff --git a/packages/ember-application/tests/system/engine_test.js b/packages/ember-application/tests/system/engine_test.js index 2307cc34bb1..6f143e603ab 100644 --- a/packages/ember-application/tests/system/engine_test.js +++ b/packages/ember-application/tests/system/engine_test.js @@ -13,9 +13,7 @@ let lookup; QUnit.module('Ember.Engine', { setup() { lookup = context.lookup = {}; - run(function() { - engine = Engine.create(); - }); + engine = run(() => Engine.create()); }, teardown() { @@ -27,9 +25,7 @@ QUnit.module('Ember.Engine', { }); QUnit.test('acts like a namespace', function() { - run(function() { - engine = lookup.TestEngine = Engine.create(); - }); + engine = run(() => lookup.TestEngine = Engine.create()); engine.Foo = EmberObject.extend(); equal(engine.Foo.toString(), 'TestEngine.Foo', 'Classes pick up their parent namespace'); diff --git a/packages/ember-application/tests/system/initializers_test.js b/packages/ember-application/tests/system/initializers_test.js index d54b45aa713..c3b52a33ab1 100644 --- a/packages/ember-application/tests/system/initializers_test.js +++ b/packages/ember-application/tests/system/initializers_test.js @@ -2,30 +2,27 @@ import run from 'ember-metal/run_loop'; import Application from 'ember-application/system/application'; import jQuery from 'ember-views/system/jquery'; -var app; +let app; QUnit.module('Ember.Application initializers', { - setup() { - }, - teardown() { if (app) { - run(function() { app.destroy(); }); + run(() => app.destroy()); } } }); QUnit.test('initializers require proper \'name\' and \'initialize\' properties', function() { - var MyApplication = Application.extend(); + let MyApplication = Application.extend(); - expectAssertion(function() { - run(function() { + expectAssertion(() => { + run(() => { MyApplication.initializer({ name: 'initializer' }); }); }); - expectAssertion(function() { - run(function() { + expectAssertion(() => { + run(() => { MyApplication.initializer({ initialize() {} }); }); }); @@ -35,14 +32,14 @@ QUnit.test('initializers that throw errors cause the boot promise to reject with QUnit.expect(2); QUnit.stop(); - var MyApplication = Application.extend(); + let MyApplication = Application.extend(); MyApplication.initializer({ name: 'initializer', initialize() { throw new Error('boot failure'); } }); - var app = MyApplication.create({ + app = MyApplication.create({ autoboot: false }); @@ -66,7 +63,7 @@ QUnit.test('initializers that throw errors cause the boot promise to reject with }); QUnit.test('initializers are passed an App', function() { - var MyApplication = Application.extend(); + let MyApplication = Application.extend(); MyApplication.initializer({ name: 'initializer', @@ -75,7 +72,7 @@ QUnit.test('initializers are passed an App', function() { } }); - run(function() { + run(() => { app = MyApplication.create({ router: false, rootElement: '#qunit-fixture' @@ -84,8 +81,8 @@ QUnit.test('initializers are passed an App', function() { }); QUnit.test('initializers can be registered in a specified order', function() { - var order = []; - var MyApplication = Application.extend(); + let order = []; + let MyApplication = Application.extend(); MyApplication.initializer({ name: 'fourth', after: 'third', @@ -134,7 +131,7 @@ QUnit.test('initializers can be registered in a specified order', function() { } }); - run(function() { + run(() => { app = MyApplication.create({ router: false, rootElement: '#qunit-fixture' @@ -145,9 +142,8 @@ QUnit.test('initializers can be registered in a specified order', function() { }); QUnit.test('initializers can be registered in a specified order as an array', function() { - var order = []; - var MyApplication = Application.extend(); - + let order = []; + let MyApplication = Application.extend(); MyApplication.initializer({ name: 'third', @@ -197,7 +193,7 @@ QUnit.test('initializers can be registered in a specified order as an array', fu } }); - run(function() { + run(() => { app = MyApplication.create({ router: false, rootElement: '#qunit-fixture' @@ -208,35 +204,35 @@ QUnit.test('initializers can be registered in a specified order as an array', fu }); QUnit.test('initializers can have multiple dependencies', function () { - var order = []; - var a = { + let order = []; + let a = { name: 'a', before: 'b', initialize(registry) { order.push('a'); } }; - var b = { + let b = { name: 'b', initialize(registry) { order.push('b'); } }; - var c = { + let c = { name: 'c', after: 'b', initialize(registry) { order.push('c'); } }; - var afterB = { + let afterB = { name: 'after b', after: 'b', initialize(registry) { order.push('after b'); } }; - var afterC = { + let afterC = { name: 'after c', after: 'c', initialize(registry) { @@ -250,7 +246,7 @@ QUnit.test('initializers can have multiple dependencies', function () { Application.initializer(afterB); Application.initializer(c); - run(function() { + run(() => { app = Application.create({ router: false, rootElement: '#qunit-fixture' @@ -264,51 +260,59 @@ QUnit.test('initializers can have multiple dependencies', function () { }); QUnit.test('initializers set on Application subclasses are not shared between apps', function() { - var firstInitializerRunCount = 0; - var secondInitializerRunCount = 0; - var FirstApp = Application.extend(); - var firstApp, secondApp; + let firstInitializerRunCount = 0; + let secondInitializerRunCount = 0; + let FirstApp = Application.extend(); + FirstApp.initializer({ name: 'first', initialize(registry) { firstInitializerRunCount++; } }); - var SecondApp = Application.extend(); + + let SecondApp = Application.extend(); + SecondApp.initializer({ name: 'second', initialize(registry) { secondInitializerRunCount++; } }); + jQuery('#qunit-fixture').html('
'); - run(function() { - firstApp = FirstApp.create({ + + let firstApp = run(() => { + return FirstApp.create({ router: false, rootElement: '#qunit-fixture #first' }); }); + equal(firstInitializerRunCount, 1, 'first initializer only was run'); equal(secondInitializerRunCount, 0, 'first initializer only was run'); - run(function() { - secondApp = SecondApp.create({ + + let secondApp = run(() => { + return SecondApp.create({ router: false, rootElement: '#qunit-fixture #second' }); }); + equal(firstInitializerRunCount, 1, 'second initializer only was run'); equal(secondInitializerRunCount, 1, 'second initializer only was run'); - run(function() { + + run(() => { firstApp.destroy(); secondApp.destroy(); }); }); QUnit.test('initializers are concatenated', function() { - var firstInitializerRunCount = 0; - var secondInitializerRunCount = 0; - var FirstApp = Application.extend(); - var firstApp, secondApp; + let firstInitializerRunCount = 0; + let secondInitializerRunCount = 0; + let FirstApp = Application.extend(); + FirstApp.initializer({ name: 'first', initialize(registry) { @@ -316,7 +320,7 @@ QUnit.test('initializers are concatenated', function() { } }); - var SecondApp = FirstApp.extend(); + let SecondApp = FirstApp.extend(); SecondApp.initializer({ name: 'second', initialize(registry) { @@ -325,8 +329,8 @@ QUnit.test('initializers are concatenated', function() { }); jQuery('#qunit-fixture').html('
'); - run(function() { - firstApp = FirstApp.create({ + let firstApp = run(() => { + return FirstApp.create({ router: false, rootElement: '#qunit-fixture #first' }); @@ -334,15 +338,17 @@ QUnit.test('initializers are concatenated', function() { equal(firstInitializerRunCount, 1, 'first initializer only was run when base class created'); equal(secondInitializerRunCount, 0, 'first initializer only was run when base class created'); firstInitializerRunCount = 0; - run(function() { - secondApp = SecondApp.create({ + + let secondApp = run(() => { + return SecondApp.create({ router: false, rootElement: '#qunit-fixture #second' }); }); + equal(firstInitializerRunCount, 1, 'first initializer was run when subclass created'); equal(secondInitializerRunCount, 1, 'second initializers was run when subclass created'); - run(function() { + run(() => { firstApp.destroy(); secondApp.destroy(); }); @@ -358,7 +364,7 @@ QUnit.test('initializers are per-app', function() { initialize(app) {} }); - expectAssertion(function() { + expectAssertion(() => { FirstApp.initializer({ name: 'abc', initialize(app) {} @@ -376,7 +382,7 @@ QUnit.test('initializers are per-app', function() { QUnit.test('initializers are executed in their own context', function() { expect(1); - var MyApplication = Application.extend(); + let MyApplication = Application.extend(); MyApplication.initializer({ name: 'coolInitializer', @@ -386,7 +392,7 @@ QUnit.test('initializers are executed in their own context', function() { } }); - run(function() { + run(() => { app = MyApplication.create({ router: false, rootElement: '#qunit-fixture' @@ -397,7 +403,7 @@ QUnit.test('initializers are executed in their own context', function() { QUnit.test('initializers throw a deprecation warning when receiving a second argument', function() { expect(1); - var MyApplication = Application.extend(); + let MyApplication = Application.extend(); MyApplication.initializer({ name: 'deprecated', @@ -405,8 +411,8 @@ QUnit.test('initializers throw a deprecation warning when receiving a second arg } }); - expectDeprecation(function() { - run(function() { + expectDeprecation(() => { + run(() => { app = MyApplication.create({ router: false, rootElement: '#qunit-fixture' diff --git a/packages/ember-application/tests/system/instance_initializers_test.js b/packages/ember-application/tests/system/instance_initializers_test.js index 82953775403..152f42ef975 100644 --- a/packages/ember-application/tests/system/instance_initializers_test.js +++ b/packages/ember-application/tests/system/instance_initializers_test.js @@ -3,37 +3,34 @@ import Application from 'ember-application/system/application'; import ApplicationInstance from 'ember-application/system/application-instance'; import jQuery from 'ember-views/system/jquery'; -var app; +let app; QUnit.module('Ember.Application instance initializers', { - setup() { - }, - teardown() { if (app) { - run(function() { app.destroy(); }); + run(() => app.destroy()); } } }); QUnit.test('initializers require proper \'name\' and \'initialize\' properties', function() { - var MyApplication = Application.extend(); + let MyApplication = Application.extend(); - expectAssertion(function() { - run(function() { + expectAssertion(() => { + run(() => { MyApplication.instanceInitializer({ name: 'initializer' }); }); }); - expectAssertion(function() { - run(function() { + expectAssertion(() => { + run(() => { MyApplication.instanceInitializer({ initialize() {} }); }); }); }); QUnit.test('initializers are passed an app instance', function() { - var MyApplication = Application.extend(); + let MyApplication = Application.extend(); MyApplication.instanceInitializer({ name: 'initializer', @@ -42,7 +39,7 @@ QUnit.test('initializers are passed an app instance', function() { } }); - run(function() { + run(() => { app = MyApplication.create({ router: false, rootElement: '#qunit-fixture' @@ -51,8 +48,8 @@ QUnit.test('initializers are passed an app instance', function() { }); QUnit.test('initializers can be registered in a specified order', function() { - var order = []; - var MyApplication = Application.extend(); + let order = []; + let MyApplication = Application.extend(); MyApplication.instanceInitializer({ name: 'fourth', after: 'third', @@ -101,7 +98,7 @@ QUnit.test('initializers can be registered in a specified order', function() { } }); - run(function() { + run(() => { app = MyApplication.create({ router: false, rootElement: '#qunit-fixture' @@ -112,9 +109,8 @@ QUnit.test('initializers can be registered in a specified order', function() { }); QUnit.test('initializers can be registered in a specified order as an array', function() { - var order = []; - var MyApplication = Application.extend(); - + let order = []; + let MyApplication = Application.extend(); MyApplication.instanceInitializer({ name: 'third', @@ -164,7 +160,7 @@ QUnit.test('initializers can be registered in a specified order as an array', fu } }); - run(function() { + run(() => { app = MyApplication.create({ router: false, rootElement: '#qunit-fixture' @@ -175,35 +171,35 @@ QUnit.test('initializers can be registered in a specified order as an array', fu }); QUnit.test('initializers can have multiple dependencies', function () { - var order = []; - var a = { + let order = []; + let a = { name: 'a', before: 'b', initialize(registry) { order.push('a'); } }; - var b = { + let b = { name: 'b', initialize(registry) { order.push('b'); } }; - var c = { + let c = { name: 'c', after: 'b', initialize(registry) { order.push('c'); } }; - var afterB = { + let afterB = { name: 'after b', after: 'b', initialize(registry) { order.push('after b'); } }; - var afterC = { + let afterC = { name: 'after c', after: 'c', initialize(registry) { @@ -217,7 +213,7 @@ QUnit.test('initializers can have multiple dependencies', function () { Application.instanceInitializer(afterB); Application.instanceInitializer(c); - run(function() { + run(() => { app = Application.create({ router: false, rootElement: '#qunit-fixture' @@ -231,10 +227,10 @@ QUnit.test('initializers can have multiple dependencies', function () { }); QUnit.test('initializers set on Application subclasses should not be shared between apps', function() { - var firstInitializerRunCount = 0; - var secondInitializerRunCount = 0; - var FirstApp = Application.extend(); - var firstApp, secondApp; + let firstInitializerRunCount = 0; + let secondInitializerRunCount = 0; + let FirstApp = Application.extend(); + let firstApp, secondApp; FirstApp.instanceInitializer({ name: 'first', @@ -242,7 +238,7 @@ QUnit.test('initializers set on Application subclasses should not be shared betw firstInitializerRunCount++; } }); - var SecondApp = Application.extend(); + let SecondApp = Application.extend(); SecondApp.instanceInitializer({ name: 'second', initialize(registry) { @@ -250,7 +246,7 @@ QUnit.test('initializers set on Application subclasses should not be shared betw } }); jQuery('#qunit-fixture').html('
'); - run(function() { + run(() => { firstApp = FirstApp.create({ router: false, rootElement: '#qunit-fixture #first' @@ -258,7 +254,7 @@ QUnit.test('initializers set on Application subclasses should not be shared betw }); equal(firstInitializerRunCount, 1, 'first initializer only was run'); equal(secondInitializerRunCount, 0, 'first initializer only was run'); - run(function() { + run(() => { secondApp = SecondApp.create({ router: false, rootElement: '#qunit-fixture #second' @@ -266,17 +262,17 @@ QUnit.test('initializers set on Application subclasses should not be shared betw }); equal(firstInitializerRunCount, 1, 'second initializer only was run'); equal(secondInitializerRunCount, 1, 'second initializer only was run'); - run(function() { - firstApp.destroy(); - secondApp.destroy(); -}); + run(() => { + firstApp.destroy(); + secondApp.destroy(); + }); }); QUnit.test('initializers are concatenated', function() { - var firstInitializerRunCount = 0; - var secondInitializerRunCount = 0; - var FirstApp = Application.extend(); - var firstApp, secondApp; + let firstInitializerRunCount = 0; + let secondInitializerRunCount = 0; + let FirstApp = Application.extend(); + let firstApp, secondApp; FirstApp.instanceInitializer({ name: 'first', @@ -285,7 +281,7 @@ QUnit.test('initializers are concatenated', function() { } }); - var SecondApp = FirstApp.extend(); + let SecondApp = FirstApp.extend(); SecondApp.instanceInitializer({ name: 'second', initialize(registry) { @@ -346,9 +342,9 @@ QUnit.test('initializers are per-app', function() { QUnit.test('initializers are run before ready hook', function() { expect(2); - var readyWasCalled = false; + let readyWasCalled = false; - var MyApplication = Application.extend({ + let MyApplication = Application.extend({ ready() { ok(true, 'ready is called'); readyWasCalled = true; @@ -373,7 +369,7 @@ QUnit.test('initializers are run before ready hook', function() { QUnit.test('initializers are executed in their own context', function() { expect(1); - var MyApplication = Application.extend(); + let MyApplication = Application.extend(); MyApplication.instanceInitializer({ name: 'coolInitializer', @@ -383,7 +379,7 @@ QUnit.test('initializers are executed in their own context', function() { } }); - run(function() { + run(() => { app = MyApplication.create({ router: false, rootElement: '#qunit-fixture' @@ -394,7 +390,7 @@ QUnit.test('initializers are executed in their own context', function() { QUnit.test('initializers get an instance on app reset', function() { expect(2); - var MyApplication = Application.extend(); + let MyApplication = Application.extend(); MyApplication.instanceInitializer({ name: 'giveMeAnInstance', @@ -403,7 +399,7 @@ QUnit.test('initializers get an instance on app reset', function() { } }); - run(function() { + run(() => { app = MyApplication.create({ router: false, rootElement: '#qunit-fixture' diff --git a/packages/ember-application/tests/system/logging_test.js b/packages/ember-application/tests/system/logging_test.js index 59d0468a18f..ba52367646a 100644 --- a/packages/ember-application/tests/system/logging_test.js +++ b/packages/ember-application/tests/system/logging_test.js @@ -10,7 +10,7 @@ import { compile } from 'ember-template-compiler/tests/utils/helpers'; import 'ember-routing'; -var App, logs, originalLogger; +let App, logs, originalLogger; QUnit.module('Ember.Application – logging of generated classes', { setup() { @@ -19,13 +19,13 @@ QUnit.module('Ember.Application – logging of generated classes', { originalLogger = Logger.info; Logger.info = function() { - var fullName = arguments[1].fullName; + let fullName = arguments[1].fullName; logs[fullName] = logs[fullName] || 0; logs[fullName]++; }; - run(function() { + run(() => { App = Application.create({ LOG_ACTIVE_GENERATION: true }); @@ -54,15 +54,15 @@ QUnit.module('Ember.Application – logging of generated classes', { function visit(path) { QUnit.stop(); - var promise = run(function() { - return new RSVP.Promise(function(resolve, reject) { + var promise = run(() => { + return new RSVP.Promise((resolve, reject) => { var router = App.__container__.lookup('router:main'); - resolve(router.handleURL(path).then(function(value) { + resolve(router.handleURL(path).then(value => { QUnit.start(); ok(true, 'visited: `' + path + '`'); return value; - }, function(reason) { + }, reason => { QUnit.start(); ok(false, 'failed to visit:`' + path + '` reason: `' + QUnit.jsDump.parse(reason)); throw reason; @@ -97,7 +97,7 @@ QUnit.test('do NOT log class generation if logging disabled', function() { run(App, 'advanceReadiness'); - visit('/posts').then(function() { + visit('/posts').then(() => { equal(Object.keys(logs).length, 0, 'expected no logs'); }); }); @@ -110,7 +110,7 @@ QUnit.test('actively generated classes get logged', function() { run(App, 'advanceReadiness'); - visit('/posts').then(function() { + visit('/posts').then(() => { equal(logs['controller:application'], 1, 'expected: ApplicationController was generated'); equal(logs['controller:posts'], 1, 'expected: PostsController was generated'); @@ -128,7 +128,7 @@ QUnit.test('predefined classes do not get logged', function() { run(App, 'advanceReadiness'); - visit('/posts').then(function() { + visit('/posts').then(() => { ok(!logs['controller:application'], 'did not expect: ApplicationController was generated'); ok(!logs['controller:posts'], 'did not expect: PostsController was generated'); @@ -150,7 +150,7 @@ QUnit.module('Ember.Application – logging of view lookups', { logs[fullName]++; }; - run(function() { + run(() => { App = Application.create({ LOG_VIEW_LOOKUPS: true }); @@ -185,7 +185,7 @@ QUnit.test('log when template and view are missing when flag is active', functio App.register('template:application', compile('{{outlet}}')); run(App, 'advanceReadiness'); - visit('/posts').then(function() { + visit('/posts').then(() => { equal(logs['template:application'], undefined, 'expected: Should not log template:application since it exists.'); equal(logs['template:index'], 1, 'expected: Could not find "index" template or view.'); equal(logs['template:posts'], 1, 'expected: Could not find "posts" template or view.'); @@ -199,7 +199,7 @@ QUnit.test('do not log when template and view are missing when flag is not true' run(App, 'advanceReadiness'); - visit('/posts').then(function() { + visit('/posts').then(() => { equal(Object.keys(logs).length, 0, 'expected no logs'); }); }); @@ -211,7 +211,7 @@ QUnit.test('do not log which views are used with templates when flag is not true run(App, 'advanceReadiness'); - visit('/posts').then(function() { + visit('/posts').then(() => { equal(Object.keys(logs).length, 0, 'expected no logs'); }); }); diff --git a/packages/ember-application/tests/system/readiness_test.js b/packages/ember-application/tests/system/readiness_test.js index ee7d5e36c59..fe94d1ca2f8 100644 --- a/packages/ember-application/tests/system/readiness_test.js +++ b/packages/ember-application/tests/system/readiness_test.js @@ -1,8 +1,8 @@ import run from 'ember-metal/run_loop'; import EmberApplication from 'ember-application/system/application'; -var jQuery, application, Application; -var readyWasCalled, domReady, readyCallbacks; +let jQuery, application, Application; +let readyWasCalled, domReady, readyCallbacks; // We are using a small mock of jQuery because jQuery is third-party code with // very well-defined semantics, and we want to confirm that a jQuery stub run @@ -14,7 +14,7 @@ QUnit.module('Application readiness', { readyWasCalled = 0; readyCallbacks = []; - var jQueryInstance = { + let jQueryInstance = { ready(callback) { readyCallbacks.push(callback); if (jQuery.isReady) { @@ -28,12 +28,11 @@ QUnit.module('Application readiness', { }; jQuery.isReady = false; - var domReadyCalled = 0; + let domReadyCalled = 0; domReady = function() { if (domReadyCalled !== 0) { return; } domReadyCalled++; - var i; - for (i = 0; i < readyCallbacks.length; i++) { + for (let i = 0; i < readyCallbacks.length; i++) { readyCallbacks[i](); } }; @@ -49,7 +48,7 @@ QUnit.module('Application readiness', { teardown() { if (application) { - run(function() { application.destroy(); }); + run(() => application.destroy()); } } }); @@ -61,7 +60,7 @@ QUnit.module('Application readiness', { QUnit.test('Ember.Application\'s ready event is called right away if jQuery is already ready', function() { jQuery.isReady = true; - run(function() { + run(() => { application = Application.create({ router: false }); equal(readyWasCalled, 0, 'ready is not called until later'); @@ -75,7 +74,7 @@ QUnit.test('Ember.Application\'s ready event is called right away if jQuery is a }); QUnit.test('Ember.Application\'s ready event is called after the document becomes ready', function() { - run(function() { + run(() => { application = Application.create({ router: false }); }); @@ -87,7 +86,7 @@ QUnit.test('Ember.Application\'s ready event is called after the document become }); QUnit.test('Ember.Application\'s ready event can be deferred by other components', function() { - run(function() { + run(() => { application = Application.create({ router: false }); application.deferReadiness(); }); @@ -98,7 +97,7 @@ QUnit.test('Ember.Application\'s ready event can be deferred by other components equal(readyWasCalled, 0, 'ready wasn\'t called yet'); - run(function() { + run(() => { application.advanceReadiness(); equal(readyWasCalled, 0); }); @@ -109,7 +108,7 @@ QUnit.test('Ember.Application\'s ready event can be deferred by other components QUnit.test('Ember.Application\'s ready event can be deferred by other components', function() { jQuery.isReady = false; - run(function() { + run(() => { application = Application.create({ router: false }); application.deferReadiness(); equal(readyWasCalled, 0, 'ready wasn\'t called yet'); @@ -119,13 +118,13 @@ QUnit.test('Ember.Application\'s ready event can be deferred by other components equal(readyWasCalled, 0, 'ready wasn\'t called yet'); - run(function() { + run(() => { application.advanceReadiness(); }); equal(readyWasCalled, 1, 'ready was called now all readiness deferrals are advanced'); - expectAssertion(function() { + expectAssertion(() => { application.deferReadiness(); }); }); diff --git a/packages/ember-application/tests/system/reset_test.js b/packages/ember-application/tests/system/reset_test.js index a3b97988b6c..2a85221365b 100644 --- a/packages/ember-application/tests/system/reset_test.js +++ b/packages/ember-application/tests/system/reset_test.js @@ -8,7 +8,7 @@ import Controller from 'ember-runtime/controllers/controller'; import jQuery from 'ember-views/system/jquery'; import Registry from 'container/registry'; -var application, Application; +let application, Application; QUnit.module('Ember.Application - resetting', { setup() { @@ -43,7 +43,7 @@ QUnit.test('Does not bring its own run loop if one is already provided', functio application = run(Application, 'create'); - run(function() { + run(() => { application.ready = function() { didBecomeReady = true; }; @@ -60,17 +60,17 @@ QUnit.test('Does not bring its own run loop if one is already provided', functio }); QUnit.test('When an application is reset, new instances of controllers are generated', function() { - run(function() { + run(() => { application = Application.create(); application.AcademicController = Controller.extend(); }); - var firstController = application.__container__.lookup('controller:academic'); - var secondController = application.__container__.lookup('controller:academic'); + let firstController = application.__container__.lookup('controller:academic'); + let secondController = application.__container__.lookup('controller:academic'); application.reset(); - var thirdController = application.__container__.lookup('controller:academic'); + let thirdController = application.__container__.lookup('controller:academic'); strictEqual(firstController, secondController, 'controllers looked up in succession should be the same instance'); @@ -80,12 +80,12 @@ QUnit.test('When an application is reset, new instances of controllers are gener }); QUnit.test('When an application is reset, the eventDispatcher is destroyed and recreated', function() { - var eventDispatcherWasSetup, eventDispatcherWasDestroyed; + let eventDispatcherWasSetup, eventDispatcherWasDestroyed; eventDispatcherWasSetup = 0; eventDispatcherWasDestroyed = 0; - var mock_event_dispatcher = { + let mock_event_dispatcher = { create() { return { setup() { @@ -99,7 +99,7 @@ QUnit.test('When an application is reset, the eventDispatcher is destroyed and r }; // this is pretty awful. We should make this less Global-ly. - var originalRegister = Registry.prototype.register; + let originalRegister = Registry.prototype.register; Registry.prototype.register = function(name, type, options) { if (name === 'event_dispatcher:main') { return mock_event_dispatcher; @@ -109,7 +109,7 @@ QUnit.test('When an application is reset, the eventDispatcher is destroyed and r }; try { - run(function() { + run(() => { application = Application.create(); equal(eventDispatcherWasSetup, 0); @@ -129,9 +129,9 @@ QUnit.test('When an application is reset, the eventDispatcher is destroyed and r }); QUnit.test('When an application is reset, the router URL is reset to `/`', function() { - var location, router; + let location, router; - run(function() { + run(() => { application = Application.create(); application.Router = Router.extend({ location: 'none' @@ -147,13 +147,13 @@ QUnit.test('When an application is reset, the router URL is reset to `/`', funct location = router.get('location'); - run(function() { + run(() => { location.handleURL('/one'); }); application.reset(); - var applicationController = application.__container__.lookup('controller:application'); + let applicationController = application.__container__.lookup('controller:application'); router = application.__container__.lookup('router:main'); location = router.get('location'); @@ -162,7 +162,7 @@ QUnit.test('When an application is reset, the router URL is reset to `/`', funct equal(get(applicationController, 'currentPath'), 'index'); location = application.__container__.lookup('router:main').get('location'); - run(function() { + run(() => { location.handleURL('/one'); }); @@ -174,7 +174,7 @@ QUnit.test('When an application with advance/deferReadiness is reset, the app do readyCallCount = 0; - run(function() { + run(() => { application = Application.create({ ready() { readyCallCount++; @@ -185,7 +185,7 @@ QUnit.test('When an application with advance/deferReadiness is reset, the app do equal(readyCallCount, 0, 'ready has not yet been called'); }); - run(function() { + run(() => { application.advanceReadiness(); }); @@ -197,11 +197,11 @@ QUnit.test('When an application with advance/deferReadiness is reset, the app do }); QUnit.test('With ember-data like initializer and constant', function() { - var readyCallCount; + let readyCallCount; readyCallCount = 0; - var DS = { + let DS = { Store: EmberObject.extend({ init() { if (!get(DS, 'defaultStore')) { @@ -228,7 +228,7 @@ QUnit.test('With ember-data like initializer and constant', function() { } }); - run(function() { + run(() => { application = Application.create(); application.Store = DS.Store; }); @@ -242,13 +242,11 @@ QUnit.test('With ember-data like initializer and constant', function() { }); QUnit.test('Ensure that the hashchange event listener is removed', function() { - var listeners; + let listeners; jQuery(window).off('hashchange'); // ensure that any previous listeners are cleared - run(function() { - application = Application.create(); - }); + application = run(() => Application.create()); listeners = jQuery._data(jQuery(window)[0], 'events'); equal(listeners['hashchange'].length, 1, 'hashchange event listener was set up'); diff --git a/packages/ember-application/tests/system/visit_test.js b/packages/ember-application/tests/system/visit_test.js index 601857b41a9..36380b8cd11 100644 --- a/packages/ember-application/tests/system/visit_test.js +++ b/packages/ember-application/tests/system/visit_test.js @@ -84,7 +84,7 @@ QUnit.test('Applications with autoboot set to false do not autoboot', function(a let appBooted = 0; let instanceBooted = 0; - run(function() { + run(() => { createApplication(); App.initializer({ @@ -118,7 +118,7 @@ QUnit.test('calling visit() on an app without first calling boot() should boot t let appBooted = 0; let instanceBooted = 0; - run(function() { + run(() => { createApplication(); App.initializer({ @@ -146,7 +146,7 @@ QUnit.test('calling visit() on an already booted app should not boot it again', let appBooted = 0; let instanceBooted = 0; - run(function() { + run(() => { createApplication(); App.initializer({ @@ -181,7 +181,7 @@ QUnit.test('calling visit() on an already booted app should not boot it again', }); QUnit.test('visit() rejects on application boot failure', function(assert) { - run(function() { + run(() => { createApplication(); App.initializer({ @@ -203,7 +203,7 @@ QUnit.test('visit() rejects on application boot failure', function(assert) { }); QUnit.test('visit() rejects on instance boot failure', function(assert) { - run(function() { + run(() => { createApplication(); App.instanceInitializer({ @@ -225,7 +225,7 @@ QUnit.test('visit() rejects on instance boot failure', function(assert) { }); QUnit.test('visit() follows redirects', function(assert) { - run(function() { + run(() => { createApplication(); App.Router.map(function() { @@ -254,7 +254,7 @@ QUnit.test('visit() follows redirects', function(assert) { }); QUnit.test('visit() rejects if an error occured during a transition', function(assert) { - run(function() { + run(() => { createApplication(); App.Router.map(function() { @@ -293,7 +293,7 @@ QUnit.test('visit() rejects if an error occured during a transition', function(a }); QUnit.test('visit() chain', function(assert) { - run(function() { + run(() => { createApplication(); App.Router.map(function() { @@ -325,7 +325,7 @@ QUnit.test('visit() chain', function(assert) { }); QUnit.test('visit() returns a promise that resolves when the view has rendered', function(assert) { - run(function() { + run(() => { createApplication(); App.register('template:application', compile('

Hello world

')); @@ -362,7 +362,7 @@ test('Ember Islands-style setup', function(assert) { let xBarInitCalled = false; let xBarDidInsertElementCalled = false; - run(function() { + run(() => { createApplication(true); App.Router.map(function() { @@ -469,14 +469,12 @@ test('Ember Islands-style setup', function(assert) { assert.equal($bar.find('button').text(), 'Join 0 others in clicking me!'); assert.ok($bar.text().indexOf('X-Foo') === -1); - run(function() { - $foo.find('x-foo').click(); - }); + run(() => $foo.find('x-foo').click()); assert.equal($foo.find('p').text(), 'Hello Godfrey, I have been clicked 1 times (1 times combined)!'); assert.equal($bar.find('button').text(), 'Join 1 others in clicking me!'); - run(function() { + run(() => { $bar.find('button').click(); $bar.find('button').click(); }); diff --git a/packages/ember-debug/lib/index.js b/packages/ember-debug/lib/index.js index 3266c5a5d32..d509b70c537 100644 --- a/packages/ember-debug/lib/index.js +++ b/packages/ember-debug/lib/index.js @@ -186,7 +186,7 @@ export function _warnIfUsingStrippedFeatureFlags(FEATURES, knownFeatures, featur if (!isTesting()) { // Complain if they're using FEATURE flags in builds other than canary FEATURES['features-stripped-test'] = true; - var featuresWereStripped = true; + let featuresWereStripped = true; if (isEnabled('features-stripped-test')) { featuresWereStripped = false; @@ -196,11 +196,11 @@ if (!isTesting()) { _warnIfUsingStrippedFeatureFlags(ENV.FEATURES, DEFAULT_FEATURES, featuresWereStripped); // Inform the developer about the Ember Inspector if not installed. - var isFirefox = environment.isFirefox; - var isChrome = environment.isChrome; + let isFirefox = environment.isFirefox; + let isChrome = environment.isChrome; if (typeof window !== 'undefined' && (isFirefox || isChrome) && window.addEventListener) { - window.addEventListener('load', function() { + window.addEventListener('load', () => { if (document.documentElement && document.documentElement.dataset && !document.documentElement.dataset.emberExtension) { var downloadURL; @@ -295,7 +295,7 @@ Ember.Debug.registerWarnHandler = registerWarnHandler; so that if `ember.js` (which must be output for backwards compat reasons) is used a nice helpful warning message will be printed out. */ -export var runningNonEmberDebugJS = false; +export let runningNonEmberDebugJS = false; if (runningNonEmberDebugJS) { warn('Please use `ember.debug.js` instead of `ember.js` for development and debugging.'); } diff --git a/packages/ember-debug/tests/handlers-test.js b/packages/ember-debug/tests/handlers-test.js index a1fcbd507b2..188a108fb81 100644 --- a/packages/ember-debug/tests/handlers-test.js +++ b/packages/ember-debug/tests/handlers-test.js @@ -92,9 +92,7 @@ QUnit.test('handlers are called in the proper order', function(assert) { }; } - expected.forEach(function(item) { - registerHandler('blarz', generateHandler(item)); - }); + expected.forEach(item => registerHandler('blarz', generateHandler(item))); invoke('blarz', expectedMessage, false, expectedOptions); diff --git a/packages/ember-debug/tests/main_test.js b/packages/ember-debug/tests/main_test.js index 4c4541f0dc1..77eb9b6d3d0 100644 --- a/packages/ember-debug/tests/main_test.js +++ b/packages/ember-debug/tests/main_test.js @@ -65,7 +65,7 @@ QUnit.test('Ember.deprecate resets deprecation level to RAISE if ENV.RAISE_ON_DE ENV.RAISE_ON_DEPRECATION = true; - assert.throws(function() { + assert.throws(() => { deprecate('Should throw', false, { id: 'test', until: 'forever' }); }, /Should throw/); }); @@ -87,11 +87,11 @@ QUnit.test('When ENV.RAISE_ON_DEPRECATION is true, it is still possible to silen assert.ok(false, `Expected deprecate not to throw but it did: ${e.message}`); } - assert.throws(function() { + assert.throws(() => { deprecate('Should throw with no matching id', false, { id: 'test', until: 'forever' }); }, /Should throw with no matching id/); - assert.throws(function() { + assert.throws(() => { deprecate('Should throw with non-matching id', false, { id: 'other-id', until: 'forever' }); }, /Should throw with non-matching id/); }); @@ -99,17 +99,9 @@ QUnit.test('When ENV.RAISE_ON_DEPRECATION is true, it is still possible to silen QUnit.test('Ember.deprecate throws deprecation if second argument is falsy', function() { expect(3); - throws(function() { - deprecate('Deprecation is thrown', false, { id: 'test', until: 'forever' }); - }); - - throws(function() { - deprecate('Deprecation is thrown', '', { id: 'test', until: 'forever' }); - }); - - throws(function() { - deprecate('Deprecation is thrown', 0, { id: 'test', until: 'forever' }); - }); + throws(() => deprecate('Deprecation is thrown', false, { id: 'test', until: 'forever' })); + throws(() => deprecate('Deprecation is thrown', '', { id: 'test', until: 'forever' })); + throws(() => deprecate('Deprecation is thrown', 0, { id: 'test', until: 'forever' })); }); QUnit.test('Ember.deprecate does not invoke a function as the second argument', function() { @@ -135,17 +127,9 @@ QUnit.test('Ember.deprecate does not throw deprecations if second argument is tr QUnit.test('Ember.assert throws if second argument is falsy', function() { expect(3); - throws(function() { - emberAssert('Assertion is thrown', false); - }); - - throws(function() { - emberAssert('Assertion is thrown', ''); - }); - - throws(function() { - emberAssert('Assertion is thrown', 0); - }); + throws(() => emberAssert('Assertion is thrown', false)); + throws(() => emberAssert('Assertion is thrown', '')); + throws(() => emberAssert('Assertion is thrown', 0)); }); QUnit.test('Ember.assert does not throw if second argument is a function', function(assert) { diff --git a/packages/ember-debug/tests/warn_if_using_stripped_feature_flags_test.js b/packages/ember-debug/tests/warn_if_using_stripped_feature_flags_test.js index 0ea4f839795..b38afcc0e1f 100644 --- a/packages/ember-debug/tests/warn_if_using_stripped_feature_flags_test.js +++ b/packages/ember-debug/tests/warn_if_using_stripped_feature_flags_test.js @@ -2,10 +2,10 @@ import { ENV } from 'ember-environment'; import { getDebugFunction, setDebugFunction } from 'ember-metal/debug'; import { _warnIfUsingStrippedFeatureFlags } from 'ember-debug'; -var oldWarn, oldRunInDebug, origEnvFeatures, origEnableOptional, features, knownFeatures; +let oldWarn, oldRunInDebug, origEnvFeatures, origEnableOptional, features, knownFeatures; function confirmWarns(expectedMsg) { - var featuresWereStripped = true; + let featuresWereStripped = true; setDebugFunction('warn', function(msg, test) { if (!test) { diff --git a/packages/ember-extension-support/lib/container_debug_adapter.js b/packages/ember-extension-support/lib/container_debug_adapter.js index e72fc1cc03e..676eb9eac4f 100644 --- a/packages/ember-extension-support/lib/container_debug_adapter.js +++ b/packages/ember-extension-support/lib/container_debug_adapter.js @@ -36,7 +36,7 @@ import EmberObject from 'ember-runtime/system/object'; Application.initializer({ name: "containerDebugAdapter", - initialize: function(application) { + initialize(application) { application.register('container-debug-adapter:main', require('app/container-debug-adapter')); } }); @@ -86,16 +86,16 @@ export default EmberObject.extend({ @public */ catalogEntriesByType(type) { - var namespaces = emberA(Namespace.NAMESPACES); - var types = emberA(); - var typeSuffixRegex = new RegExp(`${classify(type)}$`); + let namespaces = emberA(Namespace.NAMESPACES); + let types = emberA(); + let typeSuffixRegex = new RegExp(`${classify(type)}$`); - namespaces.forEach(function(namespace) { + namespaces.forEach(namespace => { if (namespace !== Ember) { - for (var key in namespace) { + for (let key in namespace) { if (!namespace.hasOwnProperty(key)) { continue; } if (typeSuffixRegex.test(key)) { - var klass = namespace[key]; + let klass = namespace[key]; if (typeOf(klass) === 'class') { types.push(dasherize(key.replace(typeSuffixRegex, ''))); } diff --git a/packages/ember-extension-support/lib/data_adapter.js b/packages/ember-extension-support/lib/data_adapter.js index 91654a477ec..8093b741144 100644 --- a/packages/ember-extension-support/lib/data_adapter.js +++ b/packages/ember-extension-support/lib/data_adapter.js @@ -141,20 +141,20 @@ export default EmberObject.extend({ @return {Function} Method to call to remove all observers */ watchModelTypes(typesAdded, typesUpdated) { - var modelTypes = this.getModelTypes(); - var releaseMethods = emberA(); - var typesToSend; + let modelTypes = this.getModelTypes(); + let releaseMethods = emberA(); + let typesToSend; - typesToSend = modelTypes.map((type) => { - var klass = type.klass; - var wrapped = this.wrapModelType(klass, type.name); + typesToSend = modelTypes.map(type => { + let klass = type.klass; + let wrapped = this.wrapModelType(klass, type.name); releaseMethods.push(this.observeModelType(type.name, typesUpdated)); return wrapped; }); typesAdded(typesToSend); - var release = () => { + let release = () => { releaseMethods.forEach((fn) => fn() ); this.releaseMethods.removeObject(release); }; @@ -194,25 +194,24 @@ export default EmberObject.extend({ @return {Function} Method to call to remove all observers. */ watchRecords(modelName, recordsAdded, recordsUpdated, recordsRemoved) { - var releaseMethods = emberA(); - var klass = this._nameToClass(modelName); - var records = this.getRecords(klass, modelName); - var release; + let releaseMethods = emberA(); + let klass = this._nameToClass(modelName); + let records = this.getRecords(klass, modelName); + let release; - var recordUpdated = function(updatedRecord) { + function recordUpdated(updatedRecord) { recordsUpdated([updatedRecord]); - }; + } - var recordsToSend = records.map((record) => { + let recordsToSend = records.map((record) => { releaseMethods.push(this.observeRecord(record, recordUpdated)); return this.wrapRecord(record); }); - - var contentDidChange = (array, idx, removedCount, addedCount) => { - for (var i = idx; i < idx + addedCount; i++) { - var record = objectAt(array, i); - var wrapped = this.wrapRecord(record); + let contentDidChange = (array, idx, removedCount, addedCount) => { + for (let i = idx; i < idx + addedCount; i++) { + let record = objectAt(array, i); + let wrapped = this.wrapRecord(record); releaseMethods.push(this.observeRecord(record, recordUpdated)); recordsAdded([wrapped]); } @@ -222,11 +221,11 @@ export default EmberObject.extend({ } }; - var observer = { didChange: contentDidChange, willChange() { return this; } }; + let observer = { didChange: contentDidChange, willChange() { return this; } }; addArrayObserver(records, this, observer); release = () => { - releaseMethods.forEach(function(fn) { fn(); }); + releaseMethods.forEach(fn => fn()); removeArrayObserver(records, this, observer); this.releaseMethods.removeObject(release); }; @@ -244,9 +243,7 @@ export default EmberObject.extend({ */ willDestroy() { this._super(...arguments); - this.releaseMethods.forEach(function(fn) { - fn(); - }); + this.releaseMethods.forEach(fn => fn()); }, /** @@ -289,13 +286,14 @@ export default EmberObject.extend({ */ observeModelType(modelName, typesUpdated) { - var klass = this._nameToClass(modelName); - var records = this.getRecords(klass, modelName); + let klass = this._nameToClass(modelName); + let records = this.getRecords(klass, modelName); - var onChange = () => { + function onChange() { typesUpdated([this.wrapModelType(klass, modelName)]); - }; - var observer = { + } + + let observer = { didChange() { run.scheduleOnce('actions', this, onChange); }, @@ -304,9 +302,9 @@ export default EmberObject.extend({ addArrayObserver(records, this, observer); - var release = () => { + function release() { removeArrayObserver(records, this, observer); - }; + } return release; }, @@ -330,8 +328,8 @@ export default EmberObject.extend({ release: {Function} The function to remove observers. */ wrapModelType(klass, name) { - var records = this.getRecords(klass, name); - var typeToSend; + let records = this.getRecords(klass, name); + let typeToSend; typeToSend = { name, @@ -340,7 +338,6 @@ export default EmberObject.extend({ object: klass }; - return typeToSend; }, @@ -353,8 +350,8 @@ export default EmberObject.extend({ @return {Array} Array of model types. */ getModelTypes() { - var containerDebugAdapter = this.get('containerDebugAdapter'); - var types; + let containerDebugAdapter = this.get('containerDebugAdapter'); + let types; if (containerDebugAdapter.canCatalogEntriesByType('model')) { types = containerDebugAdapter.catalogEntriesByType('model'); @@ -369,9 +366,7 @@ export default EmberObject.extend({ name: name }; }); - types = emberA(types).filter((type) => { - return this.detect(type.klass); - }); + types = emberA(types).filter(type => this.detect(type.klass)); return emberA(types); }, @@ -385,17 +380,17 @@ export default EmberObject.extend({ @return {Array} Array of model type strings. */ _getObjectsOnNamespaces() { - var namespaces = emberA(Namespace.NAMESPACES); - var types = emberA(); + let namespaces = emberA(Namespace.NAMESPACES); + let types = emberA(); - namespaces.forEach((namespace) => { - for (var key in namespace) { + namespaces.forEach(namespace => { + for (let key in namespace) { if (!namespace.hasOwnProperty(key)) { continue; } // Even though we will filter again in `getModelTypes`, // we should not call `lookupFactory` on non-models // (especially when `EmberENV.MODEL_FACTORY_INJECTIONS` is `true`) if (!this.detect(namespace[key])) { continue; } - var name = dasherize(key); + let name = dasherize(key); if (!(namespace instanceof Application) && namespace.toString()) { name = `${namespace}/${name}`; } @@ -429,7 +424,7 @@ export default EmberObject.extend({ searchKeywords: {Array} */ wrapRecord(record) { - var recordToSend = { object: record }; + let recordToSend = { object: record }; recordToSend.columnValues = this.getRecordColumnValues(record); recordToSend.searchKeywords = this.getRecordKeywords(record); diff --git a/packages/ember-extension-support/tests/container_debug_adapter_test.js b/packages/ember-extension-support/tests/container_debug_adapter_test.js index bbaf0115c14..e42f305bbae 100644 --- a/packages/ember-extension-support/tests/container_debug_adapter_test.js +++ b/packages/ember-extension-support/tests/container_debug_adapter_test.js @@ -3,8 +3,7 @@ import EmberController from 'ember-runtime/controllers/controller'; import 'ember-extension-support'; // Must be required to export Ember.ContainerDebugAdapter. import Application from 'ember-application/system/application'; -var adapter, App, appInstance; - +let adapter, App, appInstance; function boot() { run(App, 'advanceReadiness'); @@ -12,19 +11,19 @@ function boot() { QUnit.module('Container Debug Adapter', { setup() { - run(function() { + run(() => { App = Application.create(); // ES6TODO: this comes from the ember-application package NOT ember-runtime. App.toString = function() { return 'App'; }; App.deferReadiness(); }); boot(); - run(function() { + run(() => { appInstance = App.__deprecatedInstance__; adapter = appInstance.lookup('container-debug-adapter:main'); }); }, teardown() { - run(function() { + run(() => { adapter.destroy(); appInstance.destroy(); App.destroy(); @@ -46,7 +45,7 @@ QUnit.test('the default ContainerDebugAdapter can catalog typical entries by typ QUnit.test('the default ContainerDebugAdapter catalogs controller entries', function() { App.PostController = EmberController.extend(); - var controllerClasses = adapter.catalogEntriesByType('controller'); + let controllerClasses = adapter.catalogEntriesByType('controller'); equal(controllerClasses.length, 1, 'found 1 class'); equal(controllerClasses[0], 'post', 'found the right class'); diff --git a/packages/ember-extension-support/tests/data_adapter_test.js b/packages/ember-extension-support/tests/data_adapter_test.js index 01156fc7a3f..be4453bb845 100644 --- a/packages/ember-extension-support/tests/data_adapter_test.js +++ b/packages/ember-extension-support/tests/data_adapter_test.js @@ -11,10 +11,10 @@ import EmberDataAdapter from 'ember-extension-support/data_adapter'; import EmberApplication from 'ember-application/system/application'; import DefaultResolver from 'ember-application/system/resolver'; -var adapter, App; -var Model = EmberObject.extend(); +let adapter, App; +const Model = EmberObject.extend(); -var DataAdapter = EmberDataAdapter.extend({ +const DataAdapter = EmberDataAdapter.extend({ detect(klass) { return klass !== Model && Model.detect(klass); } @@ -22,7 +22,7 @@ var DataAdapter = EmberDataAdapter.extend({ QUnit.module('Data Adapter', { setup() { - run(function() { + run(() => { App = EmberApplication.create(); App.toString = function() { return 'App'; }; App.deferReadiness(); @@ -30,7 +30,7 @@ QUnit.module('Data Adapter', { }); }, teardown() { - run(function() { + run(() => { adapter.destroy(); App.destroy(); }); @@ -52,14 +52,14 @@ QUnit.test('Model types added with DefaultResolver', function() { run(App, 'advanceReadiness'); - var modelTypesAdded = function(types) { + function modelTypesAdded(types) { equal(types.length, 1); - var postType = types[0]; + let postType = types[0]; equal(postType.name, 'post', 'Correctly sets the name'); equal(postType.count, 3, 'Correctly sets the record count'); strictEqual(postType.object, App.Post, 'Correctly sets the object'); deepEqual(postType.columns, [{ name: 'title', desc: 'Title' }], 'Correctly sets the columns'); - }; + } run(adapter, 'watchModelTypes', modelTypesAdded); }); @@ -79,8 +79,8 @@ QUnit.test('getRecords gets a model name as second argument', function() { }); QUnit.test('Model types added with custom container-debug-adapter', function() { - var PostClass = Model.extend(); - var StubContainerDebugAdapter = DefaultResolver.extend({ + let PostClass = Model.extend(); + let StubContainerDebugAdapter = DefaultResolver.extend({ canCatalogEntriesByType(type) { return true; }, @@ -102,15 +102,15 @@ QUnit.test('Model types added with custom container-debug-adapter', function() { run(App, 'advanceReadiness'); - var modelTypesAdded = function(types) { + function modelTypesAdded(types) { equal(types.length, 1); - var postType = types[0]; + let postType = types[0]; equal(postType.name, PostClass.toString(), 'Correctly sets the name'); equal(postType.count, 3, 'Correctly sets the record count'); strictEqual(postType.object, PostClass, 'Correctly sets the object'); deepEqual(postType.columns, [{ name: 'title', desc: 'Title' }], 'Correctly sets the columns'); - }; + } run(adapter, 'watchModelTypes', modelTypesAdded); }); @@ -119,7 +119,7 @@ QUnit.test('Model Types Updated', function() { App.Post = Model.extend(); adapter = App.__container__.lookup('data-adapter:main'); - var records = emberA([1, 2, 3]); + let records = emberA([1, 2, 3]); adapter.reopen({ getRecords() { return records; @@ -128,28 +128,28 @@ QUnit.test('Model Types Updated', function() { run(App, 'advanceReadiness'); - var modelTypesAdded = function() { - run(function() { + function modelTypesAdded() { + run(() => { records.pushObject(4); }); - }; + } - var modelTypesUpdated = function(types) { - var postType = types[0]; + function modelTypesUpdated(types) { + let postType = types[0]; equal(postType.count, 4, 'Correctly updates the count'); - }; + } run(adapter, 'watchModelTypes', modelTypesAdded, modelTypesUpdated); }); QUnit.test('Records Added', function() { expect(8); - var countAdded = 1; + let countAdded = 1; App.Post = Model.extend(); - var post = App.Post.create(); - var recordList = emberA([post]); + let post = App.Post.create(); + let recordList = emberA([post]); adapter = App.__container__.lookup('data-adapter:main'); adapter.reopen({ @@ -167,13 +167,13 @@ QUnit.test('Records Added', function() { } }); - var recordsAdded = function(records) { - var record = records[0]; + function recordsAdded(records) { + let record = records[0]; equal(record.color, 'blue', 'Sets the color correctly'); deepEqual(record.columnValues, { title: 'Post ' + countAdded }, 'Sets the column values correctly'); deepEqual(record.searchKeywords, ['Post ' + countAdded], 'Sets search keywords correctly'); strictEqual(record.object, post, 'Sets the object to the record instance'); - }; + } adapter.watchRecords(App.Post, recordsAdded); countAdded++; @@ -182,11 +182,11 @@ QUnit.test('Records Added', function() { }); QUnit.test('Observes and releases a record correctly', function() { - var updatesCalled = 0; + let updatesCalled = 0; App.Post = Model.extend(); - var post = App.Post.create({ title: 'Post' }); - var recordList = emberA([post]); + let post = App.Post.create({ title: 'Post' }); + let recordList = emberA([post]); adapter = App.__container__.lookup('data-adapter:main'); adapter.reopen({ @@ -194,10 +194,10 @@ QUnit.test('Observes and releases a record correctly', function() { return recordList; }, observeRecord(record, recordUpdated) { - var self = this; - var callback = function() { + let self = this; + function callback() { recordUpdated(self.wrapRecord(record)); - }; + } addObserver(record, 'title', callback); return function() { removeObserver(record, 'title', callback); @@ -208,16 +208,16 @@ QUnit.test('Observes and releases a record correctly', function() { } }); - var recordsAdded = function() { + function recordsAdded() { set(post, 'title', 'Post Modified'); - }; + } - var recordsUpdated = function(records) { + function recordsUpdated(records) { updatesCalled++; equal(records[0].columnValues.title, 'Post Modified'); - }; + } - var release = adapter.watchRecords(App.Post, recordsAdded, recordsUpdated); + let release = adapter.watchRecords(App.Post, recordsAdded, recordsUpdated); release(); set(post, 'title', 'New Title'); equal(updatesCalled, 1, 'Release function removes observers'); diff --git a/packages/ember-glimmer-template-compiler/lib/system/template.js b/packages/ember-glimmer-template-compiler/lib/system/template.js index b93898d722a..9591e10f524 100644 --- a/packages/ember-glimmer-template-compiler/lib/system/template.js +++ b/packages/ember-glimmer-template-compiler/lib/system/template.js @@ -32,7 +32,8 @@ class Wrapper { } let templateId = 0; -const template = function(json) { + +export default function template(json) { let id = templateId++; let Factory = class extends Wrapper { constructor(options) { @@ -42,6 +43,4 @@ const template = function(json) { }; Factory.id = id; return Factory; -}; - -export default template; +} diff --git a/packages/ember-glimmer-template-compiler/tests/plugins-test.js b/packages/ember-glimmer-template-compiler/tests/plugins-test.js index 326e813976d..d261fd97fd4 100644 --- a/packages/ember-glimmer-template-compiler/tests/plugins-test.js +++ b/packages/ember-glimmer-template-compiler/tests/plugins-test.js @@ -34,7 +34,7 @@ QUnit.test('registering a plugin adds it to htmlbars-compiler options', function }); QUnit.test('registering an unknown type throws an error', function() { - throws(function() { + throws(() => { registerPlugin('asdf', 'whatever'); }, `Attempting to register whatever as "asdf" which is not a valid ${engineName} plugin type.`); }); diff --git a/packages/ember-glimmer/tests/integration/components/attribute-bindings-test.js b/packages/ember-glimmer/tests/integration/components/attribute-bindings-test.js index 4f8f19008fc..f4cb29193ba 100644 --- a/packages/ember-glimmer/tests/integration/components/attribute-bindings-test.js +++ b/packages/ember-glimmer/tests/integration/components/attribute-bindings-test.js @@ -469,5 +469,4 @@ moduleFor('Attribute bindings integration', class extends RenderingTest { this.assertComponentElement(this.nthChild(0), { tagName: 'a', attrs: { href: 'unsafe:javascript:alert(\'foo\')' } }); } - }); diff --git a/packages/ember-glimmer/tests/integration/components/curly-components-test.js b/packages/ember-glimmer/tests/integration/components/curly-components-test.js index 00a728f4875..e647eaa9955 100644 --- a/packages/ember-glimmer/tests/integration/components/curly-components-test.js +++ b/packages/ember-glimmer/tests/integration/components/curly-components-test.js @@ -136,12 +136,12 @@ moduleFor('Components test: curly components', class extends RenderingTest { this.render('{{foo-bar id=somethingUndefined}}'); - var foundId = this.$('h1').attr('id'); + let foundId = this.$('h1').attr('id'); assert.ok(/^ember/.test(foundId), 'Has a reasonable id attribute (found id=' + foundId + ').'); this.runTask(() => this.rerender()); - var newFoundId = this.$('h1').attr('id'); + let newFoundId = this.$('h1').attr('id'); assert.ok(/^ember/.test(newFoundId), 'Has a reasonable id attribute (found id=' + newFoundId + ').'); assert.equal(foundId, newFoundId); @@ -156,12 +156,12 @@ moduleFor('Components test: curly components', class extends RenderingTest { this.render('{{foo-bar id="custom-id"}}'); - var foundId = this.$('h1').attr('id'); + let foundId = this.$('h1').attr('id'); assert.equal(foundId, 'custom-id'); this.runTask(() => this.rerender()); - var newFoundId = this.$('h1').attr('id'); + let newFoundId = this.$('h1').attr('id'); assert.equal(newFoundId, 'custom-id'); assert.equal(foundId, newFoundId); diff --git a/packages/ember-glimmer/tests/integration/helpers/-class-test.js b/packages/ember-glimmer/tests/integration/helpers/-class-test.js index 6cf340da91e..402782a9c68 100644 --- a/packages/ember-glimmer/tests/integration/helpers/-class-test.js +++ b/packages/ember-glimmer/tests/integration/helpers/-class-test.js @@ -2,7 +2,6 @@ import { RenderingTest, moduleFor } from '../../utils/test-case'; import { classes } from '../../utils/test-helpers'; import { set } from 'ember-metal/property_set'; - moduleFor('Helpers test: {{-class}}', class extends RenderingTest { ['@glimmer casts binding to dasherized class']() { diff --git a/packages/ember-glimmer/tests/integration/helpers/concat-test.js b/packages/ember-glimmer/tests/integration/helpers/concat-test.js index 1c5ded2180f..419e3431de0 100644 --- a/packages/ember-glimmer/tests/integration/helpers/concat-test.js +++ b/packages/ember-glimmer/tests/integration/helpers/concat-test.js @@ -95,5 +95,4 @@ moduleFor('Helpers test: {{concat}}', class extends RenderingTest { this.assertText('Truthy!'); } - }); diff --git a/packages/ember-glimmer/tests/integration/helpers/hash-test.js b/packages/ember-glimmer/tests/integration/helpers/hash-test.js index 16f5cd78a13..dc71a39bd0e 100644 --- a/packages/ember-glimmer/tests/integration/helpers/hash-test.js +++ b/packages/ember-glimmer/tests/integration/helpers/hash-test.js @@ -167,5 +167,4 @@ moduleFor('Helpers test: {{hash}}', class extends RenderingTest { this.assertText('Chad Hietala'); } - }); diff --git a/packages/ember-glimmer/tests/integration/helpers/input-test.js b/packages/ember-glimmer/tests/integration/helpers/input-test.js index c4c54346281..1b8be450213 100644 --- a/packages/ember-glimmer/tests/integration/helpers/input-test.js +++ b/packages/ember-glimmer/tests/integration/helpers/input-test.js @@ -439,5 +439,4 @@ moduleFor(`@htmlbars Helpers test: {{input type='text'}}`, class extends InputRe // this.assertAttr('size', undefined); //NOTE: re-enable once `size` bug above has been addressed this.assertAttr('tabindex', undefined); } - }); diff --git a/packages/ember-glimmer/tests/integration/helpers/loc-test.js b/packages/ember-glimmer/tests/integration/helpers/loc-test.js index 74845c3c15a..6c8b244501d 100644 --- a/packages/ember-glimmer/tests/integration/helpers/loc-test.js +++ b/packages/ember-glimmer/tests/integration/helpers/loc-test.js @@ -85,5 +85,4 @@ moduleFor('Helpers test: {{loc}}', class extends RenderingTest { this.assertText('Hallo Freund - Hallo, Mr. Pitkin', 'the bound value is correct after replacement'); } - }); diff --git a/packages/ember-htmlbars-template-compiler/lib/plugins/transform-closure-component-attrs-into-mut.js b/packages/ember-htmlbars-template-compiler/lib/plugins/transform-closure-component-attrs-into-mut.js index 81d0b9994f3..a80f8bec14a 100644 --- a/packages/ember-htmlbars-template-compiler/lib/plugins/transform-closure-component-attrs-into-mut.js +++ b/packages/ember-htmlbars-template-compiler/lib/plugins/transform-closure-component-attrs-into-mut.js @@ -1,4 +1,4 @@ -function TransformClosureComponentAttrsIntoMut() { +export default function TransformClosureComponentAttrsIntoMut() { // set later within HTMLBars to the syntax package this.syntax = null; } @@ -12,7 +12,7 @@ TransformClosureComponentAttrsIntoMut.prototype.transform = function TransformCl let b = this.syntax.builders; this.syntax.traverse(ast, { - SubExpression: function(node) { + SubExpression(node) { if (isComponentClosure(node)) { mutParameters(b, node); } @@ -33,19 +33,12 @@ function mutParameters(builder, node) { } } - each(node.hash.pairs, function(pair) { + for (let i = 0; i < node.hash.pairs.length; i++) { + let pair = node.hash.pairs[i]; let { value } = pair; if (value.type === 'PathExpression') { pair.value = builder.sexpr(builder.path('@mut'), [pair.value]); } - }); -} - -function each(list, callback) { - for (var i = 0, l = list.length; i < l; i++) { - callback(list[i]); } } - -export default TransformClosureComponentAttrsIntoMut; diff --git a/packages/ember-htmlbars-template-compiler/lib/plugins/transform-component-attrs-into-mut.js b/packages/ember-htmlbars-template-compiler/lib/plugins/transform-component-attrs-into-mut.js index 75b431eefb4..dd7b304ae71 100644 --- a/packages/ember-htmlbars-template-compiler/lib/plugins/transform-component-attrs-into-mut.js +++ b/packages/ember-htmlbars-template-compiler/lib/plugins/transform-component-attrs-into-mut.js @@ -1,4 +1,4 @@ -function TransformComponentAttrsIntoMut() { +export default function TransformComponentAttrsIntoMut() { // set later within HTMLBars to the syntax package this.syntax = null; } @@ -9,19 +9,20 @@ function TransformComponentAttrsIntoMut() { @param {AST} ast The AST to be transformed. */ TransformComponentAttrsIntoMut.prototype.transform = function TransformComponentAttrsIntoMut_transform(ast) { - var b = this.syntax.builders; - var walker = new this.syntax.Walker(); + let b = this.syntax.builders; + let walker = new this.syntax.Walker(); walker.visit(ast, function(node) { if (!validate(node)) { return; } - each(node.hash.pairs, function(pair) { + for (let i = 0; i < node.hash.pairs.length; i++) { + let pair = node.hash.pairs[i]; let { value } = pair; if (value.type === 'PathExpression') { pair.value = b.sexpr(b.path('@mut'), [pair.value]); } - }); + } }); return ast; @@ -30,11 +31,3 @@ TransformComponentAttrsIntoMut.prototype.transform = function TransformComponent function validate(node) { return node.type === 'BlockStatement' || node.type === 'MustacheStatement'; } - -function each(list, callback) { - for (var i = 0; i < list.length; i++) { - callback(list[i]); - } -} - -export default TransformComponentAttrsIntoMut; diff --git a/packages/ember-htmlbars-template-compiler/lib/plugins/transform-component-curly-to-readonly.js b/packages/ember-htmlbars-template-compiler/lib/plugins/transform-component-curly-to-readonly.js index 3254ca20c79..cd1c77ae39a 100644 --- a/packages/ember-htmlbars-template-compiler/lib/plugins/transform-component-curly-to-readonly.js +++ b/packages/ember-htmlbars-template-compiler/lib/plugins/transform-component-curly-to-readonly.js @@ -1,4 +1,4 @@ -function TransformComponentCurlyToReadonly() { +export default function TransformComponentCurlyToReadonly() { // set later within HTMLBars to the syntax package this.syntax = null; } @@ -9,18 +9,20 @@ function TransformComponentCurlyToReadonly() { @param {AST} ast The AST to be transformed. */ TransformComponentCurlyToReadonly.prototype.transform = function TransformComponetnCurlyToReadonly_transform(ast) { - var b = this.syntax.builders; - var walker = new this.syntax.Walker(); + let b = this.syntax.builders; + let walker = new this.syntax.Walker(); - walker.visit(ast, function(node) { + walker.visit(ast, node => { if (!validate(node)) { return; } - each(node.attributes, function(attr) { + for (let i = 0; i < node.attributes.length; i++) { + let attr = node.attributes[i]; + if (attr.value.type !== 'MustacheStatement') { return; } if (attr.value.params.length || attr.value.hash.pairs.length) { return; } attr.value = b.mustache(b.path('readonly'), [attr.value.path], null, !attr.value.escape); - }); + } }); return ast; @@ -29,11 +31,3 @@ TransformComponentCurlyToReadonly.prototype.transform = function TransformCompon function validate(node) { return node.type === 'ComponentNode'; } - -function each(list, callback) { - for (var i = 0; i < list.length; i++) { - callback(list[i]); - } -} - -export default TransformComponentCurlyToReadonly; diff --git a/packages/ember-htmlbars-template-compiler/lib/plugins/transform-old-class-binding-syntax.js b/packages/ember-htmlbars-template-compiler/lib/plugins/transform-old-class-binding-syntax.js index 9e4ebef9d5d..fad142c3d03 100644 --- a/packages/ember-htmlbars-template-compiler/lib/plugins/transform-old-class-binding-syntax.js +++ b/packages/ember-htmlbars-template-compiler/lib/plugins/transform-old-class-binding-syntax.js @@ -4,10 +4,10 @@ export default function TransformOldClassBindingSyntax(options) { } TransformOldClassBindingSyntax.prototype.transform = function TransformOldClassBindingSyntax_transform(ast) { - var b = this.syntax.builders; - var walker = new this.syntax.Walker(); + let b = this.syntax.builders; + let walker = new this.syntax.Walker(); - walker.visit(ast, function(node) { + walker.visit(ast, node => { if (!validate(node)) { return; } let allOfTheMicrosyntaxes = []; @@ -63,7 +63,7 @@ TransformOldClassBindingSyntax.prototype.transform = function TransformOldClassB }; function buildSexprs(microsyntax, sexprs, b) { - for (var i = 0; i < microsyntax.length; i++) { + for (let i = 0; i < microsyntax.length; i++) { let [propName, activeClass, inactiveClass] = microsyntax[i]; let sexpr; @@ -107,15 +107,15 @@ function validate(node) { } function each(list, callback) { - for (var i = 0; i < list.length; i++) { + for (let i = 0; i < list.length; i++) { callback(list[i], i); } } function parseMicrosyntax(string) { - var segments = string.split(' '); + let segments = string.split(' '); - for (var i = 0; i < segments.length; i++) { + for (let i = 0; i < segments.length; i++) { segments[i] = segments[i].split(':'); } diff --git a/packages/ember-htmlbars-template-compiler/lib/system/compile-options.js b/packages/ember-htmlbars-template-compiler/lib/system/compile-options.js index 0b276f2ed17..1e629e0fb69 100644 --- a/packages/ember-htmlbars-template-compiler/lib/system/compile-options.js +++ b/packages/ember-htmlbars-template-compiler/lib/system/compile-options.js @@ -11,8 +11,6 @@ import TransformComponentAttrsIntoMut from '../plugins/transform-component-attrs import TransformComponentCurlyToReadonly from '../plugins/transform-component-curly-to-readonly'; import TransformOldClassBindingSyntax from '../plugins/transform-old-class-binding-syntax'; -let compileOptions; - export let PLUGINS = [ ...defaultPlugins, @@ -25,8 +23,7 @@ export let PLUGINS = [ let USER_PLUGINS = []; -function mergePlugins(options) { - options = options || {}; +function mergePlugins(options = {}) { options = assign({}, options); if (!options.plugins) { options.plugins = { ast: [...USER_PLUGINS, ...PLUGINS] }; @@ -65,9 +62,8 @@ export function removePlugin(type, PluginClass) { @private @property compileOptions */ -compileOptions = function(_options) { - var disableComponentGeneration = true; - +export default function compileOptions(_options) { + let disableComponentGeneration = true; let options; // When calling `Ember.Handlebars.compile()` a second argument of `true` // had a special meaning (long since lost), this just gaurds against @@ -91,6 +87,4 @@ compileOptions = function(_options) { }; return options; -}; - -export default compileOptions; +} diff --git a/packages/ember-htmlbars-template-compiler/lib/system/compile.js b/packages/ember-htmlbars-template-compiler/lib/system/compile.js index ae4e5a6f22e..d54ca505cdb 100644 --- a/packages/ember-htmlbars-template-compiler/lib/system/compile.js +++ b/packages/ember-htmlbars-template-compiler/lib/system/compile.js @@ -13,7 +13,7 @@ export default function compiler(string, options) { throw new Error('Cannot call `compile` without the template compiler loaded. Please load `ember-template-compiler.js` prior to calling `compile`.'); } - var templateSpec = compile(string, compileOptions(options)); + let templateSpec = compile(string, compileOptions(options)); return template(templateSpec); } diff --git a/packages/ember-htmlbars-template-compiler/lib/system/template.js b/packages/ember-htmlbars-template-compiler/lib/system/template.js index 53e382164a1..4c1a200ca15 100644 --- a/packages/ember-htmlbars-template-compiler/lib/system/template.js +++ b/packages/ember-htmlbars-template-compiler/lib/system/template.js @@ -2,7 +2,7 @@ import require from 'require'; let { wrap } = require('htmlbars-runtime/hooks'); -let template = function(templateSpec) { +export default function template(templateSpec) { if (!templateSpec.render) { templateSpec = wrap(templateSpec); } @@ -11,6 +11,4 @@ let template = function(templateSpec) { templateSpec.isMethod = false; return templateSpec; -}; - -export default template; +} diff --git a/packages/ember-htmlbars-template-compiler/tests/system/compile_test.js b/packages/ember-htmlbars-template-compiler/tests/system/compile_test.js index d685b2d6368..29b3fa3fe21 100644 --- a/packages/ember-htmlbars-template-compiler/tests/system/compile_test.js +++ b/packages/ember-htmlbars-template-compiler/tests/system/compile_test.js @@ -3,9 +3,9 @@ import { compile } from '../utils/helpers'; QUnit.module('ember-htmlbars: compile'); QUnit.test('calls template on the compiled function', function() { - var templateString = '{{foo}} -- {{some-bar blah=\'foo\'}}'; + let templateString = '{{foo}} -- {{some-bar blah=\'foo\'}}'; - var actual = compile(templateString); + let actual = compile(templateString); ok(actual.isTop, 'sets isTop via template function'); ok(actual.isMethod === false, 'sets isMethod via template function'); diff --git a/packages/ember-htmlbars/lib/compat.js b/packages/ember-htmlbars/lib/compat.js index 17603cbc00c..aadd0790049 100644 --- a/packages/ember-htmlbars/lib/compat.js +++ b/packages/ember-htmlbars/lib/compat.js @@ -4,7 +4,7 @@ import { escapeExpression } from 'ember-htmlbars/utils/string'; -var EmberHandlebars = Ember.Handlebars = Ember.Handlebars || {}; +const EmberHandlebars = Ember.Handlebars = Ember.Handlebars || {}; EmberHandlebars.SafeString = SafeString; EmberHandlebars.Utils = { diff --git a/packages/ember-htmlbars/lib/component.js b/packages/ember-htmlbars/lib/component.js index 1d62d845558..e8d7d97abeb 100644 --- a/packages/ember-htmlbars/lib/component.js +++ b/packages/ember-htmlbars/lib/component.js @@ -194,7 +194,7 @@ const Component = View.extend(TargetActionSupport, { targetObject: computed('controller', function(key) { if (this._targetObject) { return this._targetObject; } if (this._controller) { return this._controller; } - var parentView = get(this, 'parentView'); + let parentView = get(this, 'parentView'); return parentView ? get(parentView, 'controller') : null; }), @@ -279,7 +279,7 @@ const Component = View.extend(TargetActionSupport, { @public */ sendAction(action, ...contexts) { - var actionName; + let actionName; // Send the default action if (action === undefined) { @@ -302,11 +302,11 @@ const Component = View.extend(TargetActionSupport, { }, send(actionName, ...args) { - var target; - var action = this.actions && this.actions[actionName]; + let target; + let action = this.actions && this.actions[actionName]; if (action) { - var shouldBubble = action.apply(this, args) === true; + let shouldBubble = action.apply(this, args) === true; if (!shouldBubble) { return; } } diff --git a/packages/ember-htmlbars/lib/components/link-to.js b/packages/ember-htmlbars/lib/components/link-to.js index 33aeb25a082..dd4afd0f97c 100644 --- a/packages/ember-htmlbars/lib/components/link-to.js +++ b/packages/ember-htmlbars/lib/components/link-to.js @@ -341,7 +341,7 @@ import { flaggedInstrument } from 'ember-metal/instrumentation'; @see {Ember.Templates.helpers.link-to} @private **/ -let LinkComponent = EmberComponent.extend({ +const LinkComponent = EmberComponent.extend({ layout, tagName: 'a', @@ -819,7 +819,7 @@ let LinkComponent = EmberComponent.extend({ } }); -LinkComponent.toString = function() { return 'LinkComponent'; }; +LinkComponent.toString = () => 'LinkComponent'; LinkComponent.reopenClass({ positionalParams: 'params' diff --git a/packages/ember-htmlbars/lib/components/text_field.js b/packages/ember-htmlbars/lib/components/text_field.js index 6fc91890e1d..d9d0f2a90a5 100644 --- a/packages/ember-htmlbars/lib/components/text_field.js +++ b/packages/ember-htmlbars/lib/components/text_field.js @@ -8,8 +8,8 @@ import Component from '../component'; import TextSupport from 'ember-views/mixins/text_support'; import EmptyObject from 'ember-metal/empty_object'; -var inputTypeTestElement; -var inputTypes = new EmptyObject(); +let inputTypeTestElement; +const inputTypes = new EmptyObject(); function canSetTypeOfInput(type) { if (type in inputTypes) { return inputTypes[type]; @@ -111,7 +111,7 @@ export default Component.extend(TextSupport, { }, set(key, value) { - var type = 'text'; + let type = 'text'; if (canSetTypeOfInput(value)) { type = value; diff --git a/packages/ember-htmlbars/lib/env.js b/packages/ember-htmlbars/lib/env.js index 836db177f0d..2ccccd14575 100644 --- a/packages/ember-htmlbars/lib/env.js +++ b/packages/ember-htmlbars/lib/env.js @@ -35,7 +35,7 @@ import keywords, { registerKeyword } from 'ember-htmlbars/keywords'; import DOMHelper from 'ember-htmlbars/system/dom-helper'; -var emberHooks = assign({}, hooks); +const emberHooks = assign({}, hooks); emberHooks.keywords = keywords; assign(emberHooks, { @@ -109,6 +109,6 @@ export default { useFragmentCache: true }; -var domHelper = environment.hasDOM ? new DOMHelper() : null; +const domHelper = environment.hasDOM ? new DOMHelper() : null; export { domHelper }; diff --git a/packages/ember-htmlbars/lib/helper.js b/packages/ember-htmlbars/lib/helper.js index 3ebfcd1068b..cd1cb82e1e8 100644 --- a/packages/ember-htmlbars/lib/helper.js +++ b/packages/ember-htmlbars/lib/helper.js @@ -45,7 +45,7 @@ import Object from 'ember-runtime/system/object'; @public @since 1.13.0 */ -var Helper = Object.extend({ +const Helper = Object.extend({ isHelperInstance: true, /** @@ -111,10 +111,10 @@ Helper.reopenClass({ @public @since 1.13.0 */ -export function helper(helperFn) { +export function helper(compute) { return { isHelperInstance: true, - compute: helperFn + compute }; } diff --git a/packages/ember-htmlbars/lib/helpers.js b/packages/ember-htmlbars/lib/helpers.js index a13cb01f325..9e950c15c57 100644 --- a/packages/ember-htmlbars/lib/helpers.js +++ b/packages/ember-htmlbars/lib/helpers.js @@ -9,7 +9,7 @@ */ import EmptyObject from 'ember-metal/empty_object'; -var helpers = new EmptyObject(); +const helpers = new EmptyObject(); /** @module ember diff --git a/packages/ember-htmlbars/lib/helpers/-join-classes.js b/packages/ember-htmlbars/lib/helpers/-join-classes.js index 281d523f0f9..8c0680dd6e3 100644 --- a/packages/ember-htmlbars/lib/helpers/-join-classes.js +++ b/packages/ember-htmlbars/lib/helpers/-join-classes.js @@ -5,7 +5,7 @@ */ export default function joinClasses(classNames) { - var result = []; + let result = []; for (let i = 0; i < classNames.length; i++) { let className = classNames[i]; diff --git a/packages/ember-htmlbars/lib/helpers/-normalize-class.js b/packages/ember-htmlbars/lib/helpers/-normalize-class.js index 1e0c70a12c9..f037af1a3dd 100644 --- a/packages/ember-htmlbars/lib/helpers/-normalize-class.js +++ b/packages/ember-htmlbars/lib/helpers/-normalize-class.js @@ -11,8 +11,8 @@ import { isPath } from 'ember-metal/path_cache'; @private */ export default function normalizeClass(params, hash) { - var [propName, value] = params; - var { activeClass, inactiveClass } = hash; + let [propName, value] = params; + let { activeClass, inactiveClass } = hash; // When using the colon syntax, evaluate the truthiness or falsiness // of the value to determine which className to return. @@ -28,7 +28,7 @@ export default function normalizeClass(params, hash) { } else if (value === true) { // Only apply to last segment in the path. if (propName && isPath(propName)) { - var segments = propName.split('.'); + let segments = propName.split('.'); propName = segments[segments.length - 1]; } diff --git a/packages/ember-htmlbars/lib/helpers/each-in.js b/packages/ember-htmlbars/lib/helpers/each-in.js index 88ee24be1aa..6e3029bb177 100644 --- a/packages/ember-htmlbars/lib/helpers/each-in.js +++ b/packages/ember-htmlbars/lib/helpers/each-in.js @@ -37,17 +37,15 @@ import shouldDisplay from '../streams/should_display'; @public @since 2.1.0 */ -var eachInHelper = function([ object ], hash, blocks) { - var objKeys, prop, i; +export default function eachInHelper([ object ], hash, blocks) { + let objKeys, prop; objKeys = object ? Object.keys(object) : []; if (shouldDisplay(objKeys)) { - for (i = 0; i < objKeys.length; i++) { + for (let i = 0; i < objKeys.length; i++) { prop = objKeys[i]; blocks.template.yieldItem(prop, [prop, object[prop]]); } } else if (blocks.inverse.yield) { blocks.inverse.yield(); } -}; - -export default eachInHelper; +} diff --git a/packages/ember-htmlbars/lib/helpers/each.js b/packages/ember-htmlbars/lib/helpers/each.js index d1bbb14ef1d..50b665b2cdd 100644 --- a/packages/ember-htmlbars/lib/helpers/each.js +++ b/packages/ember-htmlbars/lib/helpers/each.js @@ -84,12 +84,12 @@ import decodeEachKey from 'ember-htmlbars/utils/decode-each-key'; @public */ export default function eachHelper(params, hash, blocks) { - var list = params[0]; - var keyPath = hash.key; + let list = params[0]; + let keyPath = hash.key; if (shouldDisplay(list)) { forEach(list, (item, i) => { - var key = decodeEachKey(item, keyPath, i); + let key = decodeEachKey(item, keyPath, i); blocks.template.yieldItem(key, [item, i]); }); diff --git a/packages/ember-htmlbars/lib/hooks/bind-shadow-scope.js b/packages/ember-htmlbars/lib/hooks/bind-shadow-scope.js index b149e0b5f08..37d59df74d2 100644 --- a/packages/ember-htmlbars/lib/hooks/bind-shadow-scope.js +++ b/packages/ember-htmlbars/lib/hooks/bind-shadow-scope.js @@ -8,7 +8,7 @@ import ProxyStream from '../streams/proxy-stream'; export default function bindShadowScope(env, parentScope, shadowScope, options) { if (!options) { return; } - var view = options.view; + let view = options.view; if (view && !view.isComponent) { shadowScope.bindLocal('view', newStream(view, 'view')); diff --git a/packages/ember-htmlbars/lib/hooks/component.js b/packages/ember-htmlbars/lib/hooks/component.js index d5a7f8e8549..80790a2f367 100644 --- a/packages/ember-htmlbars/lib/hooks/component.js +++ b/packages/ember-htmlbars/lib/hooks/component.js @@ -17,7 +17,7 @@ import { import { buildHTMLTemplate } from 'ember-htmlbars/system/build-component-template'; export default function componentHook(renderNode, env, scope, _tagName, params, _attrs, templates, visitor) { - var state = renderNode.getState(); + let state = renderNode.getState(); let tagName = _tagName; let attrs = _attrs; diff --git a/packages/ember-htmlbars/lib/hooks/destroy-render-node.js b/packages/ember-htmlbars/lib/hooks/destroy-render-node.js index fcfff351da6..4090de331c2 100644 --- a/packages/ember-htmlbars/lib/hooks/destroy-render-node.js +++ b/packages/ember-htmlbars/lib/hooks/destroy-render-node.js @@ -8,7 +8,7 @@ export default function destroyRenderNode(renderNode) { renderNode.emberView.destroy(); } - var streamUnsubscribers = renderNode.streamUnsubscribers; + let streamUnsubscribers = renderNode.streamUnsubscribers; if (streamUnsubscribers) { for (let i = 0; i < streamUnsubscribers.length; i++) { streamUnsubscribers[i](); diff --git a/packages/ember-htmlbars/lib/hooks/element.js b/packages/ember-htmlbars/lib/hooks/element.js index a944939ea9a..d272dc7a345 100644 --- a/packages/ember-htmlbars/lib/hooks/element.js +++ b/packages/ember-htmlbars/lib/hooks/element.js @@ -12,10 +12,10 @@ export default function emberElement(morph, env, scope, path, params, hash, visi return; } - var result; - var helper = findHelper(path, scope.getSelf(), env); + let result; + let helper = findHelper(path, scope.getSelf(), env); if (helper) { - var helperStream = buildHelperStream(helper, params, hash, { element: morph.element }, env, scope, path); + let helperStream = buildHelperStream(helper, params, hash, { element: morph.element }, env, scope, path); result = helperStream.value(); } else { result = env.hooks.get(env, scope, path); diff --git a/packages/ember-htmlbars/lib/hooks/get-root.js b/packages/ember-htmlbars/lib/hooks/get-root.js index c250305408c..1c91a61ce05 100644 --- a/packages/ember-htmlbars/lib/hooks/get-root.js +++ b/packages/ember-htmlbars/lib/hooks/get-root.js @@ -24,7 +24,7 @@ function getKey(scope, key) { if (attrs) { return attrs; } } - var self = scope.getSelf() || scope.getLocal('view'); + let self = scope.getSelf() || scope.getLocal('view'); if (self) { return self.getKey(key); diff --git a/packages/ember-htmlbars/lib/hooks/has-helper.js b/packages/ember-htmlbars/lib/hooks/has-helper.js index 2387938a021..a4eb09c337c 100644 --- a/packages/ember-htmlbars/lib/hooks/has-helper.js +++ b/packages/ember-htmlbars/lib/hooks/has-helper.js @@ -7,7 +7,7 @@ export default function hasHelperHook(env, scope, helperName) { let owner = env.owner; if (validateLazyHelperName(helperName, owner, env.hooks.keywords)) { - var registrationName = 'helper:' + helperName; + let registrationName = 'helper:' + helperName; if (owner.hasRegistration(registrationName)) { return true; } diff --git a/packages/ember-htmlbars/lib/hooks/invoke-helper.js b/packages/ember-htmlbars/lib/hooks/invoke-helper.js index b1c9c8bb191..94ecee55df2 100644 --- a/packages/ember-htmlbars/lib/hooks/invoke-helper.js +++ b/packages/ember-htmlbars/lib/hooks/invoke-helper.js @@ -2,7 +2,7 @@ import { buildHelperStream } from 'ember-htmlbars/system/invoke-helper'; import subscribe from 'ember-htmlbars/utils/subscribe'; export default function invokeHelper(morph, env, scope, visitor, params, hash, helper, templates, context) { - var helperStream = buildHelperStream(helper, params, hash, templates, env, scope); + let helperStream = buildHelperStream(helper, params, hash, templates, env, scope); // Ember.Helper helpers are pure values, thus linkable. if (helperStream.linkable) { @@ -12,11 +12,11 @@ export default function invokeHelper(morph, env, scope, visitor, params, hash, h // We subscribe the morph to the helperStream here, and also subscribe // the helperStream to any params. let addedDependency = false; - for (var i = 0; i < params.length; i++) { + for (let i = 0; i < params.length; i++) { addedDependency = true; helperStream.addDependency(params[i]); } - for (var key in hash) { + for (let key in hash) { addedDependency = true; helperStream.addDependency(hash[key]); } diff --git a/packages/ember-htmlbars/lib/hooks/link-render-node.js b/packages/ember-htmlbars/lib/hooks/link-render-node.js index d85db7b3053..f839726f4f3 100644 --- a/packages/ember-htmlbars/lib/hooks/link-render-node.js +++ b/packages/ember-htmlbars/lib/hooks/link-render-node.js @@ -73,7 +73,7 @@ export function linkParamsFor(path, params) { function eachParam(list) { let listChange = getKey(list, '[]'); - let stream = chain(list, function() { + let stream = chain(list, () => { read(listChange); return read(list); }, 'each'); @@ -86,7 +86,7 @@ function shouldDisplay(predicate, coercer) { let length = getKey(predicate, 'length'); let isTruthy = getKey(predicate, 'isTruthy'); - let stream = chain(predicate, function() { + let stream = chain(predicate, () => { let predicateVal = read(predicate); let lengthVal = read(length); let isTruthyVal = read(isTruthy); diff --git a/packages/ember-htmlbars/lib/hooks/subexpr.js b/packages/ember-htmlbars/lib/hooks/subexpr.js index 06bd7f6e267..8a69f29a257 100644 --- a/packages/ember-htmlbars/lib/hooks/subexpr.js +++ b/packages/ember-htmlbars/lib/hooks/subexpr.js @@ -14,23 +14,23 @@ import { linkParamsFor } from 'ember-htmlbars/hooks/link-render-node'; export default function subexpr(env, scope, helperName, params, hash) { // TODO: Keywords and helper invocation should be integrated into // the subexpr hook upstream in HTMLBars. - var keyword = env.hooks.keywords[helperName]; + let keyword = env.hooks.keywords[helperName]; if (keyword) { return keyword(null, env, scope, params, hash, null, null); } linkParamsFor(helperName, params); - var label = labelForSubexpr(params, hash, helperName); - var helper = lookupHelper(helperName, scope.getSelf(), env); + let label = labelForSubexpr(params, hash, helperName); + let helper = lookupHelper(helperName, scope.getSelf(), env); - var helperStream = buildHelperStream(helper, params, hash, null, env, scope, label); + let helperStream = buildHelperStream(helper, params, hash, null, env, scope, label); - for (var i = 0; i < params.length; i++) { + for (let i = 0; i < params.length; i++) { helperStream.addDependency(params[i]); } - for (var key in hash) { + for (let key in hash) { helperStream.addDependency(hash[key]); } @@ -38,9 +38,9 @@ export default function subexpr(env, scope, helperName, params, hash) { } export function labelForSubexpr(params, hash, helperName) { - var paramsLabels = labelsForParams(params); - var hashLabels = labelsForHash(hash); - var label = `(${helperName}`; + let paramsLabels = labelsForParams(params); + let hashLabels = labelsForHash(hash); + let label = `(${helperName}`; if (paramsLabels) { label += ` ${paramsLabels}`; } if (hashLabels) { label += ` ${hashLabels}`; } @@ -53,9 +53,9 @@ function labelsForParams(params) { } function labelsForHash(hash) { - var out = []; + let out = []; - for (var prop in hash) { + for (let prop in hash) { out.push(`${prop}=${labelFor(hash[prop])}`); } diff --git a/packages/ember-htmlbars/lib/keywords.js b/packages/ember-htmlbars/lib/keywords.js index 5bf2d41998b..d8782c11a4a 100644 --- a/packages/ember-htmlbars/lib/keywords.js +++ b/packages/ember-htmlbars/lib/keywords.js @@ -9,7 +9,7 @@ import { hooks } from 'htmlbars-runtime'; @private @property helpers */ -var keywords = Object.create(hooks.keywords); +const keywords = Object.create(hooks.keywords); /** @module ember diff --git a/packages/ember-htmlbars/lib/keywords/closure-action.js b/packages/ember-htmlbars/lib/keywords/closure-action.js index d0e58bcbc89..ca3de41463e 100644 --- a/packages/ember-htmlbars/lib/keywords/closure-action.js +++ b/packages/ember-htmlbars/lib/keywords/closure-action.js @@ -16,7 +16,7 @@ export const INVOKE = symbol('INVOKE'); export const ACTION = symbol('ACTION'); export default function closureAction(morph, env, scope, params, hash, template, inverse, visitor) { - let s = new Stream(function() { + let s = new Stream(() => { let rawAction = params[0]; let actionArguments = readArray(params.slice(1, params.length)); @@ -67,9 +67,7 @@ export default function closureAction(morph, env, scope, params, hash, template, } return createClosureAction(this, target, action, valuePath, actionArguments); - }, function() { - return labelForSubexpr(params, hash, 'action'); - }); + }, () => labelForSubexpr(params, hash, 'action')); params.forEach(s.addDependency, s); Object.keys(hash).forEach(item => s.addDependency(item)); @@ -78,11 +76,11 @@ export default function closureAction(morph, env, scope, params, hash, template, } function createClosureAction(stream, target, action, valuePath, actionArguments) { - var closureAction; + let closureAction; if (actionArguments.length > 0) { closureAction = function(...passedArguments) { - var args = actionArguments; + let args = actionArguments; if (passedArguments.length > 0) { args = actionArguments.concat(passedArguments); } diff --git a/packages/ember-htmlbars/lib/keywords/closure-component.js b/packages/ember-htmlbars/lib/keywords/closure-component.js index 78fcba62897..4696ce90ced 100644 --- a/packages/ember-htmlbars/lib/keywords/closure-component.js +++ b/packages/ember-htmlbars/lib/keywords/closure-component.js @@ -20,7 +20,7 @@ export const COMPONENT_PATH = symbol('COMPONENT_PATH'); export const COMPONENT_POSITIONAL_PARAMS = symbol('COMPONENT_POSITIONAL_PARAMS'); export const COMPONENT_HASH = symbol('COMPONENT_HASH'); -let ClosureComponentStream = BasicStream.extend({ +const ClosureComponentStream = BasicStream.extend({ init(env, path, params, hash) { this._env = env; this._path = path; diff --git a/packages/ember-htmlbars/lib/keywords/debugger.js b/packages/ember-htmlbars/lib/keywords/debugger.js index 831fa9789a6..345f79bd570 100644 --- a/packages/ember-htmlbars/lib/keywords/debugger.js +++ b/packages/ember-htmlbars/lib/keywords/debugger.js @@ -52,8 +52,8 @@ import { info } from 'ember-metal/debug'; export default function debuggerKeyword(morph, env, scope) { /* jshint unused: false, debug: true */ - var view = env.hooks.getValue(scope.getLocal('view')); - var context = env.hooks.getValue(scope.getSelf()); + let view = env.hooks.getValue(scope.getLocal('view')); + let context = env.hooks.getValue(scope.getSelf()); function get(path) { return env.hooks.getValue(env.hooks.get(env, scope, path)); diff --git a/packages/ember-htmlbars/lib/keywords/element-action.js b/packages/ember-htmlbars/lib/keywords/element-action.js index 8a0ed60f085..f5c13e67b24 100644 --- a/packages/ember-htmlbars/lib/keywords/element-action.js +++ b/packages/ember-htmlbars/lib/keywords/element-action.js @@ -7,11 +7,11 @@ import { isSimpleClick } from 'ember-views/system/utils'; import ActionManager from 'ember-views/system/action_manager'; export default { - setupState: function(state, env, scope, params, hash) { - var getStream = env.hooks.get; - var read = env.hooks.getValue; + setupState(state, env, scope, params, hash) { + let getStream = env.hooks.get; + let read = env.hooks.getValue; - var actionName = read(params[0]); + let actionName = read(params[0]); assert( 'You specified a quoteless path to the {{action}} helper ' + @@ -20,12 +20,12 @@ export default { typeof actionName === 'string' || typeof actionName === 'function' ); - var actionArgs = []; - for (var i = 1; i < params.length; i++) { + let actionArgs = []; + for (let i = 1; i < params.length; i++) { actionArgs.push(readUnwrappedModel(params[i])); } - var target; + let target; if (hash.target) { if (typeof hash.target === 'string') { target = read(getStream(env, scope, hash.target)); @@ -39,11 +39,11 @@ export default { return { actionName, actionArgs, target }; }, - isStable: function(state, env, scope, params, hash) { + isStable(state, env, scope, params, hash) { return true; }, - render: function(node, env, scope, params, hash, template, inverse, visitor) { + render(node, env, scope, params, hash, template, inverse, visitor) { let actionId = env.dom.getAttribute(node.element, 'data-ember-action') || uuid(); ActionHelper.registerAction({ @@ -56,22 +56,20 @@ export default { allowedKeys: hash.allowedKeys }); - node.cleanup = function() { - ActionHelper.unregisterAction(actionId); - }; + node.cleanup = () => ActionHelper.unregisterAction(actionId); env.dom.setAttribute(node.element, 'data-ember-action', actionId); } }; -export var ActionHelper = {}; +export let ActionHelper = {}; // registeredActions is re-exported for compatibility with older plugins // that were using this undocumented API. ActionHelper.registeredActions = ActionManager.registeredActions; ActionHelper.registerAction = function({ actionId, node, eventName, preventDefault, bubbles, allowedKeys }) { - var actions = ActionManager.registeredActions[actionId]; + let actions = ActionManager.registeredActions[actionId]; if (!actions) { actions = ActionManager.registeredActions[actionId] = []; @@ -116,12 +114,10 @@ ActionHelper.registerAction = function({ actionId, node, eventName, preventDefau return actionId; }; -ActionHelper.unregisterAction = function(actionId) { - delete ActionManager.registeredActions[actionId]; -}; +ActionHelper.unregisterAction = (actionId) => delete ActionManager.registeredActions[actionId]; -var MODIFIERS = ['alt', 'shift', 'meta', 'ctrl']; -var POINTER_EVENT_TYPE_REGEX = /^click|mouse|touch/; +const MODIFIERS = ['alt', 'shift', 'meta', 'ctrl']; +const POINTER_EVENT_TYPE_REGEX = /^click|mouse|touch/; function isAllowedEvent(event, allowedKeys) { if (typeof allowedKeys === 'undefined') { @@ -136,7 +132,7 @@ function isAllowedEvent(event, allowedKeys) { return true; } - for (var i = 0; i < MODIFIERS.length; i++) { + for (let i = 0; i < MODIFIERS.length; i++) { if (event[MODIFIERS[i] + 'Key'] && allowedKeys.indexOf(MODIFIERS[i]) === -1) { return false; } diff --git a/packages/ember-htmlbars/lib/keywords/get.js b/packages/ember-htmlbars/lib/keywords/get.js index b3731efb03e..8789398e0ff 100644 --- a/packages/ember-htmlbars/lib/keywords/get.js +++ b/packages/ember-htmlbars/lib/keywords/get.js @@ -20,10 +20,10 @@ function labelFor(source, key) { return `(get ${sourceLabel} ${keyLabel})`; } -let DynamicKeyStream = BasicStream.extend({ +const DynamicKeyStream = BasicStream.extend({ init(source, keySource) { // Used to get the original path for debugging purposes. - var label = labelFor(source, keySource); + let label = labelFor(source, keySource); this.label = label; this.path = label; @@ -41,16 +41,16 @@ let DynamicKeyStream = BasicStream.extend({ }, compute() { - var object = this.sourceDep.getValue(); - var key = this.key(); + let object = this.sourceDep.getValue(); + let key = this.key(); if (object && key) { return get(object, key); } }, setValue(value) { - var object = this.sourceDep.getValue(); - var key = this.key(); + let object = this.sourceDep.getValue(); + let key = this.key(); if (object) { set(object, key, value); } @@ -61,8 +61,8 @@ let DynamicKeyStream = BasicStream.extend({ revalidate(value) { this._super$revalidate(value); - var object = this.sourceDep.getValue(); - var key = this.key(); + let object = this.sourceDep.getValue(); + let key = this.key(); if (object !== this.observedObject || key !== this.observedKey) { this._clearObservedObject(); @@ -83,7 +83,7 @@ let DynamicKeyStream = BasicStream.extend({ } }); -const buildStream = function buildStream(params) { +function buildStream(params) { let [objRef, pathRef] = params; assert('The first argument to {{get}} must be a stream', isStream(objRef)); @@ -92,7 +92,7 @@ const buildStream = function buildStream(params) { let stream = buildDynamicKeyStream(objRef, pathRef); return stream; -}; +} function buildDynamicKeyStream(source, keySource) { if (!isStream(keySource)) { @@ -145,7 +145,7 @@ function buildDynamicKeyStream(source, keySource) { @for Ember.Templates.helpers @since 2.1.0 */ -function getKeyword(morph, env, scope, params, hash, template, inverse, visitor) { +export default function getKeyword(morph, env, scope, params, hash, template, inverse, visitor) { if (morph === null) { return buildStream(params); } else { @@ -165,5 +165,3 @@ function getKeyword(morph, env, scope, params, hash, template, inverse, visitor) return true; } - -export default getKeyword; diff --git a/packages/ember-htmlbars/lib/keywords/input.js b/packages/ember-htmlbars/lib/keywords/input.js index 33b74a252e3..49d87eb95d3 100644 --- a/packages/ember-htmlbars/lib/keywords/input.js +++ b/packages/ember-htmlbars/lib/keywords/input.js @@ -153,8 +153,8 @@ import assign from 'ember-metal/assign'; */ export default { setupState(lastState, env, scope, params, hash) { - var type = env.hooks.getValue(hash.type); - var componentName = componentNameMap[type] || defaultComponentName; + let type = env.hooks.getValue(hash.type); + let componentName = componentNameMap[type] || defaultComponentName; assert( '{{input type=\'checkbox\'}} does not support setting `value=someBooleanValue`; ' + @@ -174,8 +174,8 @@ export default { } }; -var defaultComponentName = '-text-field'; +const defaultComponentName = '-text-field'; -var componentNameMap = { +const componentNameMap = { 'checkbox': '-checkbox' }; diff --git a/packages/ember-htmlbars/lib/keywords/mut.js b/packages/ember-htmlbars/lib/keywords/mut.js index f0358dbd346..2f6ed4f2b32 100644 --- a/packages/ember-htmlbars/lib/keywords/mut.js +++ b/packages/ember-htmlbars/lib/keywords/mut.js @@ -13,7 +13,7 @@ import { INVOKE, ACTION } from 'ember-htmlbars/keywords/closure-action'; export let MUTABLE_REFERENCE = symbol('MUTABLE_REFERENCE'); -let MutStream = ProxyStream.extend({ +const MutStream = ProxyStream.extend({ init(stream) { this.label = `(mut ${stream.label})`; this.path = stream.path; @@ -100,7 +100,7 @@ let MutStream = ProxyStream.extend({ export default function mut(morph, env, scope, originalParams, hash, template, inverse) { // If `morph` is `null` the keyword is being invoked as a subexpression. if (morph === null) { - var valueStream = originalParams[0]; + let valueStream = originalParams[0]; return mutParam(env.hooks.getValue, valueStream); } @@ -110,14 +110,14 @@ export default function mut(morph, env, scope, originalParams, hash, template, i export function privateMut(morph, env, scope, originalParams, hash, template, inverse) { // If `morph` is `null` the keyword is being invoked as a subexpression. if (morph === null) { - var valueStream = originalParams[0]; + let valueStream = originalParams[0]; return mutParam(env.hooks.getValue, valueStream, true); } return true; } -let LiteralStream = BasicStream.extend({ +const LiteralStream = BasicStream.extend({ init(literal) { this.literal = literal; this.label = `(literal ${literal})`; diff --git a/packages/ember-htmlbars/lib/keywords/outlet.js b/packages/ember-htmlbars/lib/keywords/outlet.js index 99c79f63241..cd928829c51 100644 --- a/packages/ember-htmlbars/lib/keywords/outlet.js +++ b/packages/ember-htmlbars/lib/keywords/outlet.js @@ -76,10 +76,10 @@ export default { }, setupState(state, env, scope, params, hash) { - var outletState = env.outletState; - var read = env.hooks.getValue; - var outletName = read(params[0]) || 'main'; - var selectedOutletState = outletState[outletName]; + let outletState = env.outletState; + let read = env.hooks.getValue; + let outletName = read(params[0]) || 'main'; + let selectedOutletState = outletState[outletName]; return { outletState: selectedOutletState, @@ -158,7 +158,7 @@ function isStable(a, b) { } a = a.render; b = b.render; - for (var key in a) { + for (let key in a) { if (a.hasOwnProperty(key)) { // Name is only here for logging & debugging. If two different // names result in otherwise identical states, they're still diff --git a/packages/ember-htmlbars/lib/keywords/partial.js b/packages/ember-htmlbars/lib/keywords/partial.js index 12826856047..ea3e4c18655 100644 --- a/packages/ember-htmlbars/lib/keywords/partial.js +++ b/packages/ember-htmlbars/lib/keywords/partial.js @@ -53,9 +53,9 @@ export default { }, render(renderNode, env, scope, params, hash, template, inverse, visitor) { - var state = renderNode.getState(); + let state = renderNode.getState(); if (!state.partialName) { return true; } - var found = lookupPartial(env, state.partialName); + let found = lookupPartial(env, state.partialName); if (!found) { return true; } internal.hostBlock(renderNode, env, scope, found.raw, null, null, visitor, function(options) { diff --git a/packages/ember-htmlbars/lib/keywords/render.js b/packages/ember-htmlbars/lib/keywords/render.js index f395c7b0974..1f87942ed20 100644 --- a/packages/ember-htmlbars/lib/keywords/render.js +++ b/packages/ember-htmlbars/lib/keywords/render.js @@ -87,7 +87,7 @@ export default { }, setupState(prevState, env, scope, params, hash) { - var name = params[0]; + let name = params[0]; assert( 'The first argument of {{render}} must be quoted, e.g. {{render "sidebar"}}.', @@ -115,13 +115,13 @@ export default { }, render(node, env, scope, params, hash, template, inverse, visitor) { - var state = node.getState(); - var name = params[0]; - var context = params[1]; + let state = node.getState(); + let name = params[0]; + let context = params[1]; - var owner = env.owner; + let owner = env.owner; - var router = owner.lookup('router:main'); + let router = owner.lookup('router:main'); assert( 'The second argument of {{render}} must be a path, e.g. {{render "post" post}}.', @@ -139,7 +139,7 @@ export default { throw new EmberError('You must pass a templateName to render'); } - var templateName = 'template:' + name; + let templateName = 'template:' + name; assert( 'You used `{{render \'' + name + '\'}}`, but \'' + name + '\' can not be ' + 'found as a template.', @@ -151,8 +151,8 @@ export default { } // provide controller override - var controllerName; - var controllerFullName; + let controllerName; + let controllerFullName; if (hash.controller) { controllerName = hash.controller; @@ -170,11 +170,11 @@ export default { } let target = router; - var controller; + let controller; // choose name if (params.length > 1) { - var factory = owner._lookupFactory(controllerFullName) || + let factory = owner._lookupFactory(controllerFullName) || generateControllerFactory(owner, controllerName); controller = factory.create({ @@ -198,12 +198,12 @@ export default { template = template.raw; } - var options = { + let options = { layout: null, self: controller }; - var nodeManager = ViewNodeManager.create(node, env, hash, options, state.parentView, null, null, template); + let nodeManager = ViewNodeManager.create(node, env, hash, options, state.parentView, null, null, template); state.manager = nodeManager; if (router && params.length === 1) { @@ -215,24 +215,24 @@ export default { rerender(node, env, scope, params, hash, template, inverse, visitor) { if (params.length > 1) { - var model = read(params[1]); + let model = read(params[1]); node.getState().controller.set('model', model); } } }; function childOutletState(name, env) { - var topLevel = env.view.ownerView; + let topLevel = env.view.ownerView; if (!topLevel || !topLevel.outletState) { return; } - var outletState = topLevel.outletState; + let outletState = topLevel.outletState; if (!outletState.main) { return; } - var selectedOutletState = outletState.main.outlets['__ember_orphans__']; + let selectedOutletState = outletState.main.outlets['__ember_orphans__']; if (!selectedOutletState) { return; } - var matched = selectedOutletState.outlets[name]; + let matched = selectedOutletState.outlets[name]; if (matched) { - var childState = new EmptyObject(); + let childState = new EmptyObject(); childState[matched.render.outlet] = matched; matched.wasUsed = true; return childState; @@ -246,7 +246,7 @@ function isStable(a, b) { if (!a || !b) { return false; } - for (var outletName in a) { + for (let outletName in a) { if (!isStableOutlet(a[outletName], b[outletName])) { return false; } @@ -263,7 +263,7 @@ function isStableOutlet(a, b) { } a = a.render; b = b.render; - for (var key in a) { + for (let key in a) { if (a.hasOwnProperty(key)) { // name is only here for logging & debugging. If two different // names result in otherwise identical states, they're still diff --git a/packages/ember-htmlbars/lib/keywords/unbound.js b/packages/ember-htmlbars/lib/keywords/unbound.js index 70619eedbc0..d2e41a264f4 100644 --- a/packages/ember-htmlbars/lib/keywords/unbound.js +++ b/packages/ember-htmlbars/lib/keywords/unbound.js @@ -35,7 +35,7 @@ import { read } from '../streams/utils'; @public */ -let VolatileStream = BasicStream.extend({ +const VolatileStream = BasicStream.extend({ init(source) { this.label = `(volatile ${source.label})`; this.source = source; diff --git a/packages/ember-htmlbars/lib/morphs/attr-morph.js b/packages/ember-htmlbars/lib/morphs/attr-morph.js index 5f10d776ca3..848d9deffd1 100644 --- a/packages/ember-htmlbars/lib/morphs/attr-morph.js +++ b/packages/ember-htmlbars/lib/morphs/attr-morph.js @@ -2,7 +2,7 @@ import { warn, debugSeal } from 'ember-metal/debug'; import DOMHelper from 'dom-helper'; import isNone from 'ember-metal/is_none'; -var HTMLBarsAttrMorph = DOMHelper.prototype.AttrMorphClass; +const HTMLBarsAttrMorph = DOMHelper.prototype.AttrMorphClass; export var styleWarning = '' + 'Binding style attributes may introduce cross-site scripting vulnerabilities; ' + diff --git a/packages/ember-htmlbars/lib/morphs/morph.js b/packages/ember-htmlbars/lib/morphs/morph.js index 55ef0227629..7ef666edb62 100644 --- a/packages/ember-htmlbars/lib/morphs/morph.js +++ b/packages/ember-htmlbars/lib/morphs/morph.js @@ -1,10 +1,10 @@ import DOMHelper from 'dom-helper'; import { debugSeal } from 'ember-metal/debug'; -var HTMLBarsMorph = DOMHelper.prototype.MorphClass; +const HTMLBarsMorph = DOMHelper.prototype.MorphClass; let guid = 1; -function EmberMorph(DOMHelper, contextualElement) { +export default function EmberMorph(DOMHelper, contextualElement) { this.HTMLBarsMorph$constructor(DOMHelper, contextualElement); this.emberView = null; @@ -24,7 +24,7 @@ function EmberMorph(DOMHelper, contextualElement) { debugSeal(this); } -var proto = EmberMorph.prototype = Object.create(HTMLBarsMorph.prototype); +let proto = EmberMorph.prototype = Object.create(HTMLBarsMorph.prototype); proto.HTMLBarsMorph$constructor = HTMLBarsMorph; proto.HTMLBarsMorph$clear = HTMLBarsMorph.prototype.clear; @@ -47,7 +47,7 @@ proto.cleanup = function() { let toDestroy = this.emberToDestroy; if (toDestroy) { - for (var i = 0; i < toDestroy.length; i++) { + for (let i = 0; i < toDestroy.length; i++) { toDestroy[i].destroy(); } @@ -58,5 +58,3 @@ proto.cleanup = function() { proto.didRender = function(env, scope) { env.renderedNodes.add(this); }; - -export default EmberMorph; diff --git a/packages/ember-htmlbars/lib/node-managers/component-node-manager.js b/packages/ember-htmlbars/lib/node-managers/component-node-manager.js index 8e43fef3325..feacbf9d3b3 100644 --- a/packages/ember-htmlbars/lib/node-managers/component-node-manager.js +++ b/packages/ember-htmlbars/lib/node-managers/component-node-manager.js @@ -98,7 +98,7 @@ function configureCreateOptions(attrs, createOptions) { } ComponentNodeManager.prototype.render = function ComponentNodeManager_render(_env, visitor) { - var { component } = this; + let { component } = this; return instrument(component, function ComponentNodeManager_render_instrument() { let meta = this.block && this.block.template.meta; @@ -128,12 +128,12 @@ ComponentNodeManager.prototype.render = function ComponentNodeManager_render(_en }; ComponentNodeManager.prototype.rerender = function ComponentNodeManager_rerender(_env, attrs, visitor) { - var component = this.component; + let component = this.component; return instrument(component, function ComponentNodeManager_rerender_instrument() { let env = _env.childWithView(component); - var snapshot = takeSnapshot(attrs); + let snapshot = takeSnapshot(attrs); if (component._renderNode.shouldReceiveAttrs) { if (component._propagateAttrsToThis) { @@ -198,7 +198,7 @@ export function createComponent(_component, props, renderNode, env, attrs = {}) function takeSnapshot(attrs) { let hash = {}; - for (var prop in attrs) { + for (let prop in attrs) { hash[prop] = getCellOrValue(attrs[prop]); } @@ -208,7 +208,7 @@ function takeSnapshot(attrs) { export function takeLegacySnapshot(attrs) { let hash = {}; - for (var prop in attrs) { + for (let prop in attrs) { hash[prop] = getValue(attrs[prop]); } @@ -218,7 +218,7 @@ export function takeLegacySnapshot(attrs) { function snapshotAndUpdateTarget(rawAttrs, target) { let attrs = {}; - for (var prop in rawAttrs) { + for (let prop in rawAttrs) { let value = getCellOrValue(rawAttrs[prop]); attrs[prop] = value; diff --git a/packages/ember-htmlbars/lib/node-managers/view-node-manager.js b/packages/ember-htmlbars/lib/node-managers/view-node-manager.js index bc24907a2c2..f44e894dab6 100644 --- a/packages/ember-htmlbars/lib/node-managers/view-node-manager.js +++ b/packages/ember-htmlbars/lib/node-managers/view-node-manager.js @@ -34,11 +34,11 @@ ViewNodeManager.create = function ViewNodeManager_create(renderNode, env, attrs, } }())); - var component; - var componentInfo = { layout: found.layout }; + let component; + let componentInfo = { layout: found.layout }; if (found.component) { - var options = { parentView: parentView }; + let options = { parentView: parentView }; if (attrs && attrs.id) { options.elementId = getValue(attrs.id); } if (attrs && attrs.tagName) { options.tagName = getValue(attrs.tagName); } @@ -70,7 +70,7 @@ ViewNodeManager.create = function ViewNodeManager_create(renderNode, env, attrs, assert('BUG: ViewNodeManager.create can take a scope or a self, but not both', !(contentScope && found.self)); - var results = buildComponentTemplate(componentInfo, attrs, { + let results = buildComponentTemplate(componentInfo, attrs, { templates: { default: contentTemplate }, scope: contentScope, self: found.self @@ -80,10 +80,10 @@ ViewNodeManager.create = function ViewNodeManager_create(renderNode, env, attrs, }; ViewNodeManager.prototype.render = function ViewNodeManager_render(env, attrs, visitor) { - var component = this.component; + let component = this.component; return instrument(component, function ViewNodeManager_render_instrument() { - var newEnv = env; + let newEnv = env; if (component) { newEnv = env.childWithView(component); } else { @@ -102,7 +102,7 @@ ViewNodeManager.prototype.render = function ViewNodeManager_render(env, attrs, v } if (component) { - var element = this.expectElement && this.renderNode.firstNode; + let element = this.expectElement && this.renderNode.firstNode; // In environments like FastBoot, disable any hooks that would cause the component // to access the DOM directly. @@ -116,14 +116,14 @@ ViewNodeManager.prototype.render = function ViewNodeManager_render(env, attrs, v }; ViewNodeManager.prototype.rerender = function ViewNodeManager_rerender(env, attrs, visitor) { - var component = this.component; + let component = this.component; return instrument(component, function ViewNodeManager_rerender_instrument() { - var newEnv = env; + let newEnv = env; if (component) { newEnv = env.childWithView(component); - var snapshot = takeSnapshot(attrs); + let snapshot = takeSnapshot(attrs); // Notify component that it has become dirty and is about to change. env.renderer.willUpdate(component, snapshot); @@ -226,7 +226,7 @@ export function createOrUpdateComponent(component, options, createOptions, rende function takeSnapshot(attrs) { let hash = {}; - for (var prop in attrs) { + for (let prop in attrs) { hash[prop] = getCellOrValue(attrs[prop]); } @@ -234,7 +234,7 @@ function takeSnapshot(attrs) { } function mergeBindings(target, attrs) { - for (var prop in attrs) { + for (let prop in attrs) { if (!attrs.hasOwnProperty(prop)) { continue; } // when `attrs` is an actual value being set in the // attrs hash (`{{foo-bar attrs="blah"}}`) we cannot diff --git a/packages/ember-htmlbars/lib/renderer.js b/packages/ember-htmlbars/lib/renderer.js index 456d7c3d257..081e505f93e 100755 --- a/packages/ember-htmlbars/lib/renderer.js +++ b/packages/ember-htmlbars/lib/renderer.js @@ -30,12 +30,12 @@ Renderer.prototype.prerenderTopLevelView = view.ownerView = renderNode.emberView = view; view._renderNode = renderNode; - var layout = get(view, 'layout'); - var template = get(view, 'template'); + let layout = get(view, 'layout'); + let template = get(view, 'template'); - var componentInfo = { component: view, layout: layout }; + let componentInfo = { component: view, layout: layout }; - var block = buildComponentTemplate(componentInfo, {}, { + let block = buildComponentTemplate(componentInfo, {}, { self: view, templates: template ? { default: template.raw } : undefined }).block; @@ -71,10 +71,10 @@ Renderer.prototype.revalidateTopLevelView = Renderer.prototype.dispatchLifecycleHooks = function Renderer_dispatchLifecycleHooks(env) { - var ownerView = env.view; + let ownerView = env.view; - var lifecycleHooks = env.lifecycleHooks; - var i, hook; + let lifecycleHooks = env.lifecycleHooks; + let i, hook; for (i = 0; i < lifecycleHooks.length; i++) { hook = lifecycleHooks[i]; @@ -94,7 +94,7 @@ Renderer.prototype.dispatchLifecycleHooks = Renderer.prototype.ensureViewNotRendering = function Renderer_ensureViewNotRendering(view) { - var env = view.ownerView.env; + let env = view.ownerView.env; if (env && env.renderedViews.indexOf(view.elementId) !== -1) { throw new Error('Something you did caused a view to re-render after it rendered but before it was inserted into the DOM.'); } @@ -131,7 +131,7 @@ Renderer.prototype.clearRenderedViews = // This entry point is called from top-level `view.appendTo`. Renderer.prototype.appendTo = function Renderer_appendTo(view, target) { - var morph = this._dom.appendMorph(target); + let morph = this._dom.appendMorph(target); morph.ownerNode = morph; view._willInsert = true; run.schedule('render', this, this.renderTopLevelView, view, morph); @@ -139,7 +139,7 @@ Renderer.prototype.appendTo = Renderer.prototype.replaceIn = function Renderer_replaceIn(view, target) { - var morph = this._dom.replaceContentWithMorph(target); + let morph = this._dom.replaceContentWithMorph(target); morph.ownerNode = morph; view._willInsert = true; run.scheduleOnce('render', this, this.renderTopLevelView, view, morph); @@ -147,7 +147,7 @@ Renderer.prototype.replaceIn = Renderer.prototype.createElement = function Renderer_createElement(view) { - var morph = this._dom.createFragmentMorph(); + let morph = this._dom.createFragmentMorph(); morph.ownerNode = morph; this.prerenderTopLevelView(view, morph); }; @@ -230,7 +230,7 @@ Renderer.prototype.componentWillRender = function (component) { }; Renderer.prototype.rerender = function (view) { - var renderNode = view._renderNode; + let renderNode = view._renderNode; renderNode.isDirty = true; internal.visitChildren(renderNode.childNodes, function(node) { diff --git a/packages/ember-htmlbars/lib/streams/built-in-helper.js b/packages/ember-htmlbars/lib/streams/built-in-helper.js index 10464d9cf41..47172f5f329 100644 --- a/packages/ember-htmlbars/lib/streams/built-in-helper.js +++ b/packages/ember-htmlbars/lib/streams/built-in-helper.js @@ -4,7 +4,7 @@ import { getHashValues } from './utils'; -let BuiltInHelperStream = BasicStream.extend({ +export default BasicStream.extend({ init(helper, params, hash, templates, env, scope, label) { this.helper = helper; this.params = params; @@ -19,5 +19,3 @@ let BuiltInHelperStream = BasicStream.extend({ return this.helper(getArrayValues(this.params), getHashValues(this.hash), this.templates, this.env, this.scope); } }); - -export default BuiltInHelperStream; diff --git a/packages/ember-htmlbars/lib/streams/class_name_binding.js b/packages/ember-htmlbars/lib/streams/class_name_binding.js index a467a7a90bd..7258642097f 100644 --- a/packages/ember-htmlbars/lib/streams/class_name_binding.js +++ b/packages/ember-htmlbars/lib/streams/class_name_binding.js @@ -24,10 +24,10 @@ import { dasherize } from 'ember-runtime/system/string'; @private */ export function parsePropertyPath(path) { - var split = path.split(':'); - var propertyPath = split[0]; - var classNames = ''; - var className, falsyClassName; + let split = path.split(':'); + let propertyPath = split[0]; + let classNames = ''; + let className, falsyClassName; // check if the property is defined as prop:class or prop:trueClass:falseClass if (split.length > 1) { @@ -96,7 +96,7 @@ export function classStringForValue(path, val, className, falsyClassName) { // Normalize property path to be suitable for use // as a class name. For exaple, content.foo.barBaz // becomes bar-baz. - var parts = path.split('.'); + let parts = path.split('.'); return dasherize(parts[parts.length - 1]); // If the value is not false, undefined, or null, return the current @@ -114,7 +114,7 @@ export function classStringForValue(path, val, className, falsyClassName) { export function streamifyClassNameBinding(view, classNameBinding, prefix) { prefix = prefix || ''; assert('classNameBindings must not have spaces in them. Multiple class name bindings can be provided as elements of an array, e.g. [\'foo\', \':bar\']', classNameBinding.indexOf(' ') === -1); - var parsedPath = parsePropertyPath(classNameBinding); + let parsedPath = parsePropertyPath(classNameBinding); if (parsedPath.path === '') { return classStringForValue( parsedPath.path, @@ -123,8 +123,8 @@ export function streamifyClassNameBinding(view, classNameBinding, prefix) { parsedPath.falsyClassName ); } else { - var pathValue = view.getStream(prefix + parsedPath.path); - return chain(pathValue, function() { + let pathValue = view.getStream(prefix + parsedPath.path); + return chain(pathValue, () => { return classStringForValue( parsedPath.path, read(pathValue), diff --git a/packages/ember-htmlbars/lib/streams/dependency.js b/packages/ember-htmlbars/lib/streams/dependency.js index 8f640e01c10..ed74dd9a768 100644 --- a/packages/ember-htmlbars/lib/streams/dependency.js +++ b/packages/ember-htmlbars/lib/streams/dependency.js @@ -17,7 +17,7 @@ import { @namespace Ember.streams @constructor */ -function Dependency(depender, dependee) { +export default function Dependency(depender, dependee) { assert('Dependency error: Depender must be a stream', isStream(depender)); this.next = null; @@ -81,5 +81,3 @@ assign(Dependency.prototype, { // this.unsubscribe(); // } }); - -export default Dependency; diff --git a/packages/ember-htmlbars/lib/streams/helper-factory.js b/packages/ember-htmlbars/lib/streams/helper-factory.js index 99ca7a8303a..99155a44eb6 100644 --- a/packages/ember-htmlbars/lib/streams/helper-factory.js +++ b/packages/ember-htmlbars/lib/streams/helper-factory.js @@ -4,7 +4,7 @@ import { getHashValues } from './utils'; -let HelperFactoryStream = BasicStream.extend({ +export default BasicStream.extend({ init(helperFactory, params, hash, label) { this.helperFactory = helperFactory; this.params = params; @@ -30,5 +30,3 @@ let HelperFactoryStream = BasicStream.extend({ }, super$deactivate: BasicStream.prototype.deactivate }); - -export default HelperFactoryStream; diff --git a/packages/ember-htmlbars/lib/streams/helper-instance.js b/packages/ember-htmlbars/lib/streams/helper-instance.js index 6450877a59b..c9478c35eb9 100644 --- a/packages/ember-htmlbars/lib/streams/helper-instance.js +++ b/packages/ember-htmlbars/lib/streams/helper-instance.js @@ -4,7 +4,7 @@ import { getHashValues } from './utils'; -let HelperInstanceStream = BasicStream.extend({ +export default BasicStream.extend({ init(helper, params, hash, label) { this.helper = helper; this.params = params; @@ -17,5 +17,3 @@ let HelperInstanceStream = BasicStream.extend({ return this.helper.compute(getArrayValues(this.params), getHashValues(this.hash)); } }); - -export default HelperInstanceStream; diff --git a/packages/ember-htmlbars/lib/streams/key-stream.js b/packages/ember-htmlbars/lib/streams/key-stream.js index 5893048decf..e97c2618e39 100644 --- a/packages/ember-htmlbars/lib/streams/key-stream.js +++ b/packages/ember-htmlbars/lib/streams/key-stream.js @@ -18,7 +18,7 @@ export default BasicStream.extend({ assert('KeyStream error: key must be a non-empty string', typeof key === 'string' && key.length > 0); assert('KeyStream error: key must not have a \'.\'', key.indexOf('.') === -1); - var label = labelFor(source, key); + let label = labelFor(source, key); this.path = label; this.observedObject = null; @@ -43,7 +43,7 @@ export default BasicStream.extend({ }, setValue(value) { - var object = this.sourceDep.getValue(); + let object = this.sourceDep.getValue(); if (object) { set(object, this.key, value); } @@ -59,7 +59,7 @@ export default BasicStream.extend({ revalidate(value) { this._super$revalidate(value); - var object = this.sourceDep.getValue(); + let object = this.sourceDep.getValue(); if (object !== this.observedObject) { this._clearObservedObject(); diff --git a/packages/ember-htmlbars/lib/streams/should_display.js b/packages/ember-htmlbars/lib/streams/should_display.js index 3dde638adfb..6823f4cf98d 100644 --- a/packages/ember-htmlbars/lib/streams/should_display.js +++ b/packages/ember-htmlbars/lib/streams/should_display.js @@ -4,11 +4,11 @@ import { isArray } from 'ember-runtime/utils'; import BasicStream from './stream'; import { read, isStream } from './utils'; -let ShouldDisplayStream = BasicStream.extend({ +const ShouldDisplayStream = BasicStream.extend({ init(predicate) { assert('ShouldDisplayStream error: predicate must be a stream', isStream(predicate)); - var isTruthy = predicate.get('isTruthy'); + let isTruthy = predicate.get('isTruthy'); this.init(); this.predicate = predicate; @@ -20,7 +20,7 @@ let ShouldDisplayStream = BasicStream.extend({ }, compute() { - var truthy = read(this.isTruthy); + let truthy = read(this.isTruthy); if (typeof truthy === 'boolean') { return truthy; @@ -52,12 +52,12 @@ export default function shouldDisplay(predicate) { return new ShouldDisplayStream(predicate); } - var type = typeof predicate; + let type = typeof predicate; if (type === 'boolean') { return predicate; } if (type && type === 'object' && predicate !== null) { - var isTruthy = get(predicate, 'isTruthy'); + let isTruthy = get(predicate, 'isTruthy'); if (typeof isTruthy === 'boolean') { return isTruthy; } diff --git a/packages/ember-htmlbars/lib/streams/stream.js b/packages/ember-htmlbars/lib/streams/stream.js index e47192605dd..35510bba5c9 100644 --- a/packages/ember-htmlbars/lib/streams/stream.js +++ b/packages/ember-htmlbars/lib/streams/stream.js @@ -22,12 +22,13 @@ export const IS_STREAM = symbol('IS_STREAM'); @namespace Ember.stream @constructor */ -function BasicStream(label) { +export default function BasicStream(label) { this._init(label); } -var KeyStream; -var ProxyMixin; +// lazy +let KeyStream; +let ProxyMixin; BasicStream.prototype = { _init(label) { @@ -61,7 +62,7 @@ BasicStream.prototype = { this.children = new EmptyObject(); } - var keyStream = this.children[key]; + let keyStream = this.children[key]; if (keyStream === undefined) { keyStream = this._makeChildStream(key); @@ -72,14 +73,14 @@ BasicStream.prototype = { }, get(path) { - var firstKey = getFirstKey(path); - var tailPath = getTailPath(path); + let firstKey = getFirstKey(path); + let tailPath = getTailPath(path); if (this.children === undefined) { this.children = new EmptyObject(); } - var keyStream = this.children[firstKey]; + let keyStream = this.children[firstKey]; if (keyStream === undefined) { keyStream = this._makeChildStream(firstKey, path); @@ -105,7 +106,7 @@ BasicStream.prototype = { this.isDirty = true; } - var willRevalidate = false; + let willRevalidate = false; if (!this.isActive && this.subscriberHead) { this.activate(); @@ -129,7 +130,7 @@ BasicStream.prototype = { }, addMutableDependency(object) { - var dependency = new Dependency(this, object); + let dependency = new Dependency(this, object); if (this.isActive) { dependency.subscribe(); @@ -138,7 +139,7 @@ BasicStream.prototype = { if (this.dependencyHead === null) { this.dependencyHead = this.dependencyTail = dependency; } else { - var tail = this.dependencyTail; + let tail = this.dependencyTail; tail.next = dependency; dependency.prev = tail; this.dependencyTail = dependency; @@ -154,18 +155,18 @@ BasicStream.prototype = { }, subscribeDependencies() { - var dependency = this.dependencyHead; + let dependency = this.dependencyHead; while (dependency) { - var next = dependency.next; + let next = dependency.next; dependency.subscribe(); dependency = next; } }, unsubscribeDependencies() { - var dependency = this.dependencyHead; + let dependency = this.dependencyHead; while (dependency) { - var next = dependency.next; + let next = dependency.next; dependency.unsubscribe(); dependency = next; } @@ -230,17 +231,17 @@ BasicStream.prototype = { subscribe(callback, context) { assert('You tried to subscribe to a stream but the callback provided was not a function.', typeof callback === 'function'); - var subscriber = new Subscriber(callback, context, this); + let subscriber = new Subscriber(callback, context, this); if (this.subscriberHead === null) { this.subscriberHead = this.subscriberTail = subscriber; } else { - var tail = this.subscriberTail; + let tail = this.subscriberTail; tail.next = subscriber; subscriber.prev = tail; this.subscriberTail = subscriber; } - var stream = this; + let stream = this; return function(prune) { subscriber.removeFrom(stream); if (prune) { stream.prune(); } @@ -254,10 +255,10 @@ BasicStream.prototype = { }, unsubscribe(callback, context) { - var subscriber = this.subscriberHead; + let subscriber = this.subscriberHead; while (subscriber) { - var next = subscriber.next; + let next = subscriber.next; if (subscriber.callback === callback && subscriber.context === context) { subscriber.removeFrom(this); } @@ -266,13 +267,13 @@ BasicStream.prototype = { }, notifySubscribers(callbackToSkip, contextToSkip) { - var subscriber = this.subscriberHead; + let subscriber = this.subscriberHead; while (subscriber) { - var next = subscriber.next; + let next = subscriber.next; - var callback = subscriber.callback; - var context = subscriber.context; + let callback = subscriber.callback; + let context = subscriber.context; subscriber = next; @@ -295,10 +296,10 @@ BasicStream.prototype = { this.subscriberHead = this.subscriberTail = null; this.maybeDeactivate(); - var dependencies = this.dependencies; + let dependencies = this.dependencies; if (dependencies) { - for (var i = 0; i < dependencies.length; i++) { + for (let i = 0; i < dependencies.length; i++) { dependencies[i](prune); } } @@ -323,7 +324,7 @@ BasicStream.extend = function(object) { return Child; }; -var Stream = BasicStream.extend({ +export const Stream = BasicStream.extend({ init(fn, label) { this._compute = fn; this.label = label; @@ -349,6 +350,3 @@ function makeLabel(label) { return label; } } - -export default BasicStream; -export { Stream }; diff --git a/packages/ember-htmlbars/lib/streams/subscriber.js b/packages/ember-htmlbars/lib/streams/subscriber.js index c2cad3f99d4..1cf444fd732 100644 --- a/packages/ember-htmlbars/lib/streams/subscriber.js +++ b/packages/ember-htmlbars/lib/streams/subscriber.js @@ -10,7 +10,7 @@ import assign from 'ember-metal/assign'; @namespace Ember.streams @constructor */ -function Subscriber(callback, context) { +export default function Subscriber(callback, context) { this.next = null; this.prev = null; this.callback = callback; @@ -19,8 +19,8 @@ function Subscriber(callback, context) { assign(Subscriber.prototype, { removeFrom(stream) { - var next = this.next; - var prev = this.prev; + let next = this.next; + let prev = this.prev; if (prev) { prev.next = next; @@ -37,5 +37,3 @@ assign(Subscriber.prototype, { stream.maybeDeactivate(); } }); - -export default Subscriber; diff --git a/packages/ember-htmlbars/lib/streams/utils.js b/packages/ember-htmlbars/lib/streams/utils.js index fae77354243..211b0625b24 100644 --- a/packages/ember-htmlbars/lib/streams/utils.js +++ b/packages/ember-htmlbars/lib/streams/utils.js @@ -105,8 +105,8 @@ export function read(object) { and replaced with the stream's current value. */ export function readArray(array) { - var ret = new Array(array.length); - for (var i = 0; i < array.length; i++) { + let ret = new Array(array.length); + for (let i = 0; i < array.length; i++) { ret[i] = read(array[i]); } return ret; @@ -126,8 +126,8 @@ export function readArray(array) { values in the case of stream objects. */ export function readHash(object) { - var ret = {}; - for (var key in object) { + let ret = {}; + for (let key in object) { ret[key] = read(object[key]); } return ret; @@ -144,9 +144,9 @@ export function readHash(object) { otherwise. */ export function scanArray(array) { - var containsStream = false; + let containsStream = false; - for (var i = 0; i < array.length; i++) { + for (let i = 0; i < array.length; i++) { if (isStream(array[i])) { containsStream = true; break; @@ -167,9 +167,9 @@ export function scanArray(array) { otherwise. */ export function scanHash(hash) { - var containsStream = false; + let containsStream = false; - for (var prop in hash) { + for (let prop in hash) { if (isStream(hash[prop])) { containsStream = true; break; @@ -179,7 +179,7 @@ export function scanHash(hash) { return containsStream; } -let ConcatStream = BasicStream.extend({ +const ConcatStream = BasicStream.extend({ init(array, separator) { this.array = array; this.separator = separator; @@ -215,7 +215,7 @@ let ConcatStream = BasicStream.extend({ export function concat(array, separator) { // TODO: Create subclass ConcatStream < Stream. Defer // subscribing to streams until the value() is called. - var hasStream = scanArray(array); + let hasStream = scanArray(array); if (hasStream) { let stream = new ConcatStream(array, separator); @@ -230,10 +230,10 @@ export function concat(array, separator) { } export function labelsFor(streams) { - var labels = []; + let labels = []; - for (var i = 0; i < streams.length; i++) { - var stream = streams[i]; + for (let i = 0; i < streams.length; i++) { + let stream = streams[i]; labels.push(labelFor(stream)); } @@ -241,9 +241,9 @@ export function labelsFor(streams) { } export function labelsForObject(streams) { - var labels = []; + let labels = []; - for (var prop in streams) { + for (let prop in streams) { labels.push(`${prop}: ${inspect(streams[prop])}`); } @@ -252,7 +252,7 @@ export function labelsForObject(streams) { export function labelFor(maybeStream) { if (isStream(maybeStream)) { - var stream = maybeStream; + let stream = maybeStream; return typeof stream.label === 'function' ? stream.label() : stream.label; } else { return inspect(maybeStream); @@ -269,7 +269,7 @@ function inspect(value) { } export function or(first, second) { - var stream = new Stream(function() { + let stream = new Stream(function() { return first.value() || second.value(); }, function() { return `${labelFor(first)} || ${labelFor(second)}`; @@ -291,14 +291,12 @@ export function addDependency(stream, dependency) { export function zip(streams, callback, label) { assert('Must call zip with a label', !!label); - var stream = new Stream(function() { - var array = readArray(streams); + let stream = new Stream(() => { + let array = readArray(streams); return callback ? callback(array) : array; - }, function() { - return `${label}(${labelsFor(streams)})`; - }); + }, () => `${label}(${labelsFor(streams)})`); - for (var i = 0; i < streams.length; i++) { + for (let i = 0; i < streams.length; i++) { stream.addDependency(streams[i]); } @@ -308,14 +306,12 @@ export function zip(streams, callback, label) { export function zipHash(object, callback, label) { assert('Must call zipHash with a label', !!label); - var stream = new Stream(function() { - var hash = readHash(object); + let stream = new Stream(() => { + let hash = readHash(object); return callback ? callback(hash) : hash; - }, function() { - return `${label}(${labelsForObject(object)})`; - }); + }, () => `${label}(${labelsForObject(object)})` ); - for (var prop in object) { + for (let prop in object) { stream.addDependency(object[prop]); } @@ -331,10 +327,10 @@ export function zipHash(object, callback, label) { to `chain()` via scope. For example: ```javascript - var source = ...; // stream returning a number + let source = ...; // stream returning a number // or a numeric (non-stream) object - var result = chain(source, function() { - var currentValue = read(source); + let result = chain(source, function() { + let currentValue = read(source); return currentValue + 1; }); ``` @@ -357,7 +353,7 @@ export function zipHash(object, callback, label) { export function chain(value, fn, label) { assert('Must call chain with a label', !!label); if (isStream(value)) { - var stream = new Stream(fn, function() { return `${label}(${labelFor(value)})`; }); + let stream = new Stream(fn, () => `${label}(${labelFor(value)})`); stream.addDependency(value); return stream; } else { @@ -372,8 +368,8 @@ export function setValue(object, value) { } export function readViewFactory(object, owner) { - var value = read(object); - var viewClass; + let value = read(object); + let viewClass; if (typeof value === 'string') { assert('View requires an owner to resolve views not passed in through the context', !!owner); @@ -382,7 +378,7 @@ export function readViewFactory(object, owner) { viewClass = value; } - assert(`${value} must be a subclass or an instance of Ember.View, not ${viewClass}`, (function(viewClass) { + assert(`${value} must be a subclass or an instance of Ember.View, not ${viewClass}`, (viewClass => { return viewClass && (viewClass.isViewFactory || viewClass.isView || viewClass.isComponentFactory || viewClass.isComponent); })(viewClass)); @@ -391,7 +387,7 @@ export function readViewFactory(object, owner) { export function readUnwrappedModel(object) { if (isStream(object)) { - var result = object.value(); + let result = object.value(); // If the path is exactly `controller` then we don't unwrap it. if (object.label !== 'controller') { diff --git a/packages/ember-htmlbars/lib/system/append-templated-view.js b/packages/ember-htmlbars/lib/system/append-templated-view.js index a558af86e29..fc7c0847f6b 100644 --- a/packages/ember-htmlbars/lib/system/append-templated-view.js +++ b/packages/ember-htmlbars/lib/system/append-templated-view.js @@ -7,7 +7,7 @@ import { get } from 'ember-metal/property_get'; import View from 'ember-views/views/view'; export default function appendTemplatedView(parentView, morph, viewClassOrInstance, props) { - var viewProto; + let viewProto; if (View.detectInstance(viewClassOrInstance)) { viewProto = viewClassOrInstance; } else { @@ -16,7 +16,7 @@ export default function appendTemplatedView(parentView, morph, viewClassOrInstan // We only want to override the `_context` computed property if there is // no specified controller. See View#_context for more information. - var noControllerInProto = !viewProto.controller; + let noControllerInProto = !viewProto.controller; if (viewProto.controller && viewProto.controller.isDescriptor) { noControllerInProto = true; } if (noControllerInProto && !viewProto.controllerBinding && diff --git a/packages/ember-htmlbars/lib/system/build-component-template.js b/packages/ember-htmlbars/lib/system/build-component-template.js index ae172a9a198..16f4120df70 100644 --- a/packages/ember-htmlbars/lib/system/build-component-template.js +++ b/packages/ember-htmlbars/lib/system/build-component-template.js @@ -26,8 +26,8 @@ export default function buildComponentTemplate({ component, tagName, layout, out // element. We use `manualElement` to create a template that represents // the wrapping element and yields to the previous block. if (tagName !== '') { - var attributes = normalizeComponentAttributes(component, attrs); - var elementTemplate = internal.manualElement(tagName, attributes); + let attributes = normalizeComponentAttributes(component, attrs); + let elementTemplate = internal.manualElement(tagName, attributes); elementTemplate.meta = meta; blockToRender = createElementBlock(elementTemplate, blockToRender, component); @@ -85,10 +85,10 @@ function createContentBlocks(templates, scope, self, component) { if (!templates) { return; } - var output = {}; - for (var name in templates) { + let output = {}; + for (let name in templates) { if (templates.hasOwnProperty(name)) { - var template = templates[name]; + let template = templates[name]; if (template) { output[name] = createContentBlock(templates[name], scope, self, component); } @@ -122,7 +122,6 @@ function createElementBlock(template, yieldTo, component) { function tagNameFor(view) { let tagName = view.tagName; - if (tagName === null || tagName === undefined) { tagName = view._defaultTagName || 'div'; } @@ -152,7 +151,7 @@ function normalizeComponentAttributes(component, attrs) { let attrName, expression; if (colonIndex !== -1) { - var attrProperty = attr.substring(0, colonIndex); + let attrProperty = attr.substring(0, colonIndex); attrName = attr.substring(colonIndex + 1); expression = ['get', `${streamBasePath}${attrProperty}`]; } else if (attrs[attr]) { @@ -182,8 +181,8 @@ function normalizeComponentAttributes(component, attrs) { } if (get(component, 'isVisible') === false) { - var hiddenStyle = ['subexpr', '-html-safe', ['display: none;'], []]; - var existingStyle = normalized.style; + let hiddenStyle = ['subexpr', '-html-safe', ['display: none;'], []]; + let existingStyle = normalized.style; if (existingStyle) { normalized.style = ['subexpr', 'concat', [existingStyle, ' ', hiddenStyle], [ ]]; @@ -196,10 +195,9 @@ function normalizeComponentAttributes(component, attrs) { } function normalizeClass(component, attrs, streamBasePath) { - var i; - var normalizedClass = []; - var classNames = get(component, 'classNames'); - var classNameBindings = get(component, 'classNameBindings'); + let normalizedClass = []; + let classNames = get(component, 'classNames'); + let classNameBindings = get(component, 'classNameBindings'); if (attrs.class) { if (isStream(attrs.class)) { @@ -214,7 +212,7 @@ function normalizeClass(component, attrs, streamBasePath) { } if (classNames) { - for (i = 0; i < classNames.length; i++) { + for (let i = 0; i < classNames.length; i++) { normalizedClass.push(classNames[i]); } } @@ -229,13 +227,11 @@ function normalizeClass(component, attrs, streamBasePath) { } function normalizeClasses(classes, output, streamBasePath) { - var i; - - for (i = 0; i < classes.length; i++) { - var className = classes[i]; + for (let i = 0; i < classes.length; i++) { + let className = classes[i]; assert('classNameBindings must not have spaces in them. Multiple class name bindings can be provided as elements of an array, e.g. [\'foo\', \':bar\']', className.indexOf(' ') === -1); - var [propName, activeClass, inactiveClass] = className.split(':'); + let [propName, activeClass, inactiveClass] = className.split(':'); // Legacy :class microsyntax for static class names if (propName === '') { @@ -243,7 +239,7 @@ function normalizeClasses(classes, output, streamBasePath) { continue; } - var prop = `${streamBasePath}${propName}`; + let prop = `${streamBasePath}${propName}`; output.push(['subexpr', '-normalize-class', [ // params @@ -259,7 +255,7 @@ function normalizeClasses(classes, output, streamBasePath) { function validateTaglessComponent(component) { assert('You cannot use `classNameBindings` on a tag-less component: ' + component.toString(), () => { - var classNameBindings = component.classNameBindings; + let classNameBindings = component.classNameBindings; return !classNameBindings || classNameBindings.length === 0; }()); } diff --git a/packages/ember-htmlbars/lib/system/dom-helper.js b/packages/ember-htmlbars/lib/system/dom-helper.js index 2cd139286ed..3821100ff61 100644 --- a/packages/ember-htmlbars/lib/system/dom-helper.js +++ b/packages/ember-htmlbars/lib/system/dom-helper.js @@ -2,12 +2,10 @@ import DOMHelper from 'dom-helper'; import EmberMorph from 'ember-htmlbars/morphs/morph'; import EmberAttrMorph from 'ember-htmlbars/morphs/attr-morph'; -function EmberDOMHelper(_document) { +export default function EmberDOMHelper(_document) { DOMHelper.call(this, _document); } -var proto = EmberDOMHelper.prototype = Object.create(DOMHelper.prototype); +const proto = EmberDOMHelper.prototype = Object.create(DOMHelper.prototype); proto.MorphClass = EmberMorph; proto.AttrMorphClass = EmberAttrMorph; - -export default EmberDOMHelper; diff --git a/packages/ember-htmlbars/lib/system/instrumentation-support.js b/packages/ember-htmlbars/lib/system/instrumentation-support.js index 61064def088..f8d59b66ce6 100644 --- a/packages/ember-htmlbars/lib/system/instrumentation-support.js +++ b/packages/ember-htmlbars/lib/system/instrumentation-support.js @@ -16,7 +16,7 @@ import { @private */ export function instrument(component, callback, context) { - var instrumentName, val, details, end; + let instrumentName, val, details, end; // Only instrument if there's at least one subscriber. if (subscribers.length) { if (component) { diff --git a/packages/ember-htmlbars/lib/system/lookup-helper.js b/packages/ember-htmlbars/lib/system/lookup-helper.js index ce6ca949011..d1729d5a2f8 100644 --- a/packages/ember-htmlbars/lib/system/lookup-helper.js +++ b/packages/ember-htmlbars/lib/system/lookup-helper.js @@ -6,13 +6,8 @@ import { assert } from 'ember-metal/debug'; import Cache from 'ember-metal/cache'; -export var CONTAINS_DASH_CACHE = new Cache(1000, function(key) { - return key.indexOf('-') !== -1; -}); - -export var CONTAINS_DOT_CACHE = new Cache(1000, function(key) { - return key.indexOf('.') !== -1; -}); +export let CONTAINS_DASH_CACHE = new Cache(1000, key => key.indexOf('-') !== -1); +export let CONTAINS_DOT_CACHE = new Cache(1000, key => key.indexOf('.') !== -1); export function validateLazyHelperName(helperName, container, keywords) { return container && !(helperName in keywords); @@ -33,15 +28,15 @@ export function validateLazyHelperName(helperName, container, keywords) { @return {Helper} */ function _findHelper(name, view, env, options) { - var helper = env.helpers[name]; + let helper = env.helpers[name]; if (!helper) { let owner = env.owner; if (validateLazyHelperName(name, owner, env.hooks.keywords)) { - var helperName = 'helper:' + name; + let helperName = 'helper:' + name; // See https://github.com/emberjs/ember.js/issues/13071 // See https://bugs.chromium.org/p/v8/issues/detail?id=4839 - var registered = owner.hasRegistration(helperName, options); + let registered = owner.hasRegistration(helperName, options); if (registered) { helper = owner._lookupFactory(helperName, options); assert(`Expected to find an Ember.Helper with the name ${helperName}, but found an object of type ${typeof helper} instead.`, helper.isHelperFactory || helper.isHelperInstance); diff --git a/packages/ember-htmlbars/lib/system/render-view.js b/packages/ember-htmlbars/lib/system/render-view.js index 2d0bd22869e..69c524f8c55 100644 --- a/packages/ember-htmlbars/lib/system/render-view.js +++ b/packages/ember-htmlbars/lib/system/render-view.js @@ -5,11 +5,11 @@ import RenderEnv from 'ember-htmlbars/system/render-env'; // HTMLBars propagates the existing env and renders templates for a given render node. export function renderHTMLBarsBlock(view, block, renderNode) { let meta = block && block.template && block.template.meta; - var env = RenderEnv.build(view, meta); + let env = RenderEnv.build(view, meta); view.env = env; createOrUpdateComponent(view, {}, null, renderNode, env); - var nodeManager = new ViewNodeManager(view, null, renderNode, block, view.tagName !== ''); + let nodeManager = new ViewNodeManager(view, null, renderNode, block, view.tagName !== ''); nodeManager.render(env, {}); } diff --git a/packages/ember-htmlbars/lib/utils/decode-each-key.js b/packages/ember-htmlbars/lib/utils/decode-each-key.js index d2caa00d2d0..b73f9de40ad 100644 --- a/packages/ember-htmlbars/lib/utils/decode-each-key.js +++ b/packages/ember-htmlbars/lib/utils/decode-each-key.js @@ -14,7 +14,7 @@ function identity(item) { return key; } export default function decodeEachKey(item, keyPath, index) { - var key; + let key; switch (keyPath) { case '@index': diff --git a/packages/ember-htmlbars/lib/utils/new-stream.js b/packages/ember-htmlbars/lib/utils/new-stream.js index e2720a5740b..577b68ebbf2 100644 --- a/packages/ember-htmlbars/lib/utils/new-stream.js +++ b/packages/ember-htmlbars/lib/utils/new-stream.js @@ -2,7 +2,7 @@ import ProxyStream from '../streams/proxy-stream'; import subscribe from 'ember-htmlbars/utils/subscribe'; export default function newStream(scope, key, newValue, renderNode, isSelf) { - var stream = new ProxyStream(newValue, isSelf ? '' : key); + let stream = new ProxyStream(newValue, isSelf ? '' : key); if (renderNode) { subscribe(renderNode, scope, stream); } scope[key] = stream; } diff --git a/packages/ember-htmlbars/lib/utils/subscribe.js b/packages/ember-htmlbars/lib/utils/subscribe.js index 669b8554e9d..12f1636f99a 100644 --- a/packages/ember-htmlbars/lib/utils/subscribe.js +++ b/packages/ember-htmlbars/lib/utils/subscribe.js @@ -2,10 +2,10 @@ import { isStream, labelFor } from '../streams/utils'; export default function subscribe(node, env, scope, stream) { if (!isStream(stream)) { return; } - var component = scope.getComponent(); - var unsubscribers = node.streamUnsubscribers = node.streamUnsubscribers || []; + let component = scope.getComponent(); + let unsubscribers = node.streamUnsubscribers = node.streamUnsubscribers || []; - unsubscribers.push(stream.subscribe(function() { + unsubscribers.push(stream.subscribe(() => { node.isDirty = true; // Whenever a render node directly inside a component becomes diff --git a/packages/ember-htmlbars/lib/utils/update-scope.js b/packages/ember-htmlbars/lib/utils/update-scope.js index eaf374c80bf..112c3c1ef03 100644 --- a/packages/ember-htmlbars/lib/utils/update-scope.js +++ b/packages/ember-htmlbars/lib/utils/update-scope.js @@ -2,12 +2,12 @@ import ProxyStream from '../streams/proxy-stream'; import subscribe from 'ember-htmlbars/utils/subscribe'; export default function updateScope(scope, key, newValue, renderNode, isSelf) { - var existing = scope[key]; + let existing = scope[key]; if (existing) { existing.setSource(newValue); } else { - var stream = new ProxyStream(newValue, isSelf ? null : key); + let stream = new ProxyStream(newValue, isSelf ? null : key); if (renderNode) { subscribe(renderNode, scope, stream); } scope[key] = stream; } diff --git a/packages/ember-htmlbars/lib/views/outlet.js b/packages/ember-htmlbars/lib/views/outlet.js index 8a2c813bf42..13976163b5d 100644 --- a/packages/ember-htmlbars/lib/views/outlet.js +++ b/packages/ember-htmlbars/lib/views/outlet.js @@ -7,7 +7,7 @@ import View from 'ember-views/views/view'; import topLevelViewTemplate from 'ember-htmlbars/templates/top-level-view'; import TemplateSupport from 'ember-views/mixins/template_support'; -export var CoreOutletView = View.extend(TemplateSupport, { +export let CoreOutletView = View.extend(TemplateSupport, { defaultTemplate: topLevelViewTemplate, init() { @@ -32,10 +32,10 @@ export var CoreOutletView = View.extend(TemplateSupport, { dirtyOutlets() { // Dirty any render nodes that correspond to outlets - for (var i = 0; i < this._outlets.length; i++) { + for (let i = 0; i < this._outlets.length; i++) { this._outlets[i].isDirty = true; } } }); -export var OutletView = CoreOutletView.extend({ tagName: '' }); +export let OutletView = CoreOutletView.extend({ tagName: '' }); diff --git a/packages/ember-htmlbars/tests/helpers/-html-safe-test.js b/packages/ember-htmlbars/tests/helpers/-html-safe-test.js index e47733d7073..01d9f3e6995 100644 --- a/packages/ember-htmlbars/tests/helpers/-html-safe-test.js +++ b/packages/ember-htmlbars/tests/helpers/-html-safe-test.js @@ -7,7 +7,7 @@ import { compile } from '../utils/helpers'; import { runAppend, runDestroy } from 'ember-runtime/tests/utils'; -var component, registry, container, warnings, originalWarn; +let component, registry, container, warnings, originalWarn; QUnit.module('ember-htmlbars: {{-html-safe}} helper', { setup() { @@ -17,7 +17,7 @@ QUnit.module('ember-htmlbars: {{-html-safe}} helper', { warnings = []; originalWarn = getDebugFunction('warn'); - setDebugFunction('warn', function(message, test) { + setDebugFunction('warn', (message, test) => { if (!test) { warnings.push(message); } diff --git a/packages/ember-htmlbars/tests/helpers/link-to_test.js b/packages/ember-htmlbars/tests/helpers/link-to_test.js index 3d62bcbb56c..9fe6f0e075f 100644 --- a/packages/ember-htmlbars/tests/helpers/link-to_test.js +++ b/packages/ember-htmlbars/tests/helpers/link-to_test.js @@ -9,7 +9,7 @@ import LinkComponent from 'ember-htmlbars/components/link-to'; import buildOwner from 'container/tests/test-helpers/build-owner'; import { OWNER } from 'container/owner'; -var owner, component; +let owner, component; QUnit.module('ember-htmlbars: link-to helper', { setup() { @@ -40,7 +40,7 @@ QUnit.module('ember-htmlbars: link-to helper', { }); QUnit.test('should be able to be inserted in DOM when the router is not present', function() { - var template = '{{#link-to \'index\'}}Go to Index{{/link-to}}'; + let template = '{{#link-to \'index\'}}Go to Index{{/link-to}}'; component = Component.create({ [OWNER]: owner, layout: compile(template) @@ -52,7 +52,7 @@ QUnit.test('should be able to be inserted in DOM when the router is not present' }); QUnit.test('re-renders when title changes', function() { - var template = '{{link-to title routeName}}'; + let template = '{{link-to title routeName}}'; component = Component.create({ [OWNER]: owner, @@ -65,15 +65,13 @@ QUnit.test('re-renders when title changes', function() { equal(component.$().text(), 'foo'); - run(function() { - set(component, 'title', 'bar'); - }); + run(() => set(component, 'title', 'bar')); equal(component.$().text(), 'bar'); }); QUnit.test('can read bound title', function() { - var template = '{{link-to title routeName}}'; + let template = '{{link-to title routeName}}'; component = Component.create({ [OWNER]: owner, title: 'foo', @@ -123,7 +121,7 @@ QUnit.test('unescaped inline form (triple curlies) does not escape link title', }); QUnit.test('unwraps controllers', function() { - var template = '{{#link-to \'index\' otherController}}Text{{/link-to}}'; + let template = '{{#link-to \'index\' otherController}}Text{{/link-to}}'; component = Component.create({ [OWNER]: owner, @@ -133,7 +131,7 @@ QUnit.test('unwraps controllers', function() { layout: compile(template) }); - expectDeprecation(function() { + expectDeprecation(() => { runAppend(component); }, /Providing `{{link-to}}` with a param that is wrapped in a controller is deprecated./); diff --git a/packages/ember-htmlbars/tests/helpers/outlet_test.js b/packages/ember-htmlbars/tests/helpers/outlet_test.js index d6db8748daa..fad45850095 100644 --- a/packages/ember-htmlbars/tests/helpers/outlet_test.js +++ b/packages/ember-htmlbars/tests/helpers/outlet_test.js @@ -6,14 +6,14 @@ import { compile } from '../utils/helpers'; import { runAppend, runDestroy } from 'ember-runtime/tests/utils'; import { buildAppInstance } from 'ember-htmlbars/tests/utils'; -var trim = jQuery.trim; +let { trim } = jQuery; -var appInstance, top; +let appInstance, top; QUnit.module('ember-htmlbars: {{outlet}} helper', { setup() { appInstance = buildAppInstance(); - var CoreOutlet = appInstance._lookupFactory('view:core-outlet'); + let CoreOutlet = appInstance._lookupFactory('view:core-outlet'); top = CoreOutlet.create(); }, @@ -25,7 +25,7 @@ QUnit.module('ember-htmlbars: {{outlet}} helper', { }); QUnit.test('view should render the outlet when set after dom insertion', function() { - var routerState = withTemplate('

HI

{{outlet}}'); + let routerState = withTemplate('

HI

{{outlet}}'); top.setOutletState(routerState); runAppend(top); @@ -33,9 +33,7 @@ QUnit.test('view should render the outlet when set after dom insertion', functio routerState.outlets.main = withTemplate('

BYE

'); - run(function() { - top.setOutletState(routerState); - }); + run(() => top.setOutletState(routerState)); // Replace whitespace for older IE equal(trim(top.$().text()), 'HIBYE'); @@ -45,7 +43,7 @@ QUnit.test('a top-level outlet should always be a view', function() { appInstance.register('view:toplevel', EmberView.extend({ elementId: 'top-level' })); - var routerState = withTemplate('

HI

{{outlet}}'); + let routerState = withTemplate('

HI

{{outlet}}'); top.setOutletState(routerState); routerState.outlets.main = withTemplate('

BYE

'); runAppend(top); @@ -55,7 +53,7 @@ QUnit.test('a top-level outlet should always be a view', function() { }); QUnit.test('view should render the outlet when set before dom insertion', function() { - var routerState = withTemplate('

HI

{{outlet}}'); + let routerState = withTemplate('

HI

{{outlet}}'); routerState.outlets.main = withTemplate('

BYE

'); top.setOutletState(routerState); runAppend(top); @@ -66,7 +64,7 @@ QUnit.test('view should render the outlet when set before dom insertion', functi QUnit.test('outlet should support an optional name', function() { - var routerState = withTemplate('

HI

{{outlet \'mainView\'}}'); + let routerState = withTemplate('

HI

{{outlet \'mainView\'}}'); top.setOutletState(routerState); runAppend(top); @@ -74,36 +72,30 @@ QUnit.test('outlet should support an optional name', function() { routerState.outlets.mainView = withTemplate('

BYE

'); - run(function() { - top.setOutletState(routerState); - }); + run(() => top.setOutletState(routerState)); // Replace whitespace for older IE equal(trim(top.$().text()), 'HIBYE'); }); QUnit.test('Outlets bind to the current view, not the current concrete view', function() { - var routerState = withTemplate('

HI

{{outlet}}'); + let routerState = withTemplate('

HI

{{outlet}}'); top.setOutletState(routerState); runAppend(top); routerState.outlets.main = withTemplate('

MIDDLE

{{outlet}}'); - run(function() { - top.setOutletState(routerState); - }); + run(() => top.setOutletState(routerState)); routerState.outlets.main.outlets.main = withTemplate('

BOTTOM

'); - run(function() { - top.setOutletState(routerState); - }); + run(() => top.setOutletState(routerState)); - var output = jQuery('#qunit-fixture h1 ~ h2 ~ h3').text(); + let output = jQuery('#qunit-fixture h1 ~ h2 ~ h3').text(); equal(output, 'BOTTOM', 'all templates were rendered'); }); QUnit.test('Outlets bind to the current template\'s view, not inner contexts [DEPRECATED]', function() { - var parentTemplate = '

HI

{{#if view.alwaysTrue}}{{outlet}}{{/if}}'; - var bottomTemplate = '

BOTTOM

'; + let parentTemplate = '

HI

{{#if view.alwaysTrue}}{{outlet}}{{/if}}'; + let bottomTemplate = '

BOTTOM

'; - var routerState = { + let routerState = { render: { ViewClass: EmberView.extend({ alwaysTrue: true, @@ -119,11 +111,11 @@ QUnit.test('Outlets bind to the current template\'s view, not inner contexts [DE routerState.outlets.main = withTemplate(bottomTemplate); - run(function() { + run(() => { top.setOutletState(routerState); }); - var output = jQuery('#qunit-fixture h1 ~ h3').text(); + let output = jQuery('#qunit-fixture h1 ~ h3').text(); equal(output, 'BOTTOM', 'all templates were rendered'); }); @@ -140,7 +132,7 @@ QUnit.test('should not throw deprecations if {{outlet}} is used with a quoted na }); QUnit.test('{{outlet}} should work with an unquoted name', function() { - var routerState = { + let routerState = { render: { controller: Controller.create({ outletName: 'magical' @@ -159,7 +151,7 @@ QUnit.test('{{outlet}} should work with an unquoted name', function() { }); QUnit.test('{{outlet}} should rerender when bound name changes', function() { - var routerState = { + let routerState = { render: { controller: Controller.create({ outletName: 'magical' @@ -175,16 +167,14 @@ QUnit.test('{{outlet}} should rerender when bound name changes', function() { top.setOutletState(routerState); runAppend(top); equal(top.$().text().trim(), 'It\'s magic'); - run(function() { - routerState.render.controller.set('outletName', 'second'); - }); + run(() => routerState.render.controller.set('outletName', 'second')); equal(top.$().text().trim(), 'second'); }); QUnit.test('views created by {{outlet}} should get destroyed', function() { let inserted = 0; let destroyed = 0; - var routerState = { + let routerState = { render: { ViewClass: EmberView.extend({ didInsertElement() { @@ -200,9 +190,7 @@ QUnit.test('views created by {{outlet}} should get destroyed', function() { top.setOutletState(routerState); runAppend(top); equal(inserted, 1, 'expected to see view inserted'); - run(function() { - top.setOutletState(withTemplate('hello world')); - }); + run(() => top.setOutletState(withTemplate('hello world'))); equal(destroyed, 1, 'expected to see view destroyed'); }); diff --git a/packages/ember-htmlbars/tests/helpers/render_test.js b/packages/ember-htmlbars/tests/helpers/render_test.js index 019e952314a..462038dceb3 100644 --- a/packages/ember-htmlbars/tests/helpers/render_test.js +++ b/packages/ember-htmlbars/tests/helpers/render_test.js @@ -10,12 +10,10 @@ import { OWNER } from 'container/owner'; import { setTemplates, set as setTemplate } from 'ember-templates/template_registry'; function runSet(object, key, value) { - run(function() { - set(object, key, value); - }); + run(() => set(object, key, value)); } -var view, appInstance; +let view, appInstance; QUnit.module('ember-htmlbars: {{render}} helper', { setup() { @@ -30,8 +28,8 @@ QUnit.module('ember-htmlbars: {{render}} helper', { }); QUnit.test('{{render}} helper should render given template', function() { - var template = '

HI

{{render \'home\'}}'; - var controller = EmberController.extend(); + let template = '

HI

{{render \'home\'}}'; + let controller = EmberController.extend(); view = EmberView.create({ [OWNER]: appInstance, @@ -50,8 +48,8 @@ QUnit.test('{{render}} helper should render given template', function() { }); QUnit.test('{{render}} helper should render nested helpers', function() { - var template = '

HI

{{render \'foo\'}}'; - var controller = EmberController.extend(); + let template = '

HI

{{render \'foo\'}}'; + let controller = EmberController.extend(); view = EmberView.create({ [OWNER]: appInstance, @@ -69,8 +67,8 @@ QUnit.test('{{render}} helper should render nested helpers', function() { }); QUnit.test('{{render}} helper should have assertion if neither template nor view exists', function() { - var template = '

HI

{{render \'oops\'}}'; - var controller = EmberController.extend(); + let template = '

HI

{{render \'oops\'}}'; + let controller = EmberController.extend(); view = EmberView.create({ [OWNER]: appInstance, @@ -78,15 +76,15 @@ QUnit.test('{{render}} helper should have assertion if neither template nor view template: compile(template) }); - expectAssertion(function() { + expectAssertion(() => { runAppend(view); }, 'You used `{{render \'oops\'}}`, but \'oops\' can not be found as a template.'); }); QUnit.test('{{render}} helper should render given template with a supplied model', function() { - var template = '

HI

{{render \'post\' post}}'; - var component; - var post = { + let template = '

HI

{{render \'post\' post}}'; + let component; + let post = { title: 'Rails is omakase' }; @@ -98,8 +96,8 @@ QUnit.test('{{render}} helper should render given template with a supplied model }); }, /Please refactor [\w\{\}"` ]+ to a component/); - var postController; - var PostController = EmberController.extend({ + let postController; + let PostController = EmberController.extend({ init() { this._super(...arguments); postController = this; @@ -121,8 +119,8 @@ QUnit.test('{{render}} helper should render given template with a supplied model }); QUnit.test('{{render}} helper with a supplied model should not fire observers on the controller', function () { - var template = '

HI

{{render \'post\' post}}'; - var post = { + let template = '

HI

{{render \'post\' post}}'; + let post = { title: 'Rails is omakase' }; let controller = EmberController.create({ @@ -138,17 +136,15 @@ QUnit.test('{{render}} helper with a supplied model should not fire observers on }); }, /Please refactor [\w\{\}"` ]+ to a component/); - var PostController = EmberController.extend({ - modelDidChange: observer('model', function() { - modelDidChange++; - }) + let PostController = EmberController.extend({ + modelDidChange: observer('model', () => modelDidChange++) }); appInstance.register('controller:post', PostController); setTemplate('post', compile('

{{title}}

')); - var modelDidChange = 0; + let modelDidChange = 0; runAppend(view); equal(modelDidChange, 0, 'model observer did not fire'); }); @@ -170,19 +166,19 @@ QUnit.test('{{render}} helper should raise an error when a given controller name setTemplate('home', compile('

BYE

')); - expectAssertion(function() { + expectAssertion(() => { runAppend(view); }, 'The controller name you supplied \'postss\' did not resolve to a controller.'); }); QUnit.test('{{render}} helper should render with given controller', function() { - var template = '{{render "home" controller="posts"}}'; - var Controller = EmberController.extend(); + let template = '{{render "home" controller="posts"}}'; + let Controller = EmberController.extend(); let model = {}; let controller = Controller.create({ [OWNER]: appInstance }); - var id = 0; + let id = 0; appInstance.register('controller:posts', EmberController.extend({ init() { @@ -217,7 +213,7 @@ QUnit.test('{{render}} helper should rerender with given controller', function() let controller = Controller.create({ [OWNER]: appInstance }); - var id = 0; + let id = 0; appInstance.register('controller:posts', EmberController.extend({ init() { @@ -250,8 +246,8 @@ QUnit.test('{{render}} helper should rerender with given controller', function() }); QUnit.test('{{render}} helper should render a template without a model only once', function() { - var template = '

HI

{{render \'home\'}}
{{render \'home\'}}'; - var Controller = EmberController.extend(); + let template = '

HI

{{render \'home\'}}
{{render \'home\'}}'; + let Controller = EmberController.extend(); let controller = Controller.create({ [OWNER]: appInstance }); @@ -264,7 +260,7 @@ QUnit.test('{{render}} helper should render a template without a model only once setTemplate('home', compile('

BYE

')); - expectAssertion(function() { + expectAssertion(() => { runAppend(view); }, /\{\{render\}\} helper once/i); }); @@ -316,16 +312,16 @@ QUnit.test('{{render}} helper should render templates with models multiple times }); QUnit.test('{{render}} helper should not leak controllers', function() { - var template = '

HI

{{render \'post\' post1}}'; - var post1 = { + let template = '

HI

{{render \'post\' post1}}'; + let post1 = { title: 'Me first' }; - var Controller = EmberController.extend({ + let Controller = EmberController.extend({ post1: post1 }); - var controller = Controller.create({ + let controller = Controller.create({ [OWNER]: appInstance }); @@ -337,8 +333,8 @@ QUnit.test('{{render}} helper should not leak controllers', function() { }); }, /Please refactor [\w\{\}"` ]+ to a component/); - var postController; - var PostController = EmberController.extend({ + let postController; + let PostController = EmberController.extend({ init() { this._super(...arguments); postController = this; @@ -367,8 +363,8 @@ QUnit.test('{{render}} helper should not treat invocations with falsy contexts a }); }, /Please refactor [\w\{\}"` ]+ to a component/); - var postController1, postController2; - var PostController = EmberController.extend({ + let postController1, postController2; + let PostController = EmberController.extend({ init() { this._super(...arguments); if (!postController1) { @@ -444,14 +440,14 @@ QUnit.test('{{render}} helper should be able to render a template again when it setTemplate('home', compile('

BYE

')); - var liveRoutes = { + let liveRoutes = { render: { template: compile('

HI

{{outlet}}') }, outlets: {} }; - run(function() { + run(() => { liveRoutes.outlets.main = { render: { controller, @@ -464,7 +460,7 @@ QUnit.test('{{render}} helper should be able to render a template again when it equal(view.$().text(), 'HI1BYE'); - run(function() { + run(() => { liveRoutes.outlets.main = { render: { controller, @@ -478,16 +474,16 @@ QUnit.test('{{render}} helper should be able to render a template again when it }); QUnit.test('{{render}} works with dot notation', function() { - var template = '{{render "blog.post"}}'; + let template = '{{render "blog.post"}}'; - var ContextController = EmberController.extend(); - var contextController = ContextController.create({ + let ContextController = EmberController.extend(); + let contextController = ContextController.create({ [OWNER]: appInstance }); - var controller; - var id = 0; - var BlogPostController = EmberController.extend({ + let controller; + let id = 0; + let BlogPostController = EmberController.extend({ init() { this._super(...arguments); controller = this; @@ -506,14 +502,14 @@ QUnit.test('{{render}} works with dot notation', function() { runAppend(view); - var singletonController = appInstance.lookup('controller:blog.post'); + let singletonController = appInstance.lookup('controller:blog.post'); equal(singletonController.uniqueId, view.$().html(), 'rendered with correct singleton controller'); }); QUnit.test('throws an assertion if {{render}} is called with an unquoted template name', function() { - var template = '

HI

{{render home}}'; - var Controller = EmberController.extend(); - var controller = Controller.create({ + let template = '

HI

{{render home}}'; + let Controller = EmberController.extend(); + let controller = Controller.create({ [OWNER]: appInstance }); @@ -524,15 +520,15 @@ QUnit.test('throws an assertion if {{render}} is called with an unquoted templat setTemplate('home', compile('

BYE

')); - expectAssertion(function() { + expectAssertion(() => { runAppend(view); }, 'The first argument of {{render}} must be quoted, e.g. {{render "sidebar"}}.'); }); QUnit.test('throws an assertion if {{render}} is called with a literal for a model', function() { - var template = '

HI

{{render "home" "model"}}'; - var Controller = EmberController.extend(); - var controller = Controller.create({ + let template = '

HI

{{render "home" "model"}}'; + let Controller = EmberController.extend(); + let controller = Controller.create({ [OWNER]: appInstance }); @@ -544,15 +540,15 @@ QUnit.test('throws an assertion if {{render}} is called with a literal for a mod setTemplate('home', compile('

BYE

')); - expectAssertion(function() { + expectAssertion(() => { runAppend(view); }, 'The second argument of {{render}} must be a path, e.g. {{render "post" post}}.'); }); QUnit.test('{{render}} helper should not require view to provide its own template', function() { - var template = '{{render \'fish\'}}'; - var Controller = EmberController.extend(); - var controller = Controller.create({ + let template = '{{render \'fish\'}}'; + let Controller = EmberController.extend(); + let controller = Controller.create({ [OWNER]: appInstance }); diff --git a/packages/ember-htmlbars/tests/htmlbars_test.js b/packages/ember-htmlbars/tests/htmlbars_test.js index ffa54f95421..441629084aa 100644 --- a/packages/ember-htmlbars/tests/htmlbars_test.js +++ b/packages/ember-htmlbars/tests/htmlbars_test.js @@ -7,11 +7,11 @@ import assign from 'ember-metal/assign'; QUnit.module('ember-htmlbars: main'); QUnit.test('HTMLBars is present and can be executed', function() { - var template = compile('ohai'); + let template = compile('ohai'); - var env = assign({ dom: domHelper }, defaultEnv); + let env = assign({ dom: domHelper }, defaultEnv); - var output = template.render({}, env, { contextualElement: document.body }).fragment; + let output = template.render({}, env, { contextualElement: document.body }).fragment; equalHTML(output, 'ohai'); }); diff --git a/packages/ember-htmlbars/tests/integration/component_invocation_test.js b/packages/ember-htmlbars/tests/integration/component_invocation_test.js index 467eb2fdb47..30d12985788 100644 --- a/packages/ember-htmlbars/tests/integration/component_invocation_test.js +++ b/packages/ember-htmlbars/tests/integration/component_invocation_test.js @@ -5,7 +5,7 @@ import { runAppend, runDestroy } from 'ember-runtime/tests/utils'; import buildOwner from 'container/tests/test-helpers/build-owner'; import { OWNER } from 'container/owner'; -var owner, component; +let owner, component; function commonSetup() { owner = buildOwner(); @@ -33,13 +33,13 @@ QUnit.module('component - invocation', { QUnit.test('moduleName is available on _renderNode when a layout is present', function() { expect(1); - var layoutModuleName = 'my-app-name/templates/components/sample-component'; - var sampleComponentLayout = compile('Sample Component - {{yield}}', { + let layoutModuleName = 'my-app-name/templates/components/sample-component'; + let sampleComponentLayout = compile('Sample Component - {{yield}}', { moduleName: layoutModuleName }); owner.register('template:components/sample-component', sampleComponentLayout); owner.register('component:sample-component', Component.extend({ - didInsertElement: function() { + didInsertElement() { equal(this._renderNode.lastResult.template.meta.moduleName, layoutModuleName); } })); @@ -55,9 +55,9 @@ QUnit.test('moduleName is available on _renderNode when a layout is present', fu QUnit.test('moduleName is available on _renderNode when no layout is present', function() { expect(1); - var templateModuleName = 'my-app-name/templates/application'; + let templateModuleName = 'my-app-name/templates/application'; owner.register('component:sample-component', Component.extend({ - didInsertElement: function() { + didInsertElement() { equal(this._renderNode.lastResult.template.meta.moduleName, templateModuleName); } })); diff --git a/packages/ember-htmlbars/tests/integration/component_lifecycle_test.js b/packages/ember-htmlbars/tests/integration/component_lifecycle_test.js index 0cf019ba14b..d589c734fb9 100644 --- a/packages/ember-htmlbars/tests/integration/component_lifecycle_test.js +++ b/packages/ember-htmlbars/tests/integration/component_lifecycle_test.js @@ -7,8 +7,8 @@ import EmberView from 'ember-views/views/view'; import buildOwner from 'container/tests/test-helpers/build-owner'; import { OWNER } from 'container/owner'; -var owner, view; -var hooks; +let owner, view; +let hooks; let styles = [{ name: 'curly', @@ -69,7 +69,7 @@ styles.forEach(style => { } QUnit.test('lifecycle hooks are invoked in a predictable order', function() { - var components = {}; + let components = {}; function component(label) { return style.class.extend({ @@ -150,9 +150,7 @@ styles.forEach(style => { hooks = []; - run(function() { - components.bottom.rerender(); - }); + run(() => components.bottom.rerender()); deepEqual(hooks, [ hook('bottom', 'willUpdate'), hook('bottom', 'willRender'), @@ -161,9 +159,7 @@ styles.forEach(style => { hooks = []; - run(function() { - components.middle.rerender(); - }); + run(() => components.middle.rerender()); bottomAttrs = { oldAttrs: { website: 'tomdale.net' }, newAttrs: { website: 'tomdale.net' } }; @@ -181,9 +177,7 @@ styles.forEach(style => { hooks = []; - run(function() { - components.top.rerender(); - }); + run(() => components.top.rerender()); middleAttrs = { oldAttrs: { name: 'Tom Dale' }, newAttrs: { name: 'Tom Dale' } }; @@ -203,9 +197,7 @@ styles.forEach(style => { hooks = []; - run(function() { - view.set('twitter', '@hipstertomdale'); - }); + run(() => view.set('twitter', '@hipstertomdale')); // Because the `twitter` attr is only used by the topmost component, // and not passed down, we do not expect to see lifecycle hooks @@ -223,7 +215,7 @@ styles.forEach(style => { }); QUnit.test('passing values through attrs causes lifecycle hooks to fire if the attribute values have changed', function() { - var components = {}; + let components = {}; function component(label) { return style.class.extend({ @@ -304,9 +296,7 @@ styles.forEach(style => { hooks = []; - run(function() { - view.set('twitter', '@hipstertomdale'); - }); + run(() => view.set('twitter', '@hipstertomdale')); // Because the `twitter` attr is used by the all of the components, // the lifecycle hooks are invoked for all components. @@ -334,9 +324,7 @@ styles.forEach(style => { // In this case, because the attrs are passed down, all child components are invoked. - run(function() { - view.rerender(); - }); + run(() => view.rerender()); topAttrs = { oldAttrs: { twitter: '@hipstertomdale' }, newAttrs: { twitter: '@hipstertomdale' } }; middleAttrs = { oldAttrs: { twitterTop: '@hipstertomdale' }, newAttrs: { twitterTop: '@hipstertomdale' } }; @@ -377,9 +365,7 @@ styles.forEach(style => { assert.strictEqual(component.$().text(), '@tomdale'); - run(() => { - component.destroy(); - }); + run(() => component.destroy()); }); QUnit.test('DEPRECATED: didInitAttrs is deprecated', function(assert) { @@ -399,9 +385,7 @@ styles.forEach(style => { component = componentClass.create(); }, /\[DEPRECATED\] didInitAttrs called in <\(subclass of Ember.Component\)\:ember[\d+]+>\./); - run(() => { - component.destroy(); - }); + run(() => component.destroy()); }); QUnit.test('properties set during `init` are availabe in `didReceiveAttrs`', function(assert) { diff --git a/packages/ember-htmlbars/tests/streams/concat_test.js b/packages/ember-htmlbars/tests/streams/concat_test.js index e184b2603b5..6acfc84df34 100644 --- a/packages/ember-htmlbars/tests/streams/concat_test.js +++ b/packages/ember-htmlbars/tests/streams/concat_test.js @@ -24,9 +24,7 @@ QUnit.test('returns string if no streams were in the array', function(assert) { }); QUnit.test('returns a stream if a stream is in the array', function(assert) { - let stream = new Stream(function() { - return 'bar'; - }); + let stream = new Stream(() => 'bar'); let result = concat(['foo', stream, 'baz'], ' '); assert.ok(isStream(result), 'a stream is returned'); @@ -35,9 +33,7 @@ QUnit.test('returns a stream if a stream is in the array', function(assert) { QUnit.test('returns updated value upon input dirtied', function(assert) { let value = 'bar'; - let stream = new Stream(function() { - return value; - }); + let stream = new Stream(() => value); let result = concat(['foo', stream, 'baz'], ' '); result.activate(); @@ -50,9 +46,7 @@ QUnit.test('returns updated value upon input dirtied', function(assert) { }); QUnit.test('removes dependencies when unsubscribeDependencies is called', function(assert) { - let stream = new Stream(function() { - return 'bar'; - }); + let stream = new Stream(() => 'bar'); let result = concat(['foo', stream, 'baz'], ' '); result.activate(); diff --git a/packages/ember-htmlbars/tests/streams/key-stream-test.js b/packages/ember-htmlbars/tests/streams/key-stream-test.js index 9242908d238..5498f048bab 100644 --- a/packages/ember-htmlbars/tests/streams/key-stream-test.js +++ b/packages/ember-htmlbars/tests/streams/key-stream-test.js @@ -3,7 +3,7 @@ import { Stream } from 'ember-htmlbars/streams/stream'; import KeyStream from 'ember-htmlbars/streams/key-stream'; import { set } from 'ember-metal/property_set'; -var source, object, count; +let source, object, count; function incrementCount() { count++; @@ -14,9 +14,7 @@ QUnit.module('KeyStream', { count = 0; object = { name: 'mmun' }; - source = new Stream(function() { - return object; - }); + source = new Stream(() => object); }, teardown() { count = undefined; @@ -26,17 +24,17 @@ QUnit.module('KeyStream', { }); QUnit.test('can be instantiated manually', function() { - var nameStream = new KeyStream(source, 'name'); + let nameStream = new KeyStream(source, 'name'); equal(nameStream.value(), 'mmun', 'Stream value is correct'); }); QUnit.test('can be instantiated via `Stream.prototype.get`', function() { - var nameStream = source.get('name'); + let nameStream = source.get('name'); equal(nameStream.value(), 'mmun', 'Stream value is correct'); }); QUnit.test('is notified when the observed object\'s property is mutated', function() { - var nameStream = source.get('name'); + let nameStream = source.get('name'); nameStream.subscribe(incrementCount); equal(count, 0, 'Subscribers called correct number of times'); @@ -49,7 +47,7 @@ QUnit.test('is notified when the observed object\'s property is mutated', functi }); QUnit.test('is notified when the source stream\'s value changes to a new object', function() { - var nameStream = source.get('name'); + let nameStream = source.get('name'); nameStream.subscribe(incrementCount); equal(count, 0, 'Subscribers called correct number of times'); @@ -68,7 +66,7 @@ QUnit.test('is notified when the source stream\'s value changes to a new object' }); QUnit.test('is notified when the source stream\'s value changes to the same object', function() { - var nameStream = source.get('name'); + let nameStream = source.get('name'); nameStream.subscribe(incrementCount); equal(count, 0, 'Subscribers called correct number of times'); @@ -86,16 +84,14 @@ QUnit.test('is notified when the source stream\'s value changes to the same obje }); QUnit.test('is notified when setSource is called with a new stream whose value is a new object', function() { - var nameStream = source.get('name'); + let nameStream = source.get('name'); nameStream.subscribe(incrementCount); equal(count, 0, 'Subscribers called correct number of times'); equal(nameStream.value(), 'mmun', 'Stream value is correct'); object = { name: 'wycats' }; - nameStream.setSource(new Stream(function() { - return object; - })); + nameStream.setSource(new Stream(() => object)); equal(count, 1, 'Subscribers called correct number of times'); equal(nameStream.value(), 'wycats', 'Stream value is correct'); @@ -107,15 +103,13 @@ QUnit.test('is notified when setSource is called with a new stream whose value i }); QUnit.test('is notified when setSource is called with a new stream whose value is the same object', function() { - var nameStream = source.get('name'); + let nameStream = source.get('name'); nameStream.subscribe(incrementCount); equal(count, 0, 'Subscribers called correct number of times'); equal(nameStream.value(), 'mmun', 'Stream value is correct'); - nameStream.setSource(new Stream(function() { - return object; - })); + nameStream.setSource(new Stream(() => object)); equal(count, 1, 'Subscribers called correct number of times'); equal(nameStream.value(), 'mmun', 'Stream value is correct'); @@ -127,7 +121,7 @@ QUnit.test('is notified when setSource is called with a new stream whose value i }); QUnit.test('adds and removes key observers on activation and deactivation', function() { - var nameStream = source.get('name'); + let nameStream = source.get('name'); ok(!isWatching(object, 'name'), 'Key is not observered immediately after creation'); @@ -135,7 +129,7 @@ QUnit.test('adds and removes key observers on activation and deactivation', func ok(!isWatching(object, 'name'), 'Key is not observered after calling value with no subscribers'); - var firstCallback = function() {}; + let firstCallback = function() {}; nameStream.subscribe(firstCallback); ok(!isWatching(object, 'name'), 'Key is not observered immediately after first subscription'); @@ -144,7 +138,7 @@ QUnit.test('adds and removes key observers on activation and deactivation', func ok(isWatching(object, 'name'), 'Key is observered after activation'); - var secondCallback = function() {}; + let secondCallback = function() {}; nameStream.subscribe(secondCallback); ok(isWatching(object, 'name'), 'Key is still observered after second subscription is added'); @@ -159,8 +153,8 @@ QUnit.test('adds and removes key observers on activation and deactivation', func }); QUnit.test('removes key observers on destruction', function() { - var nameStream = source.get('name'); - nameStream.subscribe(function() {}); + let nameStream = source.get('name'); + nameStream.subscribe(() => {}); nameStream.value(); ok(isWatching(object, 'name'), '(Precondition) Key is observered after activation'); @@ -171,13 +165,13 @@ QUnit.test('removes key observers on destruction', function() { }); QUnit.test('manages key observers correctly when the object changes', function() { - var nameStream = source.get('name'); - nameStream.subscribe(function() {}); + let nameStream = source.get('name'); + nameStream.subscribe(() => {}); nameStream.value(); ok(isWatching(object, 'name'), '(Precondition) Key is observered after activation'); - var prevObject = object; + let prevObject = object; object = { name: 'wycats' }; source.notify(); diff --git a/packages/ember-htmlbars/tests/streams/proxy-stream-test.js b/packages/ember-htmlbars/tests/streams/proxy-stream-test.js index 0a3e0f022fd..7730b3f88c6 100644 --- a/packages/ember-htmlbars/tests/streams/proxy-stream-test.js +++ b/packages/ember-htmlbars/tests/streams/proxy-stream-test.js @@ -1,7 +1,7 @@ import BasicStream from 'ember-htmlbars/streams/stream'; import ProxyStream from 'ember-htmlbars/streams/proxy-stream'; -var source; +let source; QUnit.module('ProxyStream', { setup() { @@ -28,7 +28,7 @@ QUnit.module('ProxyStream', { }); QUnit.test('supports a stream argument', function() { - var stream = new ProxyStream(source); + let stream = new ProxyStream(source); equal(stream.value(), 'zlurp'); stream.setValue('blorg'); @@ -36,7 +36,7 @@ QUnit.test('supports a stream argument', function() { }); QUnit.test('supports a non-stream argument', function() { - var stream = new ProxyStream('zlurp'); + let stream = new ProxyStream('zlurp'); equal(stream.value(), 'zlurp'); stream.setValue('blorg'); diff --git a/packages/ember-htmlbars/tests/streams/should-display-test.js b/packages/ember-htmlbars/tests/streams/should-display-test.js index 715d3887c69..873fc4bc003 100644 --- a/packages/ember-htmlbars/tests/streams/should-display-test.js +++ b/packages/ember-htmlbars/tests/streams/should-display-test.js @@ -37,19 +37,19 @@ QUnit.test('predicate permutations', function() { falseFunction.isTruthy = true; equal(shouldDisplay(trueFunction), true, 'shouldDisplay(function.isTruthy = true)'); - var truthyObj = { }; + let truthyObj = { }; defineProperty(truthyObj, 'isTruthy', computed(() => true)); equal(shouldDisplay(truthyObj), true, 'shouldDisplay(obj.get("isTruthy") === true)'); - var falseyObj = { }; + let falseyObj = { }; defineProperty(falseyObj, 'isTruthy', computed(() => false)); equal(shouldDisplay(falseyObj), false, 'shouldDisplay(obj.get("isFalsey") === false)'); - var falsyArray = [1]; + let falsyArray = [1]; falsyArray.isTruthy = false; equal(shouldDisplay(falsyArray), false, '[1].isTruthy = false'); - var falseyCPArray = [1]; + let falseyCPArray = [1]; defineProperty(falseyCPArray, 'isTruthy', computed(() => false)); equal(shouldDisplay(falseyCPArray), false, 'shouldDisplay([1].get("isFalsey") === true'); }); diff --git a/packages/ember-htmlbars/tests/streams/stream-test.js b/packages/ember-htmlbars/tests/streams/stream-test.js index c164b56a1fd..141689d9ffe 100644 --- a/packages/ember-htmlbars/tests/streams/stream-test.js +++ b/packages/ember-htmlbars/tests/streams/stream-test.js @@ -2,7 +2,7 @@ import { Stream } from 'ember-htmlbars/streams/stream'; import ObjectProxy from 'ember-runtime/system/object_proxy'; import { get } from 'ember-metal/property_get'; -var stream, value, count; +let stream, value, count; function incrementCount() { count++; @@ -13,9 +13,7 @@ QUnit.module('Stream - Proxy compatibility', { count = 0; value = 'zlurp'; - stream = new Stream(function() { - return value; - }); + stream = new Stream(() => value); }, teardown() { value = undefined; diff --git a/packages/ember-htmlbars/tests/system/lookup-helper_test.js b/packages/ember-htmlbars/tests/system/lookup-helper_test.js index ed7bce4ac89..e8dbfcc06a3 100644 --- a/packages/ember-htmlbars/tests/system/lookup-helper_test.js +++ b/packages/ember-htmlbars/tests/system/lookup-helper_test.js @@ -24,27 +24,27 @@ function generateOwner() { QUnit.module('ember-htmlbars: lookupHelper hook'); QUnit.test('looks for helpers in the provided `env.helpers`', function() { - var env = generateEnv({ + let env = generateEnv({ 'flubarb'() { } }); - var actual = lookupHelper('flubarb', null, env); + let actual = lookupHelper('flubarb', null, env); equal(actual, env.helpers.flubarb, 'helpers are looked up on env'); }); QUnit.test('returns undefined if no container exists (and helper is not found in env)', function() { - var env = generateEnv(); - var view = {}; + let env = generateEnv(); + let view = {}; - var actual = findHelper('flubarb', view, env); + let actual = findHelper('flubarb', view, env); equal(actual, undefined, 'does not blow up if view does not have a container'); }); QUnit.test('does not lookup in the container if the name does not contain a dash (and helper is not found in env)', function() { - var env = generateEnv(); - var view = { + let env = generateEnv(); + let view = { container: { lookup() { ok(false, 'should not lookup in the container'); @@ -52,38 +52,38 @@ QUnit.test('does not lookup in the container if the name does not contain a dash } }; - var actual = findHelper('flubarb', view, env); + let actual = findHelper('flubarb', view, env); equal(actual, undefined, 'does not blow up if view does not have a container'); }); QUnit.test('does a lookup in the container if the name contains a dash (and helper is not found in env)', function() { let owner = generateOwner(); - var env = generateEnv(null, owner); - var view = { + let env = generateEnv(null, owner); + let view = { [OWNER]: owner }; - var someName = Helper.extend(); + let someName = Helper.extend(); owner.register('helper:some-name', someName); - var actual = lookupHelper('some-name', view, env); + let actual = lookupHelper('some-name', view, env); ok(someName.detect(actual), 'helper is an instance of the helper class'); }); QUnit.test('does a lookup in the container if the name is found in knownHelpers', function() { let owner = generateOwner(); - var env = generateEnv(null, owner); - var view = { + let env = generateEnv(null, owner); + let view = { [OWNER]: owner }; env.knownHelpers['t'] = true; - var t = Helper.extend(); + let t = Helper.extend(); owner.register('helper:t', t); - var actual = lookupHelper('t', view, env); + let actual = lookupHelper('t', view, env); ok(t.detect(actual), 'helper is an instance of the helper class'); }); @@ -91,18 +91,18 @@ QUnit.test('does a lookup in the container if the name is found in knownHelpers' QUnit.test('looks up a shorthand helper in the container', function() { expect(2); let owner = generateOwner(); - var env = generateEnv(null, owner); - var view = { + let env = generateEnv(null, owner); + let view = { [OWNER]: owner }; - var called; + let called; function someName() { called = true; } owner.register('helper:some-name', makeHelper(someName)); - var actual = lookupHelper('some-name', view, env); + let actual = lookupHelper('some-name', view, env); ok(actual.isHelperInstance, 'is a helper'); @@ -114,16 +114,16 @@ QUnit.test('looks up a shorthand helper in the container', function() { QUnit.test('fails with a useful error when resolving a function', function() { expect(1); let owner = generateOwner(); - var env = generateEnv(null, owner); - var view = { + let env = generateEnv(null, owner); + let view = { [OWNER]: owner }; function someName() {} owner.register('helper:some-name', someName); - var actual; - expectAssertion(function() { + let actual; + expectAssertion(() => { actual = lookupHelper('some-name', view, env); }, 'Expected to find an Ember.Helper with the name helper:some-name, but found an object of type function instead.'); }); diff --git a/packages/ember-htmlbars/tests/utils.js b/packages/ember-htmlbars/tests/utils.js index f31bbb08b4e..8067b0e8d4e 100644 --- a/packages/ember-htmlbars/tests/utils.js +++ b/packages/ember-htmlbars/tests/utils.js @@ -65,19 +65,19 @@ function buildAppInstance() { function resolverFor(namespace) { return { resolve(fullName) { - var nameParts = fullName.split(':'); - var type = nameParts[0]; - var name = nameParts[1]; + let nameParts = fullName.split(':'); + let type = nameParts[0]; + let name = nameParts[1]; if (type === 'template') { - var templateName = decamelize(name); + let templateName = decamelize(name); if (hasTemplate(templateName)) { return getTemplate(templateName); } } - var className = classify(name) + classify(type); - var factory = get(namespace, className); + let className = classify(name) + classify(type); + let factory = get(namespace, className); if (factory) { return factory; } } diff --git a/packages/ember-htmlbars/tests/utils/string_test.js b/packages/ember-htmlbars/tests/utils/string_test.js index f9a9287e650..4aa0f0e533f 100644 --- a/packages/ember-htmlbars/tests/utils/string_test.js +++ b/packages/ember-htmlbars/tests/utils/string_test.js @@ -4,20 +4,20 @@ import { htmlSafe } from 'ember-htmlbars/utils/string'; QUnit.module('ember-htmlbars: SafeString'); QUnit.test('htmlSafe should return an instance of SafeString', function() { - var safeString = htmlSafe('you need to be more bold'); + let safeString = htmlSafe('you need to be more bold'); ok(safeString instanceof SafeString, 'should be a SafeString'); }); QUnit.test('htmlSafe should return an empty string for null', function() { - var safeString = htmlSafe(null); + let safeString = htmlSafe(null); equal(safeString instanceof SafeString, true, 'should be a SafeString'); equal(safeString.toString(), '', 'should return an empty string'); }); QUnit.test('htmlSafe should return an empty string for undefined', function() { - var safeString = htmlSafe(); + let safeString = htmlSafe(); equal(safeString instanceof SafeString, true, 'should be a SafeString'); equal(safeString.toString(), '', 'should return an empty string'); diff --git a/packages/ember-metal/lib/alias.js b/packages/ember-metal/lib/alias.js index 0923b5463d2..508875670f7 100644 --- a/packages/ember-metal/lib/alias.js +++ b/packages/ember-metal/lib/alias.js @@ -44,14 +44,14 @@ AliasedProperty.prototype.didUnwatch = function(obj, keyName) { AliasedProperty.prototype.setup = function(obj, keyName) { assert(`Setting alias '${keyName}' on self`, this.altKey !== keyName); - var m = meta(obj); + let m = meta(obj); if (m.peekWatching(keyName)) { addDependentKeys(this, obj, keyName, m); } }; AliasedProperty.prototype.teardown = function(obj, keyName) { - var m = meta(obj); + let m = meta(obj); if (m.peekWatching(keyName)) { removeDependentKeys(this, obj, keyName, m); } diff --git a/packages/ember-metal/lib/cache.js b/packages/ember-metal/lib/cache.js index ff4e1eedcab..e169077ab84 100644 --- a/packages/ember-metal/lib/cache.js +++ b/packages/ember-metal/lib/cache.js @@ -10,7 +10,7 @@ function Cache(limit, func) { this.func = func; } -var UNDEFINED = function() {}; +function UNDEFINED() {} Cache.prototype = { set(key, value) { @@ -27,7 +27,7 @@ Cache.prototype = { }, get(key) { - var value = this.store[key]; + let value = this.store[key]; if (value === undefined) { this.misses ++; diff --git a/packages/ember-metal/lib/chains.js b/packages/ember-metal/lib/chains.js index 4c632e0f941..9e2655657f9 100644 --- a/packages/ember-metal/lib/chains.js +++ b/packages/ember-metal/lib/chains.js @@ -3,7 +3,7 @@ import { meta as metaFor, peekMeta } from 'ember-metal/meta'; import { watchKey, unwatchKey } from 'ember-metal/watch_key'; import EmptyObject from 'ember-metal/empty_object'; -var FIRST_KEY = /^([^\.]+)/; +const FIRST_KEY = /^([^\.]+)/; function firstKey(path) { return path.match(FIRST_KEY)[0]; @@ -37,7 +37,7 @@ ChainWatchers.prototype = { remove(key, node) { let nodes = this.chains[key]; if (nodes) { - for (var i = 0; i < nodes.length; i++) { + for (let i = 0; i < nodes.length; i++) { if (nodes[i] === node) { nodes.splice(i, 1); break; @@ -49,7 +49,7 @@ ChainWatchers.prototype = { has(key, node) { let nodes = this.chains[key]; if (nodes) { - for (var i = 0; i < nodes.length; i++) { + for (let i = 0; i < nodes.length; i++) { if (nodes[i] === node) { return true; } @@ -169,7 +169,7 @@ function lazyGet(obj, key) { return; } - var meta = peekMeta(obj); + let meta = peekMeta(obj); // check if object meant only to be a prototype if (meta && meta.proto === obj) { @@ -191,7 +191,7 @@ function lazyGet(obj, key) { ChainNode.prototype = { value() { if (this._value === undefined && this._watching) { - var obj = this._parent.value(); + let obj = this._parent.value(); this._value = lazyGet(obj, this._key); } return this._value; @@ -199,7 +199,7 @@ ChainNode.prototype = { destroy() { if (this._watching) { - var obj = this._object; + let obj = this._object; if (obj) { removeChainWatcher(obj, this._key, this); } @@ -209,9 +209,9 @@ ChainNode.prototype = { // copies a top level object only copy(obj) { - var ret = new ChainNode(null, null, obj); - var paths = this._paths; - var path; + let ret = new ChainNode(null, null, obj); + let paths = this._paths; + let path; for (path in paths) { // this check will also catch non-number vals. @@ -250,8 +250,8 @@ ChainNode.prototype = { }, chain(key, path) { - var chains = this._chains; - var node; + let chains = this._chains; + let node; if (chains === undefined) { chains = this._chains = new EmptyObject(); } else { @@ -273,13 +273,13 @@ ChainNode.prototype = { }, unchain(key, path) { - var chains = this._chains; - var node = chains[key]; + let chains = this._chains; + let node = chains[key]; // unchain rest of path first... if (path && path.length > 1) { - var nextKey = firstKey(path); - var nextPath = path.slice(nextKey.length + 1); + let nextKey = firstKey(path); + let nextPath = path.slice(nextKey.length + 1); node.unchain(nextKey, nextPath); } @@ -293,7 +293,7 @@ ChainNode.prototype = { notify(revalidate, affected) { if (revalidate && this._watching) { - var obj = this._parent.value(); + let obj = this._parent.value(); if (obj !== this._object) { removeChainWatcher(this._object, this._key, this); this._object = obj; @@ -303,10 +303,10 @@ ChainNode.prototype = { } // then notify chains... - var chains = this._chains; - var node; + let chains = this._chains; + let node; if (chains) { - for (var key in chains) { + for (let key in chains) { node = chains[key]; if (node !== undefined) { node.notify(revalidate, affected); diff --git a/packages/ember-metal/lib/computed.js b/packages/ember-metal/lib/computed.js index eb2b2ee2e94..aa2240c764c 100644 --- a/packages/ember-metal/lib/computed.js +++ b/packages/ember-metal/lib/computed.js @@ -160,7 +160,7 @@ function ComputedProperty(config, opts) { ComputedProperty.prototype = new Descriptor(); -var ComputedPropertyPrototype = ComputedProperty.prototype; +const ComputedPropertyPrototype = ComputedProperty.prototype; /** Call on a computed property to set it into non-cached mode. When in this @@ -246,9 +246,9 @@ ComputedPropertyPrototype.readOnly = function() { @public */ ComputedPropertyPrototype.property = function() { - var args; + let args = []; - var addArg = function(property) { + function addArg(property) { warn( `Dependent keys containing @each only work one level deep. ` + `You cannot use nested forms like todos.@each.owner.name or todos.@each.owner.@each.name. ` + @@ -257,10 +257,9 @@ ComputedPropertyPrototype.property = function() { { id: 'ember-metal.computed-deep-each' } ); args.push(property); - }; + } - args = []; - for (var i = 0; i < arguments.length; i++) { + for (let i = 0; i < arguments.length; i++) { expandProperties(arguments[i], addArg); } @@ -536,14 +535,14 @@ ComputedPropertyPrototype.teardown = function(obj, keyName) { @public */ export default function computed(func) { - var args; + let args; if (arguments.length > 1) { args = [].slice.call(arguments); func = args.pop(); } - var cp = new ComputedProperty(func); + let cp = new ComputedProperty(func); if (args) { cp.property.apply(cp, args); @@ -567,9 +566,9 @@ export default function computed(func) { @public */ function cacheFor(obj, key) { - var meta = peekMeta(obj); - var cache = meta && meta.source === obj && meta.readableCache(); - var ret = cache && cache[key]; + let meta = peekMeta(obj); + let cache = meta && meta.source === obj && meta.readableCache(); + let ret = cache && cache[key]; if (ret === UNDEFINED) { return undefined; @@ -586,7 +585,7 @@ cacheFor.set = function(cache, key, value) { }; cacheFor.get = function(cache, key) { - var ret = cache[key]; + let ret = cache[key]; if (ret === UNDEFINED) { return undefined; } diff --git a/packages/ember-metal/lib/dependent_keys.js b/packages/ember-metal/lib/dependent_keys.js index eff8e3ea606..3887caef9cc 100644 --- a/packages/ember-metal/lib/dependent_keys.js +++ b/packages/ember-metal/lib/dependent_keys.js @@ -19,8 +19,8 @@ import { export function addDependentKeys(desc, obj, keyName, meta) { // the descriptor has a list of dependent keys, so // add all of its dependent keys. - var idx, depKey; - var depKeys = desc._dependentKeys; + let idx, depKey; + let depKeys = desc._dependentKeys; if (!depKeys) { return; } @@ -37,14 +37,13 @@ export function addDependentKeys(desc, obj, keyName, meta) { export function removeDependentKeys(desc, obj, keyName, meta) { // the descriptor has a list of dependent keys, so // remove all of its dependent keys. - var depKeys = desc._dependentKeys; - var idx, depKey; + let depKeys = desc._dependentKeys; if (!depKeys) { return; } - for (idx = 0; idx < depKeys.length; idx++) { - depKey = depKeys[idx]; + 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); // Unwatch the depKey diff --git a/packages/ember-metal/lib/dictionary.js b/packages/ember-metal/lib/dictionary.js index 3de8b806b66..b4d878161ab 100644 --- a/packages/ember-metal/lib/dictionary.js +++ b/packages/ember-metal/lib/dictionary.js @@ -6,7 +6,7 @@ import EmptyObject from './empty_object'; // the cost of creation dramatically over a plain Object.create. And as this // only makes sense for long-lived dictionaries that aren't instantiated often. export default function makeDictionary(parent) { - var dict; + let dict; if (parent === null) { dict = new EmptyObject(); } else { diff --git a/packages/ember-metal/lib/empty_object.js b/packages/ember-metal/lib/empty_object.js index dbe6d6ddb35..5585df6fead 100644 --- a/packages/ember-metal/lib/empty_object.js +++ b/packages/ember-metal/lib/empty_object.js @@ -4,7 +4,7 @@ // and don't want your keys colliding with build-in methods on the // default object prototype. -var proto = Object.create(null, { +const proto = Object.create(null, { // without this, we will always still end up with (new // EmptyObject()).constructor === Object constructor: { diff --git a/packages/ember-metal/lib/error.js b/packages/ember-metal/lib/error.js index 508c3eafb2a..d9845d1fc09 100644 --- a/packages/ember-metal/lib/error.js +++ b/packages/ember-metal/lib/error.js @@ -1,4 +1,4 @@ -var errorProps = [ +const errorProps = [ 'description', 'fileName', 'lineNumber', @@ -18,7 +18,7 @@ var errorProps = [ @public */ export default function EmberError() { - var tmp = Error.apply(this, arguments); + let tmp = Error.apply(this, arguments); // Adds a `stack` property to the given error object that will yield the // stack trace at the time captureStackTrace was called. @@ -31,7 +31,7 @@ export default function EmberError() { Error.captureStackTrace(this, EmberError); } // Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work. - for (var idx = 0; idx < errorProps.length; idx++) { + for (let idx = 0; idx < errorProps.length; idx++) { this[errorProps[idx]] = tmp[errorProps[idx]]; } } diff --git a/packages/ember-metal/lib/events.js b/packages/ember-metal/lib/events.js index 0706dc5fcee..41f1bfc3fbf 100644 --- a/packages/ember-metal/lib/events.js +++ b/packages/ember-metal/lib/events.js @@ -33,11 +33,11 @@ import { ONCE, SUSPENDED } from 'ember-metal/meta_listeners'; */ function indexOf(array, target, method) { - var index = -1; + let index = -1; // hashes are added to the end of the event array // so it makes sense to start searching at the end // of the array and search in reverse - for (var i = array.length - 3 ; i >=0; i -= 3) { + for (let i = array.length - 3 ; i >=0; i -= 3) { if (target === array[i] && method === array[i + 1]) { index = i; break; @@ -47,16 +47,16 @@ function indexOf(array, target, method) { } export function accumulateListeners(obj, eventName, otherActions) { - var meta = peekMeta(obj); + let meta = peekMeta(obj); if (!meta) { return; } - var actions = meta.matchingListeners(eventName); - var newActions = []; + let actions = meta.matchingListeners(eventName); + let newActions = []; - for (var i = actions.length - 3; i >= 0; i -= 3) { - var target = actions[i]; - var method = actions[i + 1]; - var flags = actions[i + 2]; - var actionIndex = indexOf(otherActions, target, method); + for (let i = actions.length - 3; i >= 0; i -= 3) { + let target = actions[i]; + let method = actions[i + 1]; + let flags = actions[i + 2]; + let actionIndex = indexOf(otherActions, target, method); if (actionIndex === -1) { otherActions.push(target, method, flags); @@ -99,7 +99,7 @@ export function addListener(obj, eventName, target, method, once) { target = null; } - var flags = 0; + let flags = 0; if (once) { flags |= ONCE; } @@ -211,16 +211,16 @@ export function watchedEvents(obj) { */ export function sendEvent(obj, eventName, params, actions) { if (!actions) { - var meta = peekMeta(obj); + let meta = peekMeta(obj); actions = meta && meta.matchingListeners(eventName); } if (!actions || actions.length === 0) { return; } - for (var i = actions.length - 3; i >= 0; i -= 3) { // looping in reverse for once listeners - var target = actions[i]; - var method = actions[i + 1]; - var flags = actions[i + 2]; + for (let i = actions.length - 3; i >= 0; i -= 3) { // looping in reverse for once listeners + let target = actions[i]; + let method = actions[i + 1]; + let flags = actions[i + 2]; if (!method) { continue; } if (flags & SUSPENDED) { continue; } @@ -251,7 +251,7 @@ export function sendEvent(obj, eventName, params, actions) { @param {String} eventName */ export function hasListeners(obj, eventName) { - var meta = peekMeta(obj); + let meta = peekMeta(obj); if (!meta) { return false; } return meta.matchingListeners(eventName).length > 0; } @@ -264,15 +264,15 @@ export function hasListeners(obj, eventName) { @param {String} eventName */ export function listenersFor(obj, eventName) { - var ret = []; - var meta = peekMeta(obj); - var actions = meta && meta.matchingListeners(eventName); + let ret = []; + let meta = peekMeta(obj); + let actions = meta && meta.matchingListeners(eventName); if (!actions) { return ret; } - for (var i = 0; i < actions.length; i += 3) { - var target = actions[i]; - var method = actions[i + 1]; + for (let i = 0; i < actions.length; i += 3) { + let target = actions[i]; + let method = actions[i + 1]; ret.push([target, method]); } @@ -285,13 +285,13 @@ export function listenersFor(obj, eventName) { ``` javascript - var Job = Ember.Object.extend({ + let Job = Ember.Object.extend({ logCompleted: Ember.on('completed', function() { console.log('Job completed!'); }) }); - var job = Job.create(); + let job = Job.create(); Ember.sendEvent(job, 'completed'); // Logs 'Job completed!' ``` @@ -304,8 +304,8 @@ export function listenersFor(obj, eventName) { @public */ export function on(...args) { - var func = args.pop(); - var events = args; + let func = args.pop(); + let events = args; func.__ember_listens__ = events; return func; } diff --git a/packages/ember-metal/lib/expand_properties.js b/packages/ember-metal/lib/expand_properties.js index e2f1dd04d47..ce7fc6ce82a 100644 --- a/packages/ember-metal/lib/expand_properties.js +++ b/packages/ember-metal/lib/expand_properties.js @@ -5,8 +5,8 @@ import { assert } from 'ember-metal/debug'; @submodule ember-metal */ -var SPLIT_REGEX = /\{|\}/; -var END_WITH_EACH_REGEX = /\.@each$/; +const SPLIT_REGEX = /\{|\}/; +const END_WITH_EACH_REGEX = /\.@each$/; /** Expands `pattern`, invoking `callback` for each expansion. @@ -42,8 +42,8 @@ export default function expandProperties(pattern, callback) { pattern.indexOf(' ') === -1 ); - var parts = pattern.split(SPLIT_REGEX); - var properties = [parts]; + let parts = pattern.split(SPLIT_REGEX); + let properties = [parts]; for (let i = 0; i < parts.length; i++) { let part = parts[i]; @@ -58,11 +58,11 @@ export default function expandProperties(pattern, callback) { } function duplicateAndReplace(properties, currentParts, index) { - var all = []; + let all = []; properties.forEach((property) => { currentParts.forEach((part) => { - var current = property.slice(0); + let current = property.slice(0); current[index] = part; all.push(current); }); diff --git a/packages/ember-metal/lib/get_properties.js b/packages/ember-metal/lib/get_properties.js index 7a27080aaec..7b66b541342 100644 --- a/packages/ember-metal/lib/get_properties.js +++ b/packages/ember-metal/lib/get_properties.js @@ -24,9 +24,9 @@ import { get } from 'ember-metal/property_get'; @public */ export default function getProperties(obj) { - var ret = {}; - var propertyNames = arguments; - var i = 1; + let ret = {}; + let propertyNames = arguments; + let i = 1; if (arguments.length === 2 && Array.isArray(arguments[1])) { i = 0; diff --git a/packages/ember-metal/lib/index.js b/packages/ember-metal/lib/index.js index 70a36383f8f..f0529234850 100644 --- a/packages/ember-metal/lib/index.js +++ b/packages/ember-metal/lib/index.js @@ -161,7 +161,7 @@ import Backburner from 'backburner'; // END IMPORTS // BEGIN EXPORTS -var EmberInstrumentation = Ember.Instrumentation = {}; +const EmberInstrumentation = Ember.Instrumentation = {}; EmberInstrumentation.instrument = instrument; EmberInstrumentation.subscribe = instrumentationSubscribe; EmberInstrumentation.unsubscribe = instrumentationUnsubscribe; @@ -329,31 +329,31 @@ Ember.EXTEND_PROTOTYPES = ENV.EXTEND_PROTOTYPES; // BACKWARDS COMPAT ACCESSORS FOR ENV FLAGS Object.defineProperty(Ember, 'LOG_STACKTRACE_ON_DEPRECATION', { - get: () => ENV.LOG_STACKTRACE_ON_DEPRECATION, - set: value => ENV.LOG_STACKTRACE_ON_DEPRECATION = !!value, + get() { return ENV.LOG_STACKTRACE_ON_DEPRECATION; }, + set(value) { ENV.LOG_STACKTRACE_ON_DEPRECATION = !!value; }, enumerable: false }); Object.defineProperty(Ember, 'LOG_VERSION', { - get: () => ENV.LOG_VERSION, - set: value => ENV.LOG_VERSION = !!value, + get() { return ENV.LOG_VERSION; }, + set(value) { ENV.LOG_VERSION = !!value; }, enumerable: false }); Object.defineProperty(Ember, 'MODEL_FACTORY_INJECTIONS', { - get: () => ENV.MODEL_FACTORY_INJECTIONS, - set: value => ENV.MODEL_FACTORY_INJECTIONS = !!value, + get() { return ENV.MODEL_FACTORY_INJECTIONS; }, + set(value) { ENV.MODEL_FACTORY_INJECTIONS = !!value; }, enumerable: false }); Object.defineProperty(Ember, 'LOG_BINDINGS', { - get: () => ENV.LOG_BINDINGS, - set: value => ENV.LOG_BINDINGS = !!value, + get() { return ENV.LOG_BINDINGS; }, + set(value) { ENV.LOG_BINDINGS = !!value; }, enumerable: false }); Object.defineProperty(Ember, 'ENV', { - get: () => ENV, + get() { return ENV; }, enumerable: false }); @@ -363,8 +363,8 @@ Object.defineProperty(Ember, 'ENV', { @private */ Object.defineProperty(Ember, 'lookup', { - get: () => context.lookup, - set: value => context.lookup = value, + get() { return context.lookup; }, + set(value) { context.lookup = value; }, enumerable: false }); diff --git a/packages/ember-metal/lib/injected_property.js b/packages/ember-metal/lib/injected_property.js index 9b461c80695..bd5e07af65f 100644 --- a/packages/ember-metal/lib/injected_property.js +++ b/packages/ember-metal/lib/injected_property.js @@ -15,7 +15,7 @@ import { getOwner } from 'container/owner'; to the property's name @private */ -function InjectedProperty(type, name) { +export default function InjectedProperty(type, name) { this.type = type; this.name = name; @@ -24,7 +24,7 @@ function InjectedProperty(type, name) { } function injectedPropertyGet(keyName) { - var desc = this[keyName]; + let desc = this[keyName]; let owner = getOwner(this) || this.container; // fallback to `container` for backwards compat assert(`InjectedProperties should be defined with the Ember.inject computed property macros.`, desc && desc.isDescriptor && desc.type); @@ -35,15 +35,12 @@ function injectedPropertyGet(keyName) { InjectedProperty.prototype = Object.create(Descriptor.prototype); -var InjectedPropertyPrototype = InjectedProperty.prototype; -var ComputedPropertyPrototype = ComputedProperty.prototype; -var AliasedPropertyPrototype = AliasedProperty.prototype; +const InjectedPropertyPrototype = InjectedProperty.prototype; +const ComputedPropertyPrototype = ComputedProperty.prototype; +const AliasedPropertyPrototype = AliasedProperty.prototype; InjectedPropertyPrototype._super$Constructor = ComputedProperty; InjectedPropertyPrototype.get = ComputedPropertyPrototype.get; InjectedPropertyPrototype.readOnly = ComputedPropertyPrototype.readOnly; - InjectedPropertyPrototype.teardown = ComputedPropertyPrototype.teardown; - -export default InjectedProperty; diff --git a/packages/ember-metal/lib/instrumentation.js b/packages/ember-metal/lib/instrumentation.js index dab363afbc0..72c2ad95e2e 100644 --- a/packages/ember-metal/lib/instrumentation.js +++ b/packages/ember-metal/lib/instrumentation.js @@ -10,11 +10,11 @@ import isEnabled from 'ember-metal/features'; ```javascript Ember.subscribe("render", { - before: function(name, timestamp, payload) { + before(name, timestamp, payload) { }, - after: function(name, timestamp, payload) { + after(name, timestamp, payload) { } }); @@ -48,14 +48,14 @@ import isEnabled from 'ember-metal/features'; @static @private */ -export var subscribers = []; -var cache = {}; +export let subscribers = []; +let cache = {}; -var populateListeners = function(name) { - var listeners = []; - var subscriber; +function populateListeners(name) { + let listeners = []; + let subscriber; - for (var i = 0; i < subscribers.length; i++) { + for (let i = 0; i < subscribers.length; i++) { subscriber = subscribers[i]; if (subscriber.regex.test(name)) { listeners.push(subscriber.object); @@ -64,11 +64,11 @@ var populateListeners = function(name) { cache[name] = listeners; return listeners; -}; +} -var time = (function() { - var perf = 'undefined' !== typeof window ? window.performance || {} : {}; - var fn = perf.now || perf.mozNow || perf.webkitNow || perf.msNow || perf.oNow; +const time = (function() { + let perf = '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 ? fn.bind(perf) : () => { return +new Date(); @@ -96,8 +96,8 @@ export function instrument(name, _payload, callback, binding) { if (subscribers.length === 0) { return callback.call(binding); } - var payload = _payload || {}; - var finalizer = _instrumentStart(name, () => payload); + let payload = _payload || {}; + let finalizer = _instrumentStart(name, () => payload); if (finalizer) { return withFinalizer(callback, finalizer, payload, binding); @@ -106,13 +106,11 @@ export function instrument(name, _payload, callback, binding) { } } -var flaggedInstrument; +let flaggedInstrument; if (isEnabled('ember-improved-instrumentation')) { flaggedInstrument = instrument; } else { - flaggedInstrument = function(name, payload, callback) { - return callback(); - }; + flaggedInstrument = (name, payload, callback) => callback(); } export { flaggedInstrument }; @@ -131,7 +129,7 @@ function withFinalizer(callback, finalizer, payload, binding) { // private for now export function _instrumentStart(name, _payload) { - var listeners = cache[name]; + let listeners = cache[name]; if (!listeners) { listeners = populateListeners(name); @@ -141,26 +139,26 @@ export function _instrumentStart(name, _payload) { return; } - var payload = _payload(); + let payload = _payload(); - var STRUCTURED_PROFILE = ENV.STRUCTURED_PROFILE; - var timeName; + let STRUCTURED_PROFILE = ENV.STRUCTURED_PROFILE; + let timeName; if (STRUCTURED_PROFILE) { timeName = name + ': ' + payload.object; console.time(timeName); } - var beforeValues = new Array(listeners.length); - var i, listener; - var timestamp = time(); + let beforeValues = new Array(listeners.length); + let i, listener; + let timestamp = time(); for (i = 0; i < listeners.length; i++) { listener = listeners[i]; beforeValues[i] = listener.before(name, timestamp, payload); } return function _instrumentEnd() { - var i, listener; - var timestamp = time(); + let i, listener; + let timestamp = time(); for (i = 0; i < listeners.length; i++) { listener = listeners[i]; if (typeof listener.after === 'function') { @@ -187,11 +185,11 @@ export function _instrumentStart(name, _payload) { @private */ export function subscribe(pattern, object) { - var paths = pattern.split('.'); - var path; - var regex = []; + let paths = pattern.split('.'); + let path; + let regex = []; - for (var i = 0; i < paths.length; i++) { + for (let i = 0; i < paths.length; i++) { path = paths[i]; if (path === '*') { regex.push('[^\\.]*'); @@ -203,7 +201,7 @@ export function subscribe(pattern, object) { regex = regex.join('\\.'); regex = regex + '(\\..*)?'; - var subscriber = { + let subscriber = { pattern: pattern, regex: new RegExp('^' + regex + '$'), object: object @@ -225,9 +223,9 @@ export function subscribe(pattern, object) { @private */ export function unsubscribe(subscriber) { - var index; + let index; - for (var i = 0; i < subscribers.length; i++) { + for (let i = 0; i < subscribers.length; i++) { if (subscribers[i] === subscriber) { index = i; } diff --git a/packages/ember-metal/lib/is_empty.js b/packages/ember-metal/lib/is_empty.js index f86b8016da2..541b3a82fd9 100644 --- a/packages/ember-metal/lib/is_empty.js +++ b/packages/ember-metal/lib/is_empty.js @@ -27,8 +27,8 @@ import isNone from 'ember-metal/is_none'; @return {Boolean} @public */ -function isEmpty(obj) { - var none = isNone(obj); +export default function isEmpty(obj) { + let none = isNone(obj); if (none) { return none; } @@ -37,10 +37,10 @@ function isEmpty(obj) { return !obj.size; } - var objectType = typeof obj; + let objectType = typeof obj; if (objectType === 'object') { - var size = get(obj, 'size'); + let size = get(obj, 'size'); if (typeof size === 'number') { return !size; } @@ -51,7 +51,7 @@ function isEmpty(obj) { } if (objectType === 'object') { - var length = get(obj, 'length'); + let length = get(obj, 'length'); if (typeof length === 'number') { return !length; } @@ -59,5 +59,3 @@ function isEmpty(obj) { return false; } - -export default isEmpty; diff --git a/packages/ember-metal/lib/libraries.js b/packages/ember-metal/lib/libraries.js index 6fde99f8d09..56dabfd8302 100644 --- a/packages/ember-metal/lib/libraries.js +++ b/packages/ember-metal/lib/libraries.js @@ -19,10 +19,10 @@ Libraries.prototype = { constructor: Libraries, _getLibraryByName(name) { - var libs = this._registry; - var count = libs.length; + let libs = this._registry; + let count = libs.length; - for (var i = 0; i < count; i++) { + for (let i = 0; i < count; i++) { if (libs[i].name === name) { return libs[i]; } @@ -30,7 +30,7 @@ Libraries.prototype = { }, register(name, version, isCoreLibrary) { - var index = this._registry.length; + let index = this._registry.length; if (!this._getLibraryByName(name)) { if (isCoreLibrary) { @@ -47,8 +47,8 @@ Libraries.prototype = { }, deRegister(name) { - var lib = this._getLibraryByName(name); - var index; + let lib = this._getLibraryByName(name); + let index; if (lib) { index = this._registry.indexOf(lib); diff --git a/packages/ember-metal/lib/map.js b/packages/ember-metal/lib/map.js index 217140b8877..a165cb0c540 100644 --- a/packages/ember-metal/lib/map.js +++ b/packages/ember-metal/lib/map.js @@ -32,9 +32,9 @@ function missingNew(name) { } function copyNull(obj) { - var output = new EmptyObject(); + let output = new EmptyObject(); - for (var prop in obj) { + for (let prop in obj) { // hasOwnPropery is not needed because obj is new EmptyObject(); output[prop] = obj[prop]; } @@ -43,8 +43,8 @@ function copyNull(obj) { } function copyMap(original, newObject) { - var keys = original._keys.copy(); - var values = copyNull(original._values); + let keys = original._keys.copy(); + let values = copyNull(original._values); newObject._keys = keys; newObject._values = values; @@ -79,7 +79,7 @@ function OrderedSet() { @private */ OrderedSet.create = function() { - var Constructor = this; + let Constructor = this; return new Constructor(); }; @@ -104,9 +104,9 @@ OrderedSet.prototype = { @private */ add(obj, _guid) { - var guid = _guid || guidFor(obj); - var presenceSet = this.presenceSet; - var list = this.list; + let guid = _guid || guidFor(obj); + let presenceSet = this.presenceSet; + let list = this.list; if (presenceSet[guid] !== true) { presenceSet[guid] = true; @@ -125,13 +125,13 @@ OrderedSet.prototype = { @private */ delete(obj, _guid) { - var guid = _guid || guidFor(obj); - var presenceSet = this.presenceSet; - var list = this.list; + let guid = _guid || guidFor(obj); + let presenceSet = this.presenceSet; + let list = this.list; if (presenceSet[guid] === true) { delete presenceSet[guid]; - var index = list.indexOf(obj); + let index = list.indexOf(obj); if (index > -1) { list.splice(index, 1); } @@ -160,8 +160,8 @@ OrderedSet.prototype = { has(obj) { if (this.size === 0) { return false; } - var guid = guidFor(obj); - var presenceSet = this.presenceSet; + let guid = guidFor(obj); + let presenceSet = this.presenceSet; return presenceSet[guid] === true; }, @@ -179,15 +179,14 @@ OrderedSet.prototype = { if (this.size === 0) { return; } - var list = this.list; - var i; + let list = this.list; if (arguments.length === 2) { - for (i = 0; i < list.length; i++) { + for (let i = 0; i < list.length; i++) { fn.call(arguments[1], list[i]); } } else { - for (i = 0; i < list.length; i++) { + for (let i = 0; i < list.length; i++) { fn(list[i]); } } @@ -208,8 +207,8 @@ OrderedSet.prototype = { @private */ copy() { - var Constructor = this.constructor; - var set = new Constructor(); + let Constructor = this.constructor; + let set = new Constructor(); set._silenceRemoveDeprecation = this._silenceRemoveDeprecation; set.presenceSet = copyNull(this.presenceSet); @@ -257,7 +256,7 @@ function Map() { @private */ Map.create = function() { - var Constructor = this; + let Constructor = this; return new Constructor(); }; @@ -286,8 +285,8 @@ Map.prototype = { get(key) { if (this.size === 0) { return; } - var values = this._values; - var guid = guidFor(key); + let values = this._values; + let guid = guidFor(key); return values[guid]; }, @@ -303,12 +302,12 @@ Map.prototype = { @private */ set(key, value) { - var keys = this._keys; - var values = this._values; - var guid = guidFor(key); + let keys = this._keys; + let values = this._values; + let guid = guidFor(key); // ensure we don't store -0 - var k = key === -0 ? 0 : key; + let k = key === -0 ? 0 : key; keys.add(k, guid); @@ -332,9 +331,9 @@ Map.prototype = { if (this.size === 0) { return false; } // don't use ES6 "delete" because it will be annoying // to use in browsers that are not ES6 friendly; - var keys = this._keys; - var values = this._values; - var guid = guidFor(key); + let keys = this._keys; + let values = this._values; + let guid = guidFor(key); if (keys.delete(key, guid)) { delete values[guid]; @@ -377,18 +376,14 @@ Map.prototype = { if (this.size === 0) { return; } - var map = this; - var cb, thisArg; + let map = this; + let cb, thisArg; if (arguments.length === 2) { thisArg = arguments[1]; - cb = function(key) { - callback.call(thisArg, map.get(key), key, map); - }; + cb = key => callback.call(thisArg, map.get(key), key, map); } else { - cb = function(key) { - callback(map.get(key), key, map); - }; + cb = key => callback(map.get(key), key, map); } this._keys.forEach(cb); @@ -459,12 +454,12 @@ MapWithDefault.prototype._super$get = Map.prototype.get; @private */ MapWithDefault.prototype.get = function(key) { - var hasValue = this.has(key); + let hasValue = this.has(key); if (hasValue) { return this._super$get(key); } else { - var defaultValue = this.defaultValue(key); + let defaultValue = this.defaultValue(key); this.set(key, defaultValue); return defaultValue; } @@ -476,7 +471,7 @@ MapWithDefault.prototype.get = function(key) { @private */ MapWithDefault.prototype.copy = function() { - var Constructor = this.constructor; + let Constructor = this.constructor; return copyMap(this, new Constructor({ defaultValue: this.defaultValue })); diff --git a/packages/ember-metal/lib/merge.js b/packages/ember-metal/lib/merge.js index 2d806915c07..6637e3d2b4a 100644 --- a/packages/ember-metal/lib/merge.js +++ b/packages/ember-metal/lib/merge.js @@ -3,8 +3,8 @@ ```javascript Ember.merge({first: 'Tom'}, {last: 'Dale'}); // {first: 'Tom', last: 'Dale'} - var a = {first: 'Yehuda'}; - var b = {last: 'Katz'}; + let a = {first: 'Yehuda'}; + let b = {last: 'Katz'}; Ember.merge(a, b); // a == {first: 'Yehuda', last: 'Katz'}, b == {last: 'Katz'} ``` @@ -20,10 +20,10 @@ export default function merge(original, updates) { return original; } - var props = Object.keys(updates); - var prop; + let props = Object.keys(updates); + let prop; - for (var i = 0; i < props.length; i++) { + for (let i = 0; i < props.length; i++) { prop = props[i]; original[prop] = updates[prop]; } diff --git a/packages/ember-metal/lib/meta.js b/packages/ember-metal/lib/meta.js index 74aeca6e55d..9e2fcc387cd 100644 --- a/packages/ember-metal/lib/meta.js +++ b/packages/ember-metal/lib/meta.js @@ -305,7 +305,7 @@ export var META_DESC = { value: null }; -var EMBER_META_PROPERTY = { +const EMBER_META_PROPERTY = { name: META_FIELD, descriptor: META_DESC }; diff --git a/packages/ember-metal/lib/meta_listeners.js b/packages/ember-metal/lib/meta_listeners.js index 736dda52585..5b8ec74500e 100644 --- a/packages/ember-metal/lib/meta_listeners.js +++ b/packages/ember-metal/lib/meta_listeners.js @@ -11,10 +11,10 @@ */ /* listener flags */ -export var ONCE = 1; -export var SUSPENDED = 2; +export const ONCE = 1; +export const SUSPENDED = 2; -export var protoMethods = { +export const protoMethods = { addToListeners(eventName, target, method, flags) { if (!this._listeners) { diff --git a/packages/ember-metal/lib/mixin.js b/packages/ember-metal/lib/mixin.js index 65489a7a0eb..1e8f53fdc3f 100644 --- a/packages/ember-metal/lib/mixin.js +++ b/packages/ember-metal/lib/mixin.js @@ -37,8 +37,7 @@ import { function ROOT() {} ROOT.__hasSuper = false; -var REQUIRED; -var a_slice = [].slice; +const a_slice = [].slice; function isMethod(obj) { return 'function' === typeof obj && @@ -51,10 +50,10 @@ function isMethod(obj) { obj !== String; } -var CONTINUE = {}; +const CONTINUE = {}; function mixinProperties(mixinsMeta, mixin) { - var guid; + let guid; if (mixin instanceof Mixin) { guid = guidFor(mixin); @@ -67,7 +66,7 @@ function mixinProperties(mixinsMeta, mixin) { } function concatenatedMixinProperties(concatProp, props, values, base) { - var concats; + let concats; // reset before adding each new mixin to pickup concats from previous concats = values[concatProp] || base[concatProp]; @@ -79,7 +78,7 @@ function concatenatedMixinProperties(concatProp, props, values, base) { } function giveDescriptorSuper(meta, key, property, values, descs, base) { - var superProperty; + let superProperty; // Computed properties override methods, and do not call super to them if (values[key] === undefined) { @@ -90,8 +89,8 @@ function giveDescriptorSuper(meta, key, property, values, descs, base) { // If we didn't find the original descriptor in a parent mixin, find // it on the original object. if (!superProperty) { - var possibleDesc = base[key]; - var superDesc = (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) ? possibleDesc : undefined; + let possibleDesc = base[key]; + let superDesc = (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) ? possibleDesc : undefined; superProperty = superDesc; } @@ -117,7 +116,7 @@ function giveDescriptorSuper(meta, key, property, values, descs, base) { } function giveMethodSuper(obj, key, method, values, descs) { - var superMethod; + let superMethod; // Methods overwrite computed properties, and do not call super to them. if (descs[key] === undefined) { @@ -138,7 +137,7 @@ function giveMethodSuper(obj, key, method, values, descs) { } function applyConcatenatedProperties(obj, key, value, values) { - var baseValue = values[key] || obj[key]; + let baseValue = values[key] || obj[key]; if (baseValue) { if ('function' === typeof baseValue.concat) { @@ -156,7 +155,7 @@ function applyConcatenatedProperties(obj, key, value, values) { } function applyMergedProperties(obj, key, value, values) { - var baseValue = values[key] || obj[key]; + let baseValue = values[key] || obj[key]; runInDebug(function() { if (Array.isArray(value)) { // use conditional to avoid stringifying every time @@ -166,13 +165,13 @@ function applyMergedProperties(obj, key, value, values) { if (!baseValue) { return value; } - var newBase = assign({}, baseValue); - var hasFunction = false; + let newBase = assign({}, baseValue); + let hasFunction = false; - for (var prop in value) { + for (let prop in value) { if (!value.hasOwnProperty(prop)) { continue; } - var propValue = value[prop]; + let propValue = value[prop]; if (isMethod(propValue)) { // TODO: support for Computed Properties, etc? hasFunction = true; @@ -218,14 +217,14 @@ function addNormalizedProperty(base, key, value, meta, descs, values, concats, m } function mergeMixins(mixins, m, descs, values, base, keys) { - var currentMixin, props, key, concats, mergings, meta; + let currentMixin, props, key, concats, mergings, meta; function removeKeys(keyName) { delete descs[keyName]; delete values[keyName]; } - for (var i = 0; i < mixins.length; i++) { + for (let i = 0; i < mixins.length; i++) { currentMixin = mixins[i]; assert( `Expected hash or Mixin instance, got ${Object.prototype.toString.call(currentMixin)}`, @@ -256,7 +255,7 @@ function mergeMixins(mixins, m, descs, values, base, keys) { } } -var IS_BINDING = /^.+Binding$/; +let IS_BINDING = /^.+Binding$/; function detectBinding(obj, key, value, m) { if (IS_BINDING.test(key)) { @@ -289,9 +288,9 @@ function finishPartial(obj, m) { } function followAlias(obj, desc, m, descs, values) { - var altKey = desc.methodName; - var value; - var possibleDesc; + let altKey = desc.methodName; + let value; + let possibleDesc; if (descs[altKey] || values[altKey]) { value = values[altKey]; desc = descs[altKey]; @@ -307,17 +306,17 @@ function followAlias(obj, desc, m, descs, values) { } function updateObserversAndListeners(obj, key, observerOrListener, pathsKey, updateMethod) { - var paths = observerOrListener[pathsKey]; + let paths = observerOrListener[pathsKey]; if (paths) { - for (var i = 0; i < paths.length; i++) { + for (let i = 0; i < paths.length; i++) { updateMethod(obj, paths[i], null, key); } } } function replaceObserversAndListeners(obj, key, observerOrListener) { - var prev = obj[key]; + let prev = obj[key]; if ('function' === typeof prev) { updateObserversAndListeners(obj, key, prev, '__ember_observesBefore__', _removeBeforeObserver); @@ -333,11 +332,11 @@ function replaceObserversAndListeners(obj, key, observerOrListener) { } function applyMixin(obj, mixins, partial) { - var descs = {}; - var values = {}; - var m = metaFor(obj); - var keys = []; - var key, value, desc; + let descs = {}; + let values = {}; + let m = metaFor(obj); + let keys = []; + let key, value, desc; obj._super = ROOT; @@ -350,7 +349,7 @@ function applyMixin(obj, mixins, partial) { // * Copying `toString` in broken browsers mergeMixins(mixins, m, descs, values, obj, keys); - for (var i = 0; i < keys.length; i++) { + for (let i = 0; i < keys.length; i++) { key = keys[i]; if (key === 'constructor' || !values.hasOwnProperty(key)) { continue; } @@ -360,7 +359,7 @@ function applyMixin(obj, mixins, partial) { if (desc === REQUIRED) { continue; } while (desc && desc instanceof Alias) { - var followed = followAlias(obj, desc, m, descs, values); + let followed = followAlias(obj, desc, m, descs, values); desc = followed.desc; value = followed.value; } @@ -452,13 +451,13 @@ export const NAME_KEY = GUID_KEY + '_name'; export default function Mixin(args, properties) { this.properties = properties; - var length = args && args.length; + let length = args && args.length; if (length > 0) { - var m = new Array(length); + let m = new Array(length); - for (var i = 0; i < length; i++) { - var x = args[i]; + for (let i = 0; i < length; i++) { + let x = args[i]; if (x instanceof Mixin) { m[i] = x; } else { @@ -480,7 +479,7 @@ export default function Mixin(args, properties) { Mixin._apply = applyMixin; Mixin.applyPartial = function(obj) { - var args = a_slice.call(arguments, 1); + let args = a_slice.call(arguments, 1); return applyMixin(obj, args, true); }; @@ -505,12 +504,11 @@ export function clearUnprocessedMixins() { Mixin.create = function(...args) { // ES6TODO: this relies on a global state? unprocessedFlag = true; - var M = this; + let M = this; return new M(args, undefined); }; -var MixinPrototype = Mixin.prototype; - +let MixinPrototype = Mixin.prototype; /** @method reopen @@ -518,7 +516,7 @@ var MixinPrototype = Mixin.prototype; @private */ MixinPrototype.reopen = function() { - var currentMixin; + let currentMixin; if (this.properties) { currentMixin = new Mixin(undefined, this.properties); @@ -528,8 +526,8 @@ MixinPrototype.reopen = function() { this.mixins = []; } - var mixins = this.mixins; - var idx; + let mixins = this.mixins; + let idx; for (idx = 0; idx < arguments.length; idx++) { currentMixin = arguments[idx]; @@ -566,14 +564,14 @@ MixinPrototype.applyPartial = function(obj) { MixinPrototype.toString = Object.toString; function _detect(curMixin, targetMixin, seen) { - var guid = guidFor(curMixin); + let guid = guidFor(curMixin); if (seen[guid]) { return false; } seen[guid] = true; if (curMixin === targetMixin) { return true; } - var mixins = curMixin.mixins; - var loc = mixins ? mixins.length : 0; + let mixins = curMixin.mixins; + let loc = mixins ? mixins.length : 0; while (--loc >= 0) { if (_detect(mixins[loc], targetMixin, seen)) { return true; } } @@ -589,13 +587,13 @@ function _detect(curMixin, targetMixin, seen) { MixinPrototype.detect = function(obj) { if (!obj) { return false; } if (obj instanceof Mixin) { return _detect(obj, this, {}); } - var m = peekMeta(obj); + let m = peekMeta(obj); if (!m) { return false; } return !!m.peekMixins(guidFor(this)); }; MixinPrototype.without = function(...args) { - var ret = new Mixin([this]); + let ret = new Mixin([this]); ret._without = args; return ret; }; @@ -605,9 +603,9 @@ function _keys(ret, mixin, seen) { seen[guidFor(mixin)] = true; if (mixin.properties) { - var props = Object.keys(mixin.properties); - for (var i = 0; i < props.length; i++) { - var key = props[i]; + let props = Object.keys(mixin.properties); + for (let i = 0; i < props.length; i++) { + let key = props[i]; ret[key] = true; } } else if (mixin.mixins) { @@ -616,11 +614,11 @@ function _keys(ret, mixin, seen) { } MixinPrototype.keys = function() { - var keys = {}; - var seen = {}; + let keys = {}; + let seen = {}; _keys(keys, this, seen); - var ret = Object.keys(keys); + let ret = Object.keys(keys); return ret; }; @@ -629,8 +627,8 @@ debugSeal(MixinPrototype); // returns the mixins currently applied to the specified object // TODO: Make Ember.mixin Mixin.mixins = function(obj) { - var m = peekMeta(obj); - var ret = []; + let m = peekMeta(obj); + let ret = []; if (!m) { return ret; } m.forEachMixins((key, currentMixin) => { @@ -641,7 +639,7 @@ Mixin.mixins = function(obj) { return ret; }; -REQUIRED = new Descriptor(); +const REQUIRED = new Descriptor(); REQUIRED.toString = function() { return '(Required Property)'; }; /** @@ -678,7 +676,7 @@ Alias.prototype = new Descriptor(); moniker: Ember.aliasMethod('name') }); - var goodGuy = App.Person.create(); + let goodGuy = App.Person.create(); goodGuy.name(); // 'Tomhuda Katzdale' goodGuy.moniker(); // 'Tomhuda Katzdale' @@ -719,13 +717,13 @@ export function aliasMethod(methodName) { @public */ export function observer(...args) { - var func = args.slice(-1)[0]; - var paths; + let func = args.slice(-1)[0]; + let paths; - var addWatchedProperty = function(path) { + let addWatchedProperty = function(path) { paths.push(path); }; - var _paths = args.slice(0, -1); + let _paths = args.slice(0, -1); if (typeof func !== 'function') { // revert to old, soft-deprecated argument ordering @@ -737,7 +735,7 @@ export function observer(...args) { paths = []; - for (var i = 0; i < _paths.length; ++i) { + for (let i = 0; i < _paths.length; ++i) { expandProperties(_paths[i], addWatchedProperty); } @@ -777,8 +775,8 @@ export function observer(...args) { export function _immediateObserver() { deprecate('Usage of `Ember.immediateObserver` is deprecated, use `Ember.observer` instead.', false, { id: 'ember-metal.immediate-observer', until: '3.0.0' }); - for (var i = 0; i < arguments.length; i++) { - var arg = arguments[i]; + for (let i = 0; i < arguments.length; i++) { + let arg = arguments[i]; assert( 'Immediate observers must observe internal properties only, not properties on other objects.', typeof arg !== 'string' || arg.indexOf('.') === -1 @@ -805,7 +803,7 @@ export function _immediateObserver() { valueDidChange: Ember.observer('content.value', function(obj, keyName) { // only run if updating a value already in the DOM if (this.get('state') === 'inDOM') { - var color = obj.get(keyName) > this.changingFrom ? 'green' : 'red'; + let color = obj.get(keyName) > this.changingFrom ? 'green' : 'red'; // logic } }), @@ -829,12 +827,12 @@ export function _immediateObserver() { @private */ export function _beforeObserver(...args) { - var func = args.slice(-1)[0]; - var paths; + let func = args.slice(-1)[0]; + let paths; - var addWatchedProperty = function(path) { paths.push(path); }; + let addWatchedProperty = function(path) { paths.push(path); }; - var _paths = args.slice(0, -1); + let _paths = args.slice(0, -1); if (typeof func !== 'function') { // revert to old, soft-deprecated argument ordering @@ -845,7 +843,7 @@ export function _beforeObserver(...args) { paths = []; - for (var i = 0; i < _paths.length; ++i) { + for (let i = 0; i < _paths.length; ++i) { expandProperties(_paths[i], addWatchedProperty); } diff --git a/packages/ember-metal/lib/observer.js b/packages/ember-metal/lib/observer.js index fe56218fec2..9efec41d466 100644 --- a/packages/ember-metal/lib/observer.js +++ b/packages/ember-metal/lib/observer.js @@ -13,8 +13,8 @@ import { @module ember-metal */ -var AFTER_OBSERVERS = ':change'; -var BEFORE_OBSERVERS = ':before'; +const AFTER_OBSERVERS = ':change'; +const BEFORE_OBSERVERS = ':before'; function changeEvent(keyName) { return keyName + AFTER_OBSERVERS; @@ -86,7 +86,7 @@ export function _suspendObserver(obj, path, target, method, callback) { } export function _suspendObservers(obj, paths, target, method, callback) { - var events = paths.map(changeEvent); + let events = paths.map(changeEvent); return suspendListeners(obj, events, target, method, callback); } diff --git a/packages/ember-metal/lib/observer_set.js b/packages/ember-metal/lib/observer_set.js index a59b5dbea5b..a3ebcc555d2 100644 --- a/packages/ember-metal/lib/observer_set.js +++ b/packages/ember-metal/lib/observer_set.js @@ -19,18 +19,17 @@ import { sendEvent } from 'ember-metal/events'; ... ] */ -export default ObserverSet; -function ObserverSet() { +export default function ObserverSet() { this.clear(); } ObserverSet.prototype.add = function(sender, keyName, eventName) { - var observerSet = this.observerSet; - var observers = this.observers; - var senderGuid = guidFor(sender); - var keySet = observerSet[senderGuid]; - var index; + let observerSet = this.observerSet; + let observers = this.observers; + let senderGuid = guidFor(sender); + let keySet = observerSet[senderGuid]; + let index; if (!keySet) { observerSet[senderGuid] = keySet = {}; @@ -49,8 +48,8 @@ ObserverSet.prototype.add = function(sender, keyName, eventName) { }; ObserverSet.prototype.flush = function() { - var observers = this.observers; - var i, observer, sender; + let observers = this.observers; + let i, observer, sender; this.clear(); for (i = 0; i < observers.length; ++i) { observer = observers[i]; @@ -64,4 +63,3 @@ ObserverSet.prototype.clear = function() { this.observerSet = {}; this.observers = []; }; - diff --git a/packages/ember-metal/lib/path_cache.js b/packages/ember-metal/lib/path_cache.js index 3679f7cad32..ddd723f972e 100644 --- a/packages/ember-metal/lib/path_cache.js +++ b/packages/ember-metal/lib/path_cache.js @@ -1,27 +1,16 @@ import Cache from 'ember-metal/cache'; -var IS_GLOBAL = /^[A-Z$]/; -var IS_GLOBAL_PATH = /^[A-Z$].*[\.]/; -var HAS_THIS = 'this.'; +const IS_GLOBAL = /^[A-Z$]/; +const IS_GLOBAL_PATH = /^[A-Z$].*[\.]/; +const HAS_THIS = 'this.'; -var isGlobalCache = new Cache(1000, (key) => { - return IS_GLOBAL.test(key); -}); - -var isGlobalPathCache = new Cache(1000, (key) => { - return IS_GLOBAL_PATH.test(key); -}); - -var hasThisCache = new Cache(1000, (key) => { - return key.lastIndexOf(HAS_THIS, 0) === 0; -}); - -var firstDotIndexCache = new Cache(1000, (key) => { - return key.indexOf('.'); -}); +const isGlobalCache = new Cache(1000, key => IS_GLOBAL.test(key)); +const isGlobalPathCache = new Cache(1000, key => IS_GLOBAL_PATH.test(key)); +const hasThisCache = new Cache(1000, key => key.lastIndexOf(HAS_THIS, 0) === 0); +const firstDotIndexCache = new Cache(1000, key => key.indexOf('.')); -var firstKeyCache = new Cache(1000, (path) => { - var index = firstDotIndexCache.get(path); +const firstKeyCache = new Cache(1000, (path) => { + let index = firstDotIndexCache.get(path); if (index === -1) { return path; } else { @@ -29,14 +18,14 @@ var firstKeyCache = new Cache(1000, (path) => { } }); -var tailPathCache = new Cache(1000, (path) => { - var index = firstDotIndexCache.get(path); +const tailPathCache = new Cache(1000, (path) => { + let index = firstDotIndexCache.get(path); if (index !== -1) { return path.slice(index + 1); } }); -export var caches = { +export const caches = { isGlobalCache: isGlobalCache, isGlobalPathCache: isGlobalPathCache, hasThisCache: hasThisCache, diff --git a/packages/ember-metal/lib/properties.js b/packages/ember-metal/lib/properties.js index ca578bf40f6..e7d9d4b12b0 100644 --- a/packages/ember-metal/lib/properties.js +++ b/packages/ember-metal/lib/properties.js @@ -23,7 +23,7 @@ export function Descriptor() { const REDEFINE_SUPPORTED = (function () { // https://github.com/spalger/kibana/commit/b7e35e6737df585585332857a4c397dc206e7ff9 - var a = Object.create(Object.prototype, { + let a = Object.create(Object.prototype, { prop: { configurable: true, value: 1 @@ -70,7 +70,7 @@ export function INHERITING_GETTER_FUNCTION(name) { let val = meta && meta.readInheritedValue('values', name); if (val === UNDEFINED) { - var proto = Object.getPrototypeOf(this); + let proto = Object.getPrototypeOf(this); return proto && proto[name]; } else { return val; @@ -127,12 +127,12 @@ export function INHERITING_GETTER_FUNCTION(name) { become the explicit value of this property. */ export function defineProperty(obj, keyName, desc, data, meta) { - var possibleDesc, existingDesc, watching, value; + let possibleDesc, existingDesc, watching, value; if (!meta) { meta = metaFor(obj); } - var watchEntry = meta.peekWatching(keyName); + let watchEntry = meta.peekWatching(keyName); possibleDesc = obj[keyName]; existingDesc = (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) ? possibleDesc : undefined; diff --git a/packages/ember-metal/lib/property_events.js b/packages/ember-metal/lib/property_events.js index 5f76f07d497..ebd6fa799dc 100644 --- a/packages/ember-metal/lib/property_events.js +++ b/packages/ember-metal/lib/property_events.js @@ -16,9 +16,9 @@ import symbol from 'ember-metal/symbol'; export let PROPERTY_DID_CHANGE = symbol('PROPERTY_DID_CHANGE'); -var beforeObserverSet = new ObserverSet(); -var observerSet = new ObserverSet(); -var deferred = 0; +const beforeObserverSet = new ObserverSet(); +const observerSet = new ObserverSet(); +let deferred = 0; // .......................................................... // PROPERTY CHANGES @@ -41,15 +41,15 @@ var deferred = 0; @private */ function propertyWillChange(obj, keyName) { - var m = peekMeta(obj); + let m = peekMeta(obj); if (m && !m.isInitialized(obj)) { return; } - var watching = m && m.peekWatching(keyName) > 0; - var possibleDesc = obj[keyName]; - var desc = (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) ? possibleDesc : undefined; + let watching = m && m.peekWatching(keyName) > 0; + let possibleDesc = obj[keyName]; + let desc = (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) ? possibleDesc : undefined; if (desc && desc.willChange) { desc.willChange(obj, keyName); @@ -79,15 +79,15 @@ function propertyWillChange(obj, keyName) { @private */ function propertyDidChange(obj, keyName) { - var m = peekMeta(obj); + let m = peekMeta(obj); if (m && !m.isInitialized(obj)) { return; } - var watching = m && m.peekWatching(keyName) > 0; - var possibleDesc = obj[keyName]; - var desc = (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) ? possibleDesc : undefined; + let watching = m && m.peekWatching(keyName) > 0; + let possibleDesc = obj[keyName]; + let desc = (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) ? possibleDesc : undefined; // shouldn't this mean that we're watching this key? if (desc && desc.didChange) { @@ -111,14 +111,14 @@ function propertyDidChange(obj, keyName) { } -var WILL_SEEN, DID_SEEN; +let WILL_SEEN, DID_SEEN; // called whenever a property is about to change to clear the cache of any dependent keys (and notify those properties of changes, etc...) function dependentKeysWillChange(obj, depKey, meta) { if (obj.isDestroying) { return; } if (meta && meta.hasDeps(depKey)) { - var seen = WILL_SEEN; - var top = !seen; + let seen = WILL_SEEN; + let top = !seen; if (top) { seen = WILL_SEEN = {}; @@ -137,8 +137,8 @@ function dependentKeysDidChange(obj, depKey, meta) { if (obj.isDestroying) { return; } if (meta && meta.hasDeps(depKey)) { - var seen = DID_SEEN; - var top = !seen; + let seen = DID_SEEN; + let top = !seen; if (top) { seen = DID_SEEN = {}; @@ -153,9 +153,9 @@ function dependentKeysDidChange(obj, depKey, meta) { } function iterDeps(method, obj, depKey, seen, meta) { - var possibleDesc, desc; - var guid = guidFor(obj); - var current = seen[guid]; + let possibleDesc, desc; + let guid = guidFor(obj); + let current = seen[guid]; if (!current) { current = seen[guid] = {}; @@ -251,8 +251,8 @@ function changeProperties(callback, binding) { function notifyBeforeObservers(obj, keyName) { if (obj.isDestroying) { return; } - var eventName = keyName + ':before'; - var listeners, added; + let eventName = keyName + ':before'; + let listeners, added; if (deferred) { listeners = beforeObserverSet.add(obj, keyName, eventName); added = accumulateListeners(obj, eventName, listeners); @@ -265,8 +265,8 @@ function notifyBeforeObservers(obj, keyName) { function notifyObservers(obj, keyName) { if (obj.isDestroying) { return; } - var eventName = keyName + ':change'; - var listeners; + let eventName = keyName + ':change'; + let listeners; if (deferred) { listeners = observerSet.add(obj, keyName, eventName); accumulateListeners(obj, eventName, listeners); diff --git a/packages/ember-metal/lib/property_get.js b/packages/ember-metal/lib/property_get.js index 37cac051195..8f7884fc31a 100644 --- a/packages/ember-metal/lib/property_get.js +++ b/packages/ember-metal/lib/property_get.js @@ -54,9 +54,9 @@ export function get(obj, keyName) { return obj; } - var value = obj[keyName]; - var desc = (value !== null && typeof value === 'object' && value.isDescriptor) ? value : undefined; - var ret; + let value = obj[keyName]; + let desc = (value !== null && typeof value === 'object' && value.isDescriptor) ? value : undefined; + let ret; if (desc === undefined && isPath(keyName)) { return _getPath(obj, keyName); @@ -120,7 +120,7 @@ function isGettable(obj) { @public */ export function getWithDefault(root, key, defaultValue) { - var value = get(root, key); + let value = get(root, key); if (value === undefined) { return defaultValue; } return value; diff --git a/packages/ember-metal/lib/property_set.js b/packages/ember-metal/lib/property_set.js index 830da339624..4453633b4bc 100644 --- a/packages/ember-metal/lib/property_set.js +++ b/packages/ember-metal/lib/property_set.js @@ -100,13 +100,11 @@ if (isEnabled('mandatory-setter')) { } function setPath(root, path, value, tolerant) { - var keyName; - // get the last part of the path - keyName = path.slice(path.lastIndexOf('.') + 1); + let keyName = path.slice(path.lastIndexOf('.') + 1); // get the first part of the part - path = (path === keyName) ? keyName : path.slice(0, path.length - (keyName.length + 1)); + path = (path === keyName) ? keyName : path.slice(0, path.length - (keyName.length + 1)); // unless the path is this, look up the first part to // get the root diff --git a/packages/ember-metal/lib/replace.js b/packages/ember-metal/lib/replace.js index b3aec54e5d8..5cb3bdb330f 100644 --- a/packages/ember-metal/lib/replace.js +++ b/packages/ember-metal/lib/replace.js @@ -1,13 +1,13 @@ -var splice = Array.prototype.splice; +let { splice } = Array.prototype; export function _replace(array, idx, amt, objects) { - var args = [].concat(objects); - var ret = []; + let args = [].concat(objects); + let ret = []; // https://code.google.com/p/chromium/issues/detail?id=56588 - var size = 60000; - var start = idx; - var ends = amt; - var count, chunk; + let size = 60000; + let start = idx; + let ends = amt; + let count, chunk; while (args.length) { count = ends > size ? size : ends; @@ -28,13 +28,13 @@ export function _replace(array, idx, amt, objects) { Replaces objects in an array with the passed objects. ```javascript - var array = [1,2,3]; + let array = [1,2,3]; Ember.EnumerableUtils.replace(array, 1, 2, [4, 5]); // [1, 4, 5] - var array = [1,2,3]; + let array = [1,2,3]; Ember.EnumerableUtils.replace(array, 1, 1, [4, 5]); // [1, 4, 5, 3] - var array = [1,2,3]; + let array = [1,2,3]; Ember.EnumerableUtils.replace(array, 10, 1, [4, 5]); // [1, 2, 3, 4, 5] ``` diff --git a/packages/ember-metal/lib/run_loop.js b/packages/ember-metal/lib/run_loop.js index 1bcf79d030e..076a25804d5 100644 --- a/packages/ember-metal/lib/run_loop.js +++ b/packages/ember-metal/lib/run_loop.js @@ -30,7 +30,7 @@ const onErrorTarget = { } }; -var backburner = new Backburner(['sync', 'actions', 'destroy'], { +const backburner = new Backburner(['sync', 'actions', 'destroy'], { GUID_KEY: GUID_KEY, sync: { before: beginPropertyChanges, @@ -171,11 +171,7 @@ run.join = function() { @since 1.4.0 @public */ -run.bind = function(...curried) { - return function(...args) { - return run.join(...curried.concat(args)); - }; -}; +run.bind = (...curried) => (...args) => run.join(...curried.concat(args)); run.backburner = backburner; run.currentRunLoop = null; @@ -499,43 +495,43 @@ run.next = function(...args) { `run.throttle()`. ```javascript - var runNext = run.next(myContext, function() { + let runNext = run.next(myContext, function() { // will not be executed }); run.cancel(runNext); - var runLater = run.later(myContext, function() { + let runLater = run.later(myContext, function() { // will not be executed }, 500); run.cancel(runLater); - var runScheduleOnce = run.scheduleOnce('afterRender', myContext, function() { + let runScheduleOnce = run.scheduleOnce('afterRender', myContext, function() { // will not be executed }); run.cancel(runScheduleOnce); - var runOnce = run.once(myContext, function() { + let runOnce = run.once(myContext, function() { // will not be executed }); run.cancel(runOnce); - var throttle = run.throttle(myContext, function() { + let throttle = run.throttle(myContext, function() { // will not be executed }, 1, false); run.cancel(throttle); - var debounce = run.debounce(myContext, function() { + let debounce = run.debounce(myContext, function() { // will not be executed }, 1); run.cancel(debounce); - var debounceImmediate = run.debounce(myContext, function() { + let debounceImmediate = run.debounce(myContext, function() { // will be executed since we passed in true (immediate) }, 100, true); @@ -568,7 +564,7 @@ run.cancel = function(timer) { console.log(this.name + ' ran.'); } - var myContext = { name: 'debounce' }; + let myContext = { name: 'debounce' }; run.debounce(myContext, whoRan, 150); @@ -591,7 +587,7 @@ run.cancel = function(timer) { console.log(this.name + ' ran.'); } - var myContext = { name: 'debounce' }; + let myContext = { name: 'debounce' }; run.debounce(myContext, whoRan, 150, true); @@ -634,7 +630,7 @@ run.debounce = function() { console.log(this.name + ' ran.'); } - var myContext = { name: 'throttle' }; + let myContext = { name: 'throttle' }; run.throttle(myContext, whoRan, 150); // whoRan is invoked with context myContext diff --git a/packages/ember-metal/lib/set_properties.js b/packages/ember-metal/lib/set_properties.js index 3deb7d11b16..cde89f33ae3 100644 --- a/packages/ember-metal/lib/set_properties.js +++ b/packages/ember-metal/lib/set_properties.js @@ -7,7 +7,7 @@ import { set } from 'ember-metal/property_set'; observers will be buffered. ```javascript - var anObject = Ember.Object.create(); + let anObject = Ember.Object.create(); anObject.setProperties({ firstName: 'Stanley', @@ -25,10 +25,10 @@ import { set } from 'ember-metal/property_set'; export default function setProperties(obj, properties) { if (!properties || typeof properties !== 'object') { return properties; } changeProperties(() => { - var props = Object.keys(properties); - var propertyName; + let props = Object.keys(properties); + let propertyName; - for (var i = 0; i < props.length; i++) { + for (let i = 0; i < props.length; i++) { propertyName = props[i]; set(obj, propertyName, properties[propertyName]); diff --git a/packages/ember-metal/lib/tags.js b/packages/ember-metal/lib/tags.js index 5b00d0a973d..eb8b7cab45a 100644 --- a/packages/ember-metal/lib/tags.js +++ b/packages/ember-metal/lib/tags.js @@ -37,7 +37,7 @@ function ensureRunloop() { if (hasGlimmer) { ({ DirtyableTag, CONSTANT_TAG, CURRENT_TAG } = require('glimmer-reference')); - makeTag = function() { return new DirtyableTag(); }; + makeTag = () => new DirtyableTag(); markObjectAsDirty = function(meta) { ensureRunloop(); diff --git a/packages/ember-metal/lib/utils.js b/packages/ember-metal/lib/utils.js index 3aa80fb5055..1ca8cfdbc93 100644 --- a/packages/ember-metal/lib/utils.js +++ b/packages/ember-metal/lib/utils.js @@ -13,7 +13,7 @@ @private @return {Number} the uuid */ -var _uuid = 0; +let _uuid = 0; /** Generates a universally unique identifier. This method @@ -35,11 +35,11 @@ export function uuid() { @type String @final */ -var GUID_PREFIX = 'ember'; +const GUID_PREFIX = 'ember'; // Used for guid generation... -var numberCache = []; -var stringCache = {}; +const numberCache = []; +const stringCache = {}; /** Strongly hint runtimes to intern the provided string. @@ -81,9 +81,9 @@ var stringCache = {}; @return {String} interned version of the provided string */ export function intern(str) { - var obj = {}; + let obj = {}; obj[str] = 1; - for (var key in obj) { + for (let key in obj) { if (key === str) { return key; } @@ -105,23 +105,23 @@ export function intern(str) { @type String @final */ -var GUID_KEY = intern('__ember' + (+ new Date())); +const GUID_KEY = intern('__ember' + (+ new Date())); -export var GUID_DESC = { +export let GUID_DESC = { writable: true, configurable: true, enumerable: false, value: null }; -var nullDescriptor = { +let nullDescriptor = { configurable: true, writable: true, enumerable: false, value: null }; -export var GUID_KEY_PROPERTY = { +export let GUID_KEY_PROPERTY = { name: GUID_KEY, descriptor: nullDescriptor }; @@ -148,7 +148,7 @@ export function generateGuid(obj, prefix) { prefix = GUID_PREFIX; } - var ret = (prefix + uuid()); + let ret = (prefix + uuid()); if (obj) { if (obj[GUID_KEY] === null) { obj[GUID_KEY] = ret; @@ -192,8 +192,8 @@ export function guidFor(obj) { return '(null)'; } - var ret; - var type = typeof obj; + let ret; + let type = typeof obj; // Don't allow prototype changes to String etc. to change the guidFor switch (type) { @@ -298,9 +298,9 @@ export function wrap(func, superFunc) { function _wrap(func, superFunc) { function superWrapper() { - var orig = this._super; + let orig = this._super; this._super = superFunc; - var ret = func.apply(this, arguments); + let ret = func.apply(this, arguments); this._super = orig; return ret; } @@ -317,7 +317,7 @@ function _wrap(func, superFunc) { Checks to see if the `methodName` exists on the `obj`. ```javascript - var foo = { bar: function() { return 'bar'; }, baz: null }; + let foo = { bar: function() { return 'bar'; }, baz: null }; Ember.canInvoke(foo, 'bar'); // true Ember.canInvoke(foo, 'baz'); // false @@ -340,7 +340,7 @@ function canInvoke(obj, methodName) { and if it does, invokes it with the arguments passed. ```javascript - var d = new Date('03/15/2013'); + let d = new Date('03/15/2013'); Ember.tryInvoke(d, 'getTime'); // 1363320000000 Ember.tryInvoke(d, 'setFullYear', [2014]); // 1394856000000 @@ -365,7 +365,7 @@ export function tryInvoke(obj, methodName, args) { // TYPING & ARRAY MESSAGING // -var objectToString = Object.prototype.toString; +const objectToString = Object.prototype.toString; /** Forces the passed object to be part of an array. If the object is already @@ -379,7 +379,7 @@ var objectToString = Object.prototype.toString; Ember.makeArray('lindsay'); // ['lindsay'] Ember.makeArray([1, 2, 42]); // [1, 2, 42] - var controller = Ember.ArrayProxy.create({ content: [] }); + let controller = Ember.ArrayProxy.create({ content: [] }); Ember.makeArray(controller) === controller; // true ``` @@ -420,7 +420,7 @@ export function inspect(obj) { return '[' + obj + ']'; } // for non objects - var type = typeof obj; + let type = typeof obj; if (type !== 'object' && type !== 'symbol') { return '' + obj; } @@ -430,9 +430,9 @@ export function inspect(obj) { } // Object.prototype.toString === {}.toString - var v; - var ret = []; - for (var key in obj) { + let v; + let ret = []; + for (let key in obj) { if (obj.hasOwnProperty(key)) { v = obj[key]; if (v === 'toString') { continue; } // ignore useless items @@ -455,7 +455,7 @@ export function inspect(obj) { @private */ export function applyStr(t, m, a) { - var l = a && a.length; + let l = a && a.length; if (!a || !l) { return t[m](); } switch (l) { case 1: return t[m](a[0]); @@ -497,5 +497,3 @@ export { makeArray, canInvoke }; - - diff --git a/packages/ember-metal/lib/watch_key.js b/packages/ember-metal/lib/watch_key.js index 13f5e3f5612..a49df591c49 100644 --- a/packages/ember-metal/lib/watch_key.js +++ b/packages/ember-metal/lib/watch_key.js @@ -12,14 +12,14 @@ import { lookupDescriptor } from 'ember-metal/utils'; let handleMandatorySetter; export function watchKey(obj, keyName, meta) { - var m = meta || metaFor(obj); + let m = meta || metaFor(obj); // activate watching first time if (!m.peekWatching(keyName)) { m.writeWatching(keyName, 1); - var possibleDesc = obj[keyName]; - var desc = (possibleDesc !== null && + let possibleDesc = obj[keyName]; + let desc = (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) ? possibleDesc : undefined; if (desc && desc.willWatch) { desc.willWatch(obj, keyName); } @@ -52,11 +52,11 @@ if (isEnabled('mandatory-setter')) { // ember strip this entire block out handleMandatorySetter = function handleMandatorySetter(m, obj, keyName) { let descriptor = lookupDescriptor(obj, keyName); - var configurable = descriptor ? descriptor.configurable : true; - var isWritable = descriptor ? descriptor.writable : true; - var hasValue = descriptor ? 'value' in descriptor : true; - var possibleDesc = descriptor && descriptor.value; - var isDescriptor = possibleDesc !== null && + let configurable = descriptor ? descriptor.configurable : true; + let isWritable = descriptor ? descriptor.writable : true; + let hasValue = descriptor ? 'value' in descriptor : true; + let possibleDesc = descriptor && descriptor.value; + let isDescriptor = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor; @@ -86,13 +86,13 @@ if (isEnabled('mandatory-setter')) { import { UNDEFINED } from './meta'; export function unwatchKey(obj, keyName, meta) { - var m = meta || metaFor(obj); + let m = meta || metaFor(obj); let count = m.peekWatching(keyName); if (count === 1) { m.writeWatching(keyName, 0); - var possibleDesc = obj[keyName]; - var desc = (possibleDesc !== null && + let possibleDesc = obj[keyName]; + let desc = (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) ? possibleDesc : undefined; diff --git a/packages/ember-metal/lib/watch_path.js b/packages/ember-metal/lib/watch_path.js index 57903b4aac8..6e7c64dfedb 100644 --- a/packages/ember-metal/lib/watch_path.js +++ b/packages/ember-metal/lib/watch_path.js @@ -15,7 +15,7 @@ export function makeChainNode(obj) { } export function watchPath(obj, keyPath, meta) { - var m = meta || metaFor(obj); + let m = meta || metaFor(obj); let counter = m.peekWatching(keyPath) || 0; if (!counter) { // activate watching first time m.writeWatching(keyPath, 1); @@ -26,7 +26,7 @@ export function watchPath(obj, keyPath, meta) { } export function unwatchPath(obj, keyPath, meta) { - var m = meta || metaFor(obj); + let m = meta || metaFor(obj); let counter = m.peekWatching(keyPath) || 0; if (counter === 1) { diff --git a/packages/ember-metal/lib/watching.js b/packages/ember-metal/lib/watching.js index 5bb60f86a2e..b43d13ec853 100644 --- a/packages/ember-metal/lib/watching.js +++ b/packages/ember-metal/lib/watching.js @@ -45,12 +45,12 @@ function watch(obj, _keyPath, m) { export { watch }; export function isWatching(obj, key) { - var meta = peekMeta(obj); + let meta = peekMeta(obj); return (meta && meta.peekWatching(key)) > 0; } export function watcherCount(obj, key) { - var meta = peekMeta(obj); + let meta = peekMeta(obj); return (meta && meta.peekWatching(key)) || 0; } @@ -62,7 +62,7 @@ export function unwatch(obj, _keyPath, m) { } } -var NODE_STACK = []; +const NODE_STACK = []; /** Tears down the meta on an object so that it can be garbage collected. @@ -75,8 +75,8 @@ var NODE_STACK = []; @private */ export function destroy(obj) { - var meta = peekMeta(obj); - var node, nodes, key, nodeObject; + let meta = peekMeta(obj); + let node, nodes, key, nodeObject; if (meta) { deleteMeta(obj); diff --git a/packages/ember-metal/tests/accessors/get_path_test.js b/packages/ember-metal/tests/accessors/get_path_test.js index 19df6d3f2be..5c349014433 100644 --- a/packages/ember-metal/tests/accessors/get_path_test.js +++ b/packages/ember-metal/tests/accessors/get_path_test.js @@ -1,7 +1,7 @@ import { get } from 'ember-metal/property_get'; -var obj; -var moduleOpts = { +let obj; +const moduleOpts = { setup() { obj = { foo: { diff --git a/packages/ember-metal/tests/accessors/get_properties_test.js b/packages/ember-metal/tests/accessors/get_properties_test.js index 86149c7b480..e354d79acd4 100644 --- a/packages/ember-metal/tests/accessors/get_properties_test.js +++ b/packages/ember-metal/tests/accessors/get_properties_test.js @@ -3,7 +3,7 @@ import getProperties from 'ember-metal/get_properties'; QUnit.module('Ember.getProperties'); QUnit.test('can retrieve a hash of properties from an object via an argument list or array of property names', function() { - var obj = { + let obj = { firstName: 'Steve', lastName: 'Jobs', companyName: 'Apple, Inc.' diff --git a/packages/ember-metal/tests/accessors/get_test.js b/packages/ember-metal/tests/accessors/get_test.js index f628f9b9a4c..773137859d5 100644 --- a/packages/ember-metal/tests/accessors/get_test.js +++ b/packages/ember-metal/tests/accessors/get_test.js @@ -12,7 +12,7 @@ import { addObserver } from 'ember-metal/observer'; QUnit.module('Ember.get'); QUnit.test('should get arbitrary properties on an object', function() { - var obj = { + let obj = { string: 'string', number: 23, boolTrue: true, @@ -20,7 +20,7 @@ QUnit.test('should get arbitrary properties on an object', function() { nullValue: null }; - for (var key in obj) { + for (let key in obj) { if (!obj.hasOwnProperty(key)) { continue; } @@ -29,8 +29,8 @@ QUnit.test('should get arbitrary properties on an object', function() { }); QUnit.test('should not access a property more than once', function() { - var count = 0; - var obj = { + let count = 0; + let obj = { get id() { return ++count; } }; @@ -40,7 +40,7 @@ QUnit.test('should not access a property more than once', function() { }); testBoth('should call unknownProperty on watched values if the value is undefined', function(get, set) { - var obj = { + let obj = { count: 0, unknownProperty(key) { equal(key, 'foo', 'should pass key'); @@ -49,7 +49,7 @@ testBoth('should call unknownProperty on watched values if the value is undefine } }; - var count = 0; + let count = 0; addObserver(obj, 'foo', function() { count++; }); @@ -100,22 +100,12 @@ QUnit.test('warn on attempts to get a property path of null', function() { }); QUnit.test('warn on attempts to use get with an unsupported property path', function() { - var obj = {}; - expectAssertion(function() { - get(obj, null); - }, /The key provided to get must be a string, you passed null/); - expectAssertion(function() { - get(obj, NaN); - }, /The key provided to get must be a string, you passed NaN/); - expectAssertion(function() { - get(obj, undefined); - }, /The key provided to get must be a string, you passed undefined/); - expectAssertion(function() { - get(obj, false); - }, /The key provided to get must be a string, you passed false/); - expectAssertion(function() { - get(obj, 42); - }, /The key provided to get must be a string, you passed 42/); + let obj = {}; + expectAssertion(() => get(obj, null), /The key provided to get must be a string, you passed null/); + expectAssertion(() => get(obj, NaN), /The key provided to get must be a string, you passed NaN/); + expectAssertion(() => get(obj, undefined), /The key provided to get must be a string, you passed undefined/); + expectAssertion(() => get(obj, false), /The key provided to get must be a string, you passed false/); + expectAssertion(() => get(obj, 42), /The key provided to get must be a string, you passed 42/); }); // .......................................................... @@ -123,15 +113,13 @@ QUnit.test('warn on attempts to use get with an unsupported property path', func // QUnit.test('(regression) watched properties on unmodified inherited objects should still return their original value', function() { - var MyMixin = Mixin.create({ + let MyMixin = Mixin.create({ someProperty: 'foo', - propertyDidChange: observer('someProperty', function() { - // NOTHING TO DO - }) + propertyDidChange: observer('someProperty', () => {}) }); - var baseObject = MyMixin.apply({}); - var theRealObject = Object.create(baseObject); + let baseObject = MyMixin.apply({}); + let theRealObject = Object.create(baseObject); equal(get(theRealObject, 'someProperty'), 'foo', 'should return the set value, not false'); }); @@ -139,7 +127,7 @@ QUnit.test('(regression) watched properties on unmodified inherited objects shou QUnit.module('Ember.getWithDefault'); QUnit.test('should get arbitrary properties on an object', function() { - var obj = { + let obj = { string: 'string', number: 23, boolTrue: true, @@ -147,7 +135,7 @@ QUnit.test('should get arbitrary properties on an object', function() { nullValue: null }; - for (var key in obj) { + for (let key in obj) { if (!obj.hasOwnProperty(key)) { continue; } @@ -163,7 +151,7 @@ QUnit.test('should get arbitrary properties on an object', function() { }); QUnit.test('should call unknownProperty if defined and value is undefined', function() { - var obj = { + let obj = { count: 0, unknownProperty(key) { equal(key, 'foo', 'should pass key'); @@ -177,7 +165,7 @@ QUnit.test('should call unknownProperty if defined and value is undefined', func }); testBoth('if unknownProperty is present, it is called', function(get, set) { - var obj = { + let obj = { count: 0, unknownProperty(key) { if (key === 'foo') { @@ -188,10 +176,8 @@ testBoth('if unknownProperty is present, it is called', function(get, set) { } }; - var count = 0; - addObserver(obj, 'foo', function() { - count++; - }); + let count = 0; + addObserver(obj, 'foo', () => count++); equal(getWithDefault(obj, 'foo', 'fail'), 'FOO', 'should return value from unknownProperty'); equal(getWithDefault(obj, 'bar', 'default'), 'default', 'should convert undefined from unknownProperty into default'); @@ -202,15 +188,13 @@ testBoth('if unknownProperty is present, it is called', function(get, set) { // QUnit.test('(regression) watched properties on unmodified inherited objects should still return their original value', function() { - var MyMixin = Mixin.create({ + let MyMixin = Mixin.create({ someProperty: 'foo', - propertyDidChange: observer('someProperty', function() { - // NOTHING TO DO - }) + propertyDidChange: observer('someProperty', () => { /* nothing to do */}) }); - var baseObject = MyMixin.apply({}); - var theRealObject = Object.create(baseObject); + let baseObject = MyMixin.apply({}); + let theRealObject = Object.create(baseObject); equal(getWithDefault(theRealObject, 'someProperty', 'fail'), 'foo', 'should return the set value, not false'); }); diff --git a/packages/ember-metal/tests/accessors/mandatory_setters_test.js b/packages/ember-metal/tests/accessors/mandatory_setters_test.js index cf7144e7dfd..fc14da9bb0f 100644 --- a/packages/ember-metal/tests/accessors/mandatory_setters_test.js +++ b/packages/ember-metal/tests/accessors/mandatory_setters_test.js @@ -20,7 +20,7 @@ function hasMetaValue(object, property) { if (isEnabled('mandatory-setter')) { QUnit.test('does not assert if property is not being watched', function() { - var obj = { + let obj = { someProp: null, toString() { return 'custom-object'; @@ -34,7 +34,7 @@ if (isEnabled('mandatory-setter')) { QUnit.test('should not setup mandatory-setter if property is not writable', function() { expect(6); - var obj = { }; + let obj = { }; Object.defineProperty(obj, 'a', { value: true }); Object.defineProperty(obj, 'b', { value: false }); @@ -61,7 +61,7 @@ if (isEnabled('mandatory-setter')) { QUnit.test('should not teardown non mandatory-setter descriptor', function() { expect(1); - var obj = { get a() { return 'hi'; } }; + let obj = { get a() { return 'hi'; } }; watch(obj, 'a'); unwatch(obj, 'a'); @@ -72,7 +72,7 @@ if (isEnabled('mandatory-setter')) { QUnit.test('should not confuse non descriptor watched gets', function() { expect(2); - var obj = { get a() { return 'hi'; } }; + let obj = { get a() { return 'hi'; } }; watch(obj, 'a'); equal(get(obj, 'a'), 'hi'); @@ -82,7 +82,7 @@ if (isEnabled('mandatory-setter')) { QUnit.test('should not setup mandatory-setter if setter is already setup on property', function() { expect(2); - var obj = { someProp: null }; + let obj = { someProp: null }; Object.defineProperty(obj, 'someProp', { get() { @@ -130,7 +130,7 @@ if (isEnabled('mandatory-setter')) { } }); - var obj = new Foo(); + let obj = new Foo(); watch(obj, 'someProp'); ok(!hasMandatorySetter(obj, 'someProp'), 'mandatory-setter should not be installed'); @@ -157,7 +157,7 @@ if (isEnabled('mandatory-setter')) { Bar.prototype = Object.create(Foo.prototype); Bar.prototype.constructor = Bar; - var obj = new Bar(); + let obj = new Bar(); watch(obj, 'someProp'); ok(!hasMandatorySetter(obj, 'someProp'), 'mandatory-setter should not be installed'); @@ -188,7 +188,7 @@ if (isEnabled('mandatory-setter')) { Qux.prototype = Object.create(Bar.prototype); Qux.prototype.constructor = Qux; - var obj = new Qux(); + let obj = new Qux(); watch(obj, 'someProp'); ok(!hasMandatorySetter(obj, 'someProp'), 'mandatory-setter should not be installed'); @@ -197,7 +197,7 @@ if (isEnabled('mandatory-setter')) { }); QUnit.test('should assert if set without Ember.set when property is being watched', function() { - var obj = { + let obj = { someProp: null, toString() { return 'custom-object'; @@ -212,7 +212,7 @@ if (isEnabled('mandatory-setter')) { }); QUnit.test('should not assert if set with Ember.set when property is being watched', function() { - var obj = { + let obj = { someProp: null, toString() { return 'custom-object'; @@ -226,7 +226,7 @@ if (isEnabled('mandatory-setter')) { }); QUnit.test('does not setup mandatory-setter if non-configurable', function() { - var obj = { + let obj = { someProp: null, toString() { return 'custom-object'; @@ -244,7 +244,7 @@ if (isEnabled('mandatory-setter')) { }); QUnit.test('ensure after watch the property is restored (and the value is no-longer stored in meta) [non-enumerable]', function() { - var obj = { + let obj = { someProp: null, toString() { return 'custom-object'; @@ -296,7 +296,7 @@ if (isEnabled('mandatory-setter')) { }); QUnit.test('ensure after watch the property is restored (and the value is no-longer stored in meta) [enumerable]', function() { - var obj = { + let obj = { someProp: null, toString() { return 'custom-object'; @@ -349,14 +349,14 @@ if (isEnabled('mandatory-setter')) { QUnit.test('sets up mandatory-setter if property comes from prototype', function() { expect(2); - var obj = { + let obj = { someProp: null, toString() { return 'custom-object'; } }; - var obj2 = Object.create(obj); + let obj2 = Object.create(obj); watch(obj2, 'someProp'); @@ -371,7 +371,7 @@ if (isEnabled('mandatory-setter')) { function Parent() {} Parent.prototype.food = 'chips'; - var child = new Parent(); + let child = new Parent(); equal(child.food , 'chips'); diff --git a/packages/ember-metal/tests/accessors/set_path_test.js b/packages/ember-metal/tests/accessors/set_path_test.js index fa32cc09de8..cfaa5fd17a0 100644 --- a/packages/ember-metal/tests/accessors/set_path_test.js +++ b/packages/ember-metal/tests/accessors/set_path_test.js @@ -5,7 +5,7 @@ import { get } from 'ember-metal/property_get'; let originalLookup = context.lookup; let lookup; -var obj; +let obj; function commonSetup() { context.lookup = lookup = {}; obj = { @@ -58,7 +58,7 @@ QUnit.module('set with path - deprecated', { }); QUnit.test('[obj, bla.bla] gives a proper exception message', function() { - var 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 or was destroyed.'; try { set(obj, 'bla.bla', 'BAM'); } catch(ex) { @@ -67,9 +67,7 @@ QUnit.test('[obj, bla.bla] gives a proper exception message', function() { }); QUnit.test('[obj, foo.baz.bat] -> EXCEPTION', function() { - throws(function() { - set(obj, 'foo.baz.bat', 'BAM'); - }, Error); + throws(() => set(obj, 'foo.baz.bat', 'BAM')); }); QUnit.test('[obj, foo.baz.bat] -> EXCEPTION', function() { diff --git a/packages/ember-metal/tests/accessors/set_test.js b/packages/ember-metal/tests/accessors/set_test.js index a87e993e1de..491ed79c862 100644 --- a/packages/ember-metal/tests/accessors/set_test.js +++ b/packages/ember-metal/tests/accessors/set_test.js @@ -4,7 +4,7 @@ import { set } from 'ember-metal/property_set'; QUnit.module('set'); QUnit.test('should set arbitrary properties on an object', function() { - var obj = { + let obj = { string: 'string', number: 23, boolTrue: true, @@ -13,11 +13,11 @@ QUnit.test('should set arbitrary properties on an object', function() { undefinedValue: undefined }; - var newObj = { + let newObj = { undefinedValue: 'emberjs' }; - for (var key in obj) { + for (let key in obj) { if (!obj.hasOwnProperty(key)) { continue; } @@ -28,7 +28,7 @@ QUnit.test('should set arbitrary properties on an object', function() { }); QUnit.test('should call setUnknownProperty if defined and value is undefined', function() { - var obj = { + let obj = { count: 0, unknownProperty(key, value) { @@ -48,40 +48,24 @@ QUnit.test('should call setUnknownProperty if defined and value is undefined', f }); QUnit.test('warn on attempts to call set with undefined as object', function() { - expectAssertion(function() { - set(undefined, 'aProperty', 'BAM'); - }, /Cannot call set with 'aProperty' on an undefined object./); + expectAssertion(() => set(undefined, 'aProperty', 'BAM'), /Cannot call set with 'aProperty' on an undefined object./); }); QUnit.test('warn on attempts to call set with null as object', function() { - expectAssertion(function() { - set(null, 'aProperty', 'BAM'); - }, /Cannot call set with 'aProperty' on an undefined object./); + expectAssertion(() => set(null, 'aProperty', 'BAM'), /Cannot call set with 'aProperty' on an undefined object./); }); QUnit.test('warn on attempts to use set with an unsupported property path', function() { - var obj = {}; - expectAssertion(function() { - set(obj, null, 42); - }, /The key provided to set must be a string, you passed null/); - expectAssertion(function() { - set(obj, NaN, 42); - }, /The key provided to set must be a string, you passed NaN/); - expectAssertion(function() { - set(obj, undefined, 42); - }, /The key provided to set must be a string, you passed undefined/); - expectAssertion(function() { - set(obj, false, 42); - }, /The key provided to set must be a string, you passed false/); - expectAssertion(function() { - set(obj, 42, 42); - }, /The key provided to set must be a string, you passed 42/); + let obj = {}; + expectAssertion(() => set(obj, null, 42), /The key provided to set must be a string, you passed null/); + expectAssertion(() => set(obj, NaN, 42), /The key provided to set must be a string, you passed NaN/); + expectAssertion(() => set(obj, undefined, 42), /The key provided to set must be a string, you passed undefined/); + expectAssertion(() => set(obj, false, 42), /The key provided to set must be a string, you passed false/); + expectAssertion(() => set(obj, 42, 42), /The key provided to set must be a string, you passed 42/); }); QUnit.test('warn on attempts of calling set on a destroyed object', function() { let obj = { isDestroyed: true }; - expectAssertion(function() { - set(obj, 'favoriteFood', 'hot dogs'); - }, 'calling set on destroyed object: [object Object].favoriteFood = hot dogs'); + expectAssertion(() => set(obj, 'favoriteFood', 'hot dogs'), 'calling set on destroyed object: [object Object].favoriteFood = hot dogs'); }); diff --git a/packages/ember-metal/tests/alias_test.js b/packages/ember-metal/tests/alias_test.js index 062eaf609be..6e900648363 100644 --- a/packages/ember-metal/tests/alias_test.js +++ b/packages/ember-metal/tests/alias_test.js @@ -6,7 +6,7 @@ import { meta } from 'ember-metal/meta'; import { isWatching } from 'ember-metal/watching'; import { addObserver, removeObserver } from 'ember-metal/observer'; -var obj, count; +let obj, count; QUnit.module('ember-metal/alias', { setup() { @@ -35,7 +35,7 @@ QUnit.test('should proxy set to alt key', function() { QUnit.test('basic lifecycle', function() { defineProperty(obj, 'bar', alias('foo.faz')); - var m = meta(obj); + let m = meta(obj); addObserver(obj, 'bar', incrementCount); equal(m.peekDeps('foo.faz', 'bar'), 1); removeObserver(obj, 'bar', incrementCount); @@ -43,7 +43,7 @@ QUnit.test('basic lifecycle', function() { }); QUnit.test('old dependent keys should not trigger property changes', function() { - var obj1 = Object.create(null); + let obj1 = Object.create(null); defineProperty(obj1, 'foo', null, null); defineProperty(obj1, 'bar', alias('foo')); defineProperty(obj1, 'baz', alias('foo')); @@ -60,13 +60,13 @@ QUnit.test('old dependent keys should not trigger property changes', function() }); QUnit.test('overridden dependent keys should not trigger property changes', function() { - var obj1 = Object.create(null); + let obj1 = Object.create(null); defineProperty(obj1, 'foo', null, null); defineProperty(obj1, 'bar', alias('foo')); defineProperty(obj1, 'baz', alias('foo')); addObserver(obj1, 'baz', incrementCount); - var obj2 = Object.create(obj1); + let obj2 = Object.create(obj1); defineProperty(obj2, 'baz', alias('bar')); // override baz set(obj2, 'foo', 'FOO'); @@ -95,7 +95,5 @@ QUnit.test('immediately sets up dependencies if already being watched', function }); QUnit.test('setting alias on self should fail assertion', function() { - expectAssertion(function() { - defineProperty(obj, 'bar', alias('bar')); - }, 'Setting alias \'bar\' on self'); + expectAssertion(() => defineProperty(obj, 'bar', alias('bar')), 'Setting alias \'bar\' on self'); }); diff --git a/packages/ember-metal/tests/assign_test.js b/packages/ember-metal/tests/assign_test.js index dece1a6f1c0..5a632e768cd 100644 --- a/packages/ember-metal/tests/assign_test.js +++ b/packages/ember-metal/tests/assign_test.js @@ -3,10 +3,10 @@ import assign from 'ember-metal/assign'; QUnit.module('Ember.assign'); QUnit.test('Ember.assign', function() { - var a = { a: 1 }; - var b = { b: 2 }; - var c = { c: 3 }; - var a2 = { a: 4 }; + let a = { a: 1 }; + let b = { b: 2 }; + let c = { c: 3 }; + let a2 = { a: 4 }; assign(a, b, c, a2); diff --git a/packages/ember-metal/tests/binding/connect_test.js b/packages/ember-metal/tests/binding/connect_test.js index b56288ac679..dfdff96a265 100644 --- a/packages/ember-metal/tests/binding/connect_test.js +++ b/packages/ember-metal/tests/binding/connect_test.js @@ -10,7 +10,7 @@ import { get } from 'ember-metal/property_get'; function performTest(binding, a, b, get, set, connect) { if (connect === undefined) { - connect = function() {binding.connect(a);}; + connect = () => binding.connect(a); } ok(!run.currentRunLoop, 'performTest should not have a currentRunLoop'); @@ -24,18 +24,14 @@ function performTest(binding, a, b, get, set, connect) { equal(get(b, 'bar'), 'BAR', 'b should have changed'); // // make sure changes sync both ways - run(function () { - set(b, 'bar', 'BAZZ'); - }); + run(() => set(b, 'bar', 'BAZZ')); equal(get(a, 'foo'), 'BAZZ', 'a should have changed'); - run(function () { - set(a, 'foo', 'BARF'); - }); + run(() => set(a, 'foo', 'BARF')); equal(get(b, 'bar'), 'BARF', 'a should have changed'); } -var originalLookup, lookup, GlobalB; +let originalLookup, lookup, GlobalB; QUnit.module('Ember.Binding', { setup() { @@ -49,10 +45,10 @@ QUnit.module('Ember.Binding', { }); testBoth('Connecting a binding between two properties', function(get, set) { - var a = { foo: 'FOO', bar: 'BAR' }; + let a = { foo: 'FOO', bar: 'BAR' }; // a.bar -> a.foo - var binding = new Binding('foo', 'bar'); + let binding = new Binding('foo', 'bar'); let deprecationMessage = '`Ember.Binding` is deprecated. Consider using an' + ' `alias` computed property instead.'; @@ -62,12 +58,11 @@ testBoth('Connecting a binding between two properties', function(get, set) { }, deprecationMessage); }); -testBoth('Connecting a oneWay binding raises a deprecation', - function(get, set) { - var a = { foo: 'FOO', bar: 'BAR' }; +testBoth('Connecting a oneWay binding raises a deprecation', function(get, set) { + let a = { foo: 'FOO', bar: 'BAR' }; // a.bar -> a.foo - var binding = new Binding('foo', 'bar').oneWay(); + let binding = new Binding('foo', 'bar').oneWay(); let deprecationMessage = '`Ember.Binding` is deprecated. Since you' + ' are using a `oneWay` binding consider using a `readOnly` computed' + @@ -77,11 +72,11 @@ testBoth('Connecting a oneWay binding raises a deprecation', }); testBoth('Connecting a binding between two objects', function(get, set) { - var b = { bar: 'BAR' }; - var a = { foo: 'FOO', b: b }; + let b = { bar: 'BAR' }; + let a = { foo: 'FOO', b: b }; // b.bar -> a.foo - var binding = new Binding('foo', 'b.bar'); + let binding = new Binding('foo', 'b.bar'); let deprecationMessage = '`Ember.Binding` is deprecated. Consider using an' + ' `alias` computed property instead.'; @@ -92,15 +87,15 @@ testBoth('Connecting a binding between two objects', function(get, set) { }); testBoth('Connecting a binding to path', function(get, set) { - var a = { foo: 'FOO' }; + let a = { foo: 'FOO' }; lookup['GlobalB'] = GlobalB = { b: { bar: 'BAR' } }; - var b = get(GlobalB, 'b'); + let b = get(GlobalB, 'b'); // globalB.b.bar -> a.foo - var binding = new Binding('foo', 'GlobalB.b.bar'); + let binding = new Binding('foo', 'GlobalB.b.bar'); let deprecationMessage = '`Ember.Binding` is deprecated. Since you' + ' are binding to a global consider using a service instead.'; @@ -112,25 +107,23 @@ testBoth('Connecting a binding to path', function(get, set) { // make sure modifications update b = { bar: 'BIFF' }; - run(function() { - set(GlobalB, 'b', b); - }); + run(() => set(GlobalB, 'b', b)); equal(get(a, 'foo'), 'BIFF', 'a should have changed'); }); testBoth('Calling connect more than once', function(get, set) { - var b = { bar: 'BAR' }; - var a = { foo: 'FOO', b: b }; + let b = { bar: 'BAR' }; + let a = { foo: 'FOO', b: b }; // b.bar -> a.foo - var binding = new Binding('foo', 'b.bar'); + let binding = new Binding('foo', 'b.bar'); let deprecationMessage = '`Ember.Binding` is deprecated. Consider using an' + ' `alias` computed property instead.'; expectDeprecation(() => { - performTest(binding, a, b, get, set, function () { + performTest(binding, a, b, get, set, () => { binding.connect(a); binding.connect(a); }); @@ -138,16 +131,16 @@ testBoth('Calling connect more than once', function(get, set) { }); QUnit.test('inherited bindings should sync on create', function() { - var a; - run(function () { - var A = function() { + let a; + run(() => { + function A() { bind(this, 'foo', 'bar.baz'); - }; + } let deprecationMessage = '`Ember.Binding` is deprecated. Consider using an' + ' `alias` computed property instead.'; - expectDeprecation(() => { a = new A(); }, deprecationMessage); + expectDeprecation(() => a = new A(), deprecationMessage); set(a, 'bar', { baz: 'BAZ' }); }); diff --git a/packages/ember-metal/tests/binding/sync_test.js b/packages/ember-metal/tests/binding/sync_test.js index adb04149fad..860e3d33d0d 100644 --- a/packages/ember-metal/tests/binding/sync_test.js +++ b/packages/ember-metal/tests/binding/sync_test.js @@ -11,19 +11,19 @@ import { propertyWillChange, propertyDidChange } from 'ember-metal/property_even QUnit.module('system/binding/sync_test.js'); testBoth('bindings should not sync twice in a single run loop', function(get, set) { - var a, b, setValue; - var setCalled = 0; - var getCalled = 0; + let a, b, setValue; + let setCalled = 0; + let getCalled = 0; - run(function() { + run(() => { a = {}; defineProperty(a, 'foo', computed({ - get: function(key) { + get(key) { getCalled++; return setValue; }, - set: function(key, value) { + set(key, value) { setCalled++; propertyWillChange(this, key); setValue = value; @@ -39,15 +39,13 @@ testBoth('bindings should not sync twice in a single run loop', function(get, se let deprecationMessage = '`Ember.Binding` is deprecated. Consider' + ' using an `alias` computed property instead.'; - expectDeprecation(() => { - bind(b, 'foo', 'a.foo'); - }, deprecationMessage); + expectDeprecation(() => bind(b, 'foo', 'a.foo'), deprecationMessage); }); // reset after initial binding synchronization getCalled = 0; - run(function() { + run(() => { set(a, 'foo', 'trollface'); }); @@ -57,10 +55,10 @@ testBoth('bindings should not sync twice in a single run loop', function(get, se }); testBoth('bindings should not infinite loop if computed properties return objects', function(get, set) { - var a, b; - var getCalled = 0; + let a, b; + let getCalled = 0; - run(function() { + run(() => { a = {}; defineProperty(a, 'foo', computed(function() { @@ -78,9 +76,7 @@ testBoth('bindings should not infinite loop if computed properties return object let deprecationMessage = '`Ember.Binding` is deprecated. Consider' + ' using an `alias` computed property instead.'; - expectDeprecation(() => { - bind(b, 'foo', 'a.foo'); - }, deprecationMessage); + expectDeprecation(() => bind(b, 'foo', 'a.foo'), deprecationMessage); }); deepEqual(get(b, 'foo'), ['foo', 'bar'], 'the binding should sync'); @@ -88,9 +84,9 @@ testBoth('bindings should not infinite loop if computed properties return object }); testBoth('bindings should do the right thing when observers trigger bindings in the opposite direction', function(get, set) { - var a, b, c; + let a, b, c; - run(function() { + run(() => { a = { foo: 'trololol' }; @@ -102,9 +98,7 @@ testBoth('bindings should do the right thing when observers trigger bindings in let deprecationMessage = '`Ember.Binding` is deprecated. Consider' + ' using an `alias` computed property instead.'; - expectDeprecation(() => { - bind(b, 'foo', 'a.foo'); - }, deprecationMessage); + expectDeprecation(() => bind(b, 'foo', 'a.foo'), deprecationMessage); c = { a: a @@ -115,21 +109,17 @@ testBoth('bindings should do the right thing when observers trigger bindings in }, deprecationMessage); }); - addObserver(b, 'foo', function() { - set(c, 'foo', 'what is going on'); - }); + addObserver(b, 'foo', () => set(c, 'foo', 'what is going on')); - run(function() { - set(a, 'foo', 'trollface'); - }); + run(() => set(a, 'foo', 'trollface')); equal(get(a, 'foo'), 'what is going on'); }); testBoth('bindings should not try to sync destroyed objects', function(get, set) { - var a, b; + let a, b; - run(function() { + run(() => { a = { foo: 'trololol' }; @@ -141,18 +131,16 @@ testBoth('bindings should not try to sync destroyed objects', function(get, set) let deprecationMessage = '`Ember.Binding` is deprecated. Consider' + ' using an `alias` computed property instead.'; - expectDeprecation(() => { - bind(b, 'foo', 'a.foo'); - }, deprecationMessage); + expectDeprecation(() => bind(b, 'foo', 'a.foo'), deprecationMessage); }); - run(function() { + run(() => { set(a, 'foo', 'trollface'); set(b, 'isDestroyed', true); ok(true, 'should not raise'); }); - run(function() { + run(() => { a = { foo: 'trololol' }; @@ -164,12 +152,10 @@ testBoth('bindings should not try to sync destroyed objects', function(get, set) let deprecationMessage = '`Ember.Binding` is deprecated. Consider' + ' using an `alias` computed property instead.'; - expectDeprecation(() => { - bind(b, 'foo', 'a.foo'); - }, deprecationMessage); + expectDeprecation(() => bind(b, 'foo', 'a.foo'), deprecationMessage); }); - run(function() { + run(() => { set(b, 'foo', 'trollface'); set(a, 'isDestroyed', true); ok(true, 'should not raise'); diff --git a/packages/ember-metal/tests/cache_test.js b/packages/ember-metal/tests/cache_test.js index 53ec4af9e02..17c502dd1a2 100644 --- a/packages/ember-metal/tests/cache_test.js +++ b/packages/ember-metal/tests/cache_test.js @@ -3,9 +3,7 @@ import Cache from 'ember-metal/cache'; QUnit.module('Cache'); QUnit.test('basic', function() { - var cache = new Cache(100, function(key) { - return key.toUpperCase(); - }); + let cache = new Cache(100, key => key.toUpperCase()); equal(cache.get('foo'), 'FOO'); equal(cache.get('bar'), 'BAR'); @@ -13,8 +11,8 @@ QUnit.test('basic', function() { }); QUnit.test('caches computation correctly', function() { - var count = 0; - var cache = new Cache(100, function(key) { + let count = 0; + let cache = new Cache(100, key => { count++; return key.toUpperCase(); }); @@ -31,15 +29,13 @@ QUnit.test('caches computation correctly', function() { }); QUnit.test('handles undefined value correctly', function() { - var cache = new Cache(100, function(key) {}); + let cache = new Cache(100, (key) => { }); equal(cache.get('foo'), undefined); }); QUnit.test('continues working after reaching cache limit', function() { - var cache = new Cache(3, function(key) { - return key.toUpperCase(); - }); + let cache = new Cache(3, key => key.toUpperCase()); cache.get('a'); cache.get('b'); diff --git a/packages/ember-metal/tests/chains_test.js b/packages/ember-metal/tests/chains_test.js index 7e637e13424..5258bbc5c90 100644 --- a/packages/ember-metal/tests/chains_test.js +++ b/packages/ember-metal/tests/chains_test.js @@ -11,17 +11,17 @@ QUnit.module('Chains'); QUnit.test('finishChains should properly copy chains from prototypes to instances', function() { function didChange() {} - var obj = {}; + let obj = {}; addObserver(obj, 'foo.bar', null, didChange); - var childObj = Object.create(obj); + let childObj = Object.create(obj); finishChains(childObj); ok(peekMeta(obj) !== peekMeta(childObj).readableChains(), 'The chains object is copied'); }); QUnit.test('observer and CP chains', function() { - var obj = { }; + let obj = { }; defineProperty(obj, 'foo', computed('qux.[]', function() { })); defineProperty(obj, 'qux', computed(function() { })); @@ -45,7 +45,6 @@ QUnit.test('observer and CP chains', function() { observer CP(foo, 'qux.[]') */ - // invalidate qux propertyDidChange(obj, 'qux'); diff --git a/packages/ember-metal/tests/computed_test.js b/packages/ember-metal/tests/computed_test.js index 0fb4c92456c..d989132226c 100644 --- a/packages/ember-metal/tests/computed_test.js +++ b/packages/ember-metal/tests/computed_test.js @@ -18,7 +18,7 @@ import { _addBeforeObserver } from 'ember-metal/observer'; -var obj, count; +let obj, count; QUnit.module('computed'); @@ -50,8 +50,8 @@ QUnit.test('computed properties defined with an object only allow `get` and `set QUnit.test('defining computed property should invoke property on get', function() { - var obj = {}; - var count = 0; + let obj = {}; + let count = 0; defineProperty(obj, 'foo', computed(function(key) { count++; return 'computed ' + key; @@ -62,11 +62,11 @@ QUnit.test('defining computed property should invoke property on get', function( }); QUnit.test('defining computed property should invoke property on set', function() { - var obj = {}; - var count = 0; + let obj = {}; + let count = 0; defineProperty(obj, 'foo', computed({ - get: function(key) { return this['__' + key]; }, - set: function(key, value) { + get(key) { return this['__' + key]; }, + set(key, value) { count++; this['__' + key] = 'computed ' + value; return this['__' + key]; @@ -79,7 +79,7 @@ QUnit.test('defining computed property should invoke property on set', function( }); QUnit.test('defining a computed property with a dependent key ending with @each is expanded to []', function() { - var cp = computed('blazo.@each', function() { }); + let cp = computed('blazo.@each', function() { }); deepEqual(cp._dependentKeys, ['blazo.[]']); @@ -110,15 +110,15 @@ QUnit.test('defining a computed property with a dependent key more than one leve }, warning); }); -var objA, objB; +let objA, objB; QUnit.module('computed should inherit through prototype', { setup() { objA = { __foo: 'FOO' }; defineProperty(objA, 'foo', computed({ - get: function(key) { + get(key) { return this['__' + key]; }, - set: function(key, value) { + set(key, value) { this['__' + key] = 'computed ' + value; return this['__' + key]; } @@ -154,10 +154,10 @@ QUnit.module('redefining computed property to normal', { setup() { objA = { __foo: 'FOO' }; defineProperty(objA, 'foo', computed({ - get: function(key) { + get(key) { return this['__' + key]; }, - set: function(key, value) { + set(key, value) { this['__' + key] = 'computed ' + value; return this['__' + key]; } @@ -193,10 +193,10 @@ QUnit.module('redefining computed property to another property', { setup() { objA = { __foo: 'FOO' }; defineProperty(objA, 'foo', computed({ - get: function(key) { + get(key) { return this['__' + key]; }, - set: function(key, value) { + set(key, value) { this['__' + key] = 'A ' + value; return this['__' + key]; } @@ -205,8 +205,8 @@ QUnit.module('redefining computed property to another property', { objB = Object.create(objA); objB.__foo = 'FOO'; defineProperty(objB, 'foo', computed({ - get: function(key) { return this['__' + key]; }, - set: function(key, value) { + get(key) { return this['__' + key]; }, + set(key, value) { this['__' + key] = 'B ' + value; return this['__' + key]; } @@ -238,14 +238,14 @@ testBoth('using get() and set()', function(get, set) { QUnit.module('computed - metadata'); QUnit.test('can set metadata on a computed property', function() { - var computedProperty = computed(function() { }); + let computedProperty = computed(function() { }); computedProperty.meta({ key: 'keyValue' }); equal(computedProperty.meta().key, 'keyValue', 'saves passed meta hash to the _meta property'); }); QUnit.test('meta should return an empty hash if no meta is set', function() { - var computedProperty = computed(function() { }); + let computedProperty = computed(function() { }); deepEqual(computedProperty.meta(), {}, 'returned value is an empty hash'); }); @@ -257,7 +257,7 @@ QUnit.module('computed - cacheable', { setup() { obj = {}; count = 0; - var func = function(key, value) { + let func = function(key, value) { count++; return 'bar ' + count; }; @@ -285,7 +285,7 @@ testBoth('modifying a cacheable property should update cache', function(get, set }); testBoth('inherited property should not pick up cache', function(get, set) { - var objB = Object.create(obj); + let objB = Object.create(obj); equal(get(obj, 'foo'), 'bar 1', 'obj first get'); equal(get(objB, 'foo'), 'bar 2', 'objB first get'); @@ -319,15 +319,15 @@ testBoth('cacheFor should return falsy cached values', function(get, set) { }); testBoth('setting a cached computed property passes the old value as the third argument', function(get, set) { - var obj = { + let obj = { foo: 0 }; - var receivedOldValue; + let receivedOldValue; defineProperty(obj, 'plusOne', computed({ - get: function() {}, - set: function(key, value, oldValue) { + get() {}, + set(key, value, oldValue) { receivedOldValue = oldValue; return value; } }).property('foo') @@ -351,7 +351,7 @@ QUnit.module('computed - dependentkey', { setup() { obj = { bar: 'baz' }; count = 0; - var getterAndSetter = function(key, value) { + let getterAndSetter = function(key, value) { count++; get(this, 'bar'); return 'bar ' + count; @@ -392,7 +392,7 @@ testBoth('local dependent key should invalidate cache', function(get, set) { }); testBoth('should invalidate multiple nested dependent keys', function(get, set) { - var count = 0; + let count = 0; defineProperty(obj, 'bar', computed(function() { count++; get(this, 'baz'); @@ -417,7 +417,7 @@ testBoth('should invalidate multiple nested dependent keys', function(get, set) }); testBoth('circular keys should not blow up', function(get, set) { - var func = function(key, value) { + let func = function(key, value) { count++; return 'bar ' + count; }; @@ -495,8 +495,8 @@ testBoth('throws assertion if brace expansion notation has spaces', function (ge // -var func; -var moduleOpts = { +let func; +let moduleOpts = { setup() { obj = { foo: { @@ -579,7 +579,7 @@ testBoth('chained dependent keys should evaluate computed properties lazily', fu QUnit.module('computed - improved cp syntax'); QUnit.test('setter and getters are passed using an object', function() { - var testObj = EmberObject.extend({ + let testObj = EmberObject.extend({ a: '1', b: '2', aInt: computed('a', { @@ -604,7 +604,7 @@ QUnit.test('setter and getters are passed using an object', function() { }); QUnit.test('setter can be omited', function() { - var testObj = EmberObject.extend({ + let testObj = EmberObject.extend({ a: '1', b: '2', aInt: computed('a', { @@ -622,7 +622,7 @@ QUnit.test('setter can be omited', function() { }); QUnit.test('the return value of the setter gets cached', function() { - var testObj = EmberObject.extend({ + let testObj = EmberObject.extend({ a: '1', sampleCP: computed('a', { get(keyName) { @@ -646,11 +646,11 @@ QUnit.test('the return value of the setter gets cached', function() { QUnit.module('computed edge cases'); QUnit.test('adding a computed property should show up in key iteration', function() { - var obj = {}; + let obj = {}; defineProperty(obj, 'foo', computed(function() {})); - var found = []; - for (var key in obj) { + let found = []; + for (let key in obj) { found.push(key); } ok(found.indexOf('foo')>=0, 'should find computed property in iteration found=' + found); @@ -658,12 +658,12 @@ QUnit.test('adding a computed property should show up in key iteration', functio }); testBoth('when setting a value after it had been retrieved empty don\'t pass function UNDEFINED as oldValue', function(get, set) { - var obj = {}; - var oldValueIsNoFunction = true; + let obj = {}; + let oldValueIsNoFunction = true; defineProperty(obj, 'foo', computed({ - get: function() { }, - set: function(key, value, oldValue) { + get() { }, + set(key, value, oldValue) { if (typeof oldValue === 'function') { oldValueIsNoFunction = false; } @@ -680,26 +680,26 @@ testBoth('when setting a value after it had been retrieved empty don\'t pass fun QUnit.module('computed - setter'); testBoth('setting a watched computed property', function(get, set) { - var obj = { + let obj = { firstName: 'Yehuda', lastName: 'Katz' }; defineProperty(obj, 'fullName', computed({ - get: function() { return get(this, 'firstName') + ' ' + get(this, 'lastName'); }, - set: function(key, value) { - var values = value.split(' '); + get() { return get(this, 'firstName') + ' ' + get(this, 'lastName'); }, + set(key, value) { + let values = value.split(' '); set(this, 'firstName', values[0]); set(this, 'lastName', values[1]); return value; } }).property('firstName', 'lastName') ); - var fullNameWillChange = 0; - var fullNameDidChange = 0; - var firstNameWillChange = 0; - var firstNameDidChange = 0; - var lastNameWillChange = 0; - var lastNameDidChange = 0; + let fullNameWillChange = 0; + let fullNameDidChange = 0; + let firstNameWillChange = 0; + let firstNameDidChange = 0; + let lastNameWillChange = 0; + let lastNameDidChange = 0; _addBeforeObserver(obj, 'fullName', function () { fullNameWillChange++; }); @@ -738,19 +738,19 @@ testBoth('setting a watched computed property', function(get, set) { }); testBoth('setting a cached computed property that modifies the value you give it', function(get, set) { - var obj = { + let obj = { foo: 0 }; defineProperty(obj, 'plusOne', computed({ - get: function(key) { return get(this, 'foo') + 1; }, - set: function(key, value) { + get(key) { return get(this, 'foo') + 1; }, + set(key, value) { set(this, 'foo', value); return value + 1; } }).property('foo') ); - var plusOneWillChange = 0; - var plusOneDidChange = 0; + let plusOneWillChange = 0; + let plusOneDidChange = 0; _addBeforeObserver(obj, 'plusOne', function () { plusOneWillChange++; }); @@ -777,16 +777,14 @@ testBoth('setting a cached computed property that modifies the value you give it QUnit.module('computed - default setter'); testBoth('when setting a value on a computed property that doesn\'t handle sets', function(get, set) { - var obj = {}; - var observerFired = false; + let obj = {}; + let observerFired = false; defineProperty(obj, 'foo', computed(function() { return 'foo'; })); - addObserver(obj, 'foo', null, function() { - observerFired = true; - }); + addObserver(obj, 'foo', null, () => observerFired = true); set(obj, 'foo', 'bar'); @@ -798,23 +796,23 @@ testBoth('when setting a value on a computed property that doesn\'t handle sets' QUnit.module('computed - readOnly'); QUnit.test('is chainable', function() { - var cp = computed(function() {}).readOnly(); + let cp = computed(function() {}).readOnly(); ok(cp instanceof Descriptor); ok(cp instanceof ComputedProperty); }); QUnit.test('throws assertion if called over a CP with a setter defined with the new syntax', function() { - expectAssertion(function() { + expectAssertion(() => { computed({ - get: function() { }, - set: function() { } + get() { }, + set() { } }).readOnly(); }, /Computed properties that define a setter using the new syntax cannot be read-only/); }); testBoth('protects against setting', function(get, set) { - var obj = { }; + let obj = { }; defineProperty(obj, 'bar', computed(function(key) { return 'barValue'; @@ -822,7 +820,7 @@ testBoth('protects against setting', function(get, set) { equal(get(obj, 'bar'), 'barValue'); - throws(function() { + throws(() => { set(obj, 'bar', 'newBar'); }, /Cannot set read\-only property "bar" on object:/ ); diff --git a/packages/ember-metal/tests/core/inspect_test.js b/packages/ember-metal/tests/core/inspect_test.js index 595a0444904..cd6ceb12ebf 100644 --- a/packages/ember-metal/tests/core/inspect_test.js +++ b/packages/ember-metal/tests/core/inspect_test.js @@ -33,7 +33,7 @@ QUnit.test('object', function() { }); QUnit.test('objects without a prototype', function() { - var prototypelessObj = Object.create(null); + let prototypelessObj = Object.create(null); equal(inspect({ foo: prototypelessObj }), '{foo: [object Object]}'); }); @@ -46,7 +46,7 @@ QUnit.test('regexp', function() { }); QUnit.test('date', function() { - var inspected = inspect(new Date('Sat Apr 30 2011 13:24:11')); + let inspected = inspect(new Date('Sat Apr 30 2011 13:24:11')); ok(inspected.match(/Sat Apr 30/), 'The inspected date has its date'); ok(inspected.match(/2011/), 'The inspected date has its year'); ok(inspected.match(/13:24:11/), 'The inspected date has its time'); diff --git a/packages/ember-metal/tests/error_test.js b/packages/ember-metal/tests/error_test.js index 9524f8bb743..cd7cdf9c5c8 100644 --- a/packages/ember-metal/tests/error_test.js +++ b/packages/ember-metal/tests/error_test.js @@ -3,9 +3,7 @@ import EmberError from 'ember-metal/error'; QUnit.module('Ember Error Throwing'); QUnit.test('new Ember.Error displays provided message', function() { - throws(function() { + throws(() => { throw new EmberError('A Message'); - }, function(e) { - return e.message === 'A Message'; - }, 'the assigned message was displayed'); + }, e => e.message === 'A Message', 'the assigned message was displayed'); }); diff --git a/packages/ember-metal/tests/events_test.js b/packages/ember-metal/tests/events_test.js index 567632c45a4..cd7998cdfde 100644 --- a/packages/ember-metal/tests/events_test.js +++ b/packages/ember-metal/tests/events_test.js @@ -15,9 +15,10 @@ import { QUnit.module('system/props/events_test'); QUnit.test('listener should receive event - removing should remove', function() { - var obj = {}; - var count = 0; - var F = function() { count++; }; + let obj = {}; + let count = 0; + + function F() { count++; } addListener(obj, 'event!', F); equal(count, 0, 'nothing yet'); @@ -33,13 +34,13 @@ QUnit.test('listener should receive event - removing should remove', function() }); QUnit.test('listeners should be inherited', function() { - var obj = {}; - var count = 0; - var F = function() { count++; }; + let obj = {}; + let count = 0; + let F = function() { count++; }; addListener(obj, 'event!', F); - var obj2 = Object.create(obj); + let obj2 = Object.create(obj); equal(count, 0, 'nothing yet'); @@ -58,9 +59,9 @@ QUnit.test('listeners should be inherited', function() { QUnit.test('adding a listener more than once should only invoke once', function() { - var obj = {}; - var count = 0; - var F = function() { count++; }; + let obj = {}; + let count = 0; + function F() { count++; } addListener(obj, 'event!', F); addListener(obj, 'event!', F); @@ -69,8 +70,8 @@ QUnit.test('adding a listener more than once should only invoke once', function( }); QUnit.test('adding a listener with a target should invoke with target', function() { - var obj = {}; - var target; + let obj = {}; + let target; target = { count: 0, @@ -83,8 +84,8 @@ QUnit.test('adding a listener with a target should invoke with target', function }); QUnit.test('suspending a listener should not invoke during callback', function() { - var obj = {}; - var target, otherTarget; + let obj = {}; + let target, otherTarget; target = { count: 0, @@ -119,8 +120,8 @@ QUnit.test('suspending a listener should not invoke during callback', function() }); QUnit.test('adding a listener with string method should lookup method on event delivery', function() { - var obj = {}; - var target; + let obj = {}; + let target; target = { count: 0, @@ -137,8 +138,8 @@ QUnit.test('adding a listener with string method should lookup method on event d }); QUnit.test('calling sendEvent with extra params should be passed to listeners', function() { - var obj = {}; - var params = null; + let obj = {}; + let params = null; addListener(obj, 'event!', function() { params = Array.prototype.slice.call(arguments); }); @@ -148,9 +149,10 @@ QUnit.test('calling sendEvent with extra params should be passed to listeners', }); QUnit.test('hasListeners tells you if there are listeners for a given event', function() { - var obj = {}; - var F = function() {}; - var F2 = function() {}; + let obj = {}; + + function F() {} + function F2() {} equal(hasListeners(obj, 'event!'), false, 'no listeners at first'); @@ -170,9 +172,9 @@ QUnit.test('hasListeners tells you if there are listeners for a given event', fu }); QUnit.test('calling removeListener without method should remove all listeners', function() { - var obj = {}; - var F = function() {}; - var F2 = function() {}; + let obj = {}; + function F() {} + function F2() {} equal(hasListeners(obj, 'event!'), false, 'no listeners at first'); @@ -186,8 +188,8 @@ QUnit.test('calling removeListener without method should remove all listeners', }); QUnit.test('while suspended, it should not be possible to add a duplicate listener', function() { - var obj = {}; - var target; + let obj = {}; + let target; target = { count: 0, @@ -218,8 +220,8 @@ QUnit.test('while suspended, it should not be possible to add a duplicate listen }); QUnit.test('a listener can be added as part of a mixin', function() { - var triggered = 0; - var MyMixin = Mixin.create({ + let triggered = 0; + let MyMixin = Mixin.create({ foo1: on('bar', function() { triggered++; }), @@ -229,7 +231,7 @@ QUnit.test('a listener can be added as part of a mixin', function() { }) }); - var obj = {}; + let obj = {}; MyMixin.apply(obj); sendEvent(obj, 'bar'); @@ -237,19 +239,19 @@ QUnit.test('a listener can be added as part of a mixin', function() { }); QUnit.test('a listener added as part of a mixin may be overridden', function() { - var triggered = 0; - var FirstMixin = Mixin.create({ + let triggered = 0; + let FirstMixin = Mixin.create({ foo: on('bar', function() { triggered++; }) }); - var SecondMixin = Mixin.create({ + let SecondMixin = Mixin.create({ foo: on('baz', function() { triggered++; }) }); - var obj = {}; + let obj = {}; FirstMixin.apply(obj); SecondMixin.apply(obj); @@ -261,7 +263,7 @@ QUnit.test('a listener added as part of a mixin may be overridden', function() { }); QUnit.test('DEPRECATED: adding didInitAttrs as a listener is deprecated', function() { - var obj = Component.create(); + let obj = Component.create(); expectDeprecation(() => { addListener(obj, 'didInitAttrs'); diff --git a/packages/ember-metal/tests/expand_properties_test.js b/packages/ember-metal/tests/expand_properties_test.js index 9b4adaadd24..a082e17fc9f 100644 --- a/packages/ember-metal/tests/expand_properties_test.js +++ b/packages/ember-metal/tests/expand_properties_test.js @@ -1,6 +1,6 @@ import expandProperties from 'ember-metal/expand_properties'; -var foundProperties = []; +let foundProperties = []; function addProperty(property) { foundProperties.push(property); @@ -36,7 +36,7 @@ QUnit.test('A property with only a brace expansion expands correctly', function( expandProperties('{a,b,c}', addProperty); - var expected = ['a', 'b', 'c']; + let expected = ['a', 'b', 'c']; deepEqual(expected.sort(), foundProperties.sort()); }); @@ -53,7 +53,7 @@ QUnit.test('A single brace expansion expands correctly', function() { expandProperties('a.{b,c,d}.e', addProperty); - var expected = ['a.b.e', 'a.c.e', 'a.d.e']; + let expected = ['a.b.e', 'a.c.e', 'a.d.e']; deepEqual(expected.sort(), foundProperties.sort()); }); @@ -62,7 +62,7 @@ QUnit.test('Multiple brace expansions work correctly', function() { expandProperties('{a,b,c}.d.{e,f}.g', addProperty); - var expected = ['a.d.e.g', 'a.d.f.g', 'b.d.e.g', 'b.d.f.g', 'c.d.e.g', 'c.d.f.g']; + let expected = ['a.d.e.g', 'a.d.f.g', 'b.d.e.g', 'b.d.f.g', 'c.d.e.g', 'c.d.f.g']; deepEqual(expected.sort(), foundProperties.sort()); }); @@ -71,14 +71,14 @@ QUnit.test('A property with only brace expansions expands correctly', function() expandProperties('{a,b,c}.{d}.{e,f}', addProperty); - var expected = ['a.d.e', 'a.d.f', 'b.d.e', 'b.d.f', 'c.d.e', 'c.d.f']; + let expected = ['a.d.e', 'a.d.f', 'b.d.e', 'b.d.f', 'c.d.e', 'c.d.f']; deepEqual(expected.sort(), foundProperties.sort()); }); QUnit.test('A pattern must be a string', function() { expect(1); - expectAssertion(function() { + expectAssertion(() => { expandProperties([], addProperty); }, /A computed property key must be a string/); }); @@ -86,7 +86,7 @@ QUnit.test('A pattern must be a string', function() { QUnit.test('A pattern must not contain a space', function() { expect(1); - expectAssertion(function() { + expectAssertion(() => { expandProperties('a, b', addProperty); }, /Brace expanded properties cannot contain spaces, e.g. "user.{firstName, lastName}" should be "user.{firstName,lastName}"/); }); diff --git a/packages/ember-metal/tests/injected_property_test.js b/packages/ember-metal/tests/injected_property_test.js index a91befcc01a..44d3704450f 100644 --- a/packages/ember-metal/tests/injected_property_test.js +++ b/packages/ember-metal/tests/injected_property_test.js @@ -14,7 +14,7 @@ QUnit.test('injected properties should be descriptors', function() { }); QUnit.test('injected properties should be overridable', function() { - var obj = {}; + let obj = {}; defineProperty(obj, 'foo', new InjectedProperty()); set(obj, 'foo', 'bar'); @@ -23,7 +23,7 @@ QUnit.test('injected properties should be overridable', function() { }); QUnit.test('getting on an object without an owner or container should fail assertion', function() { - var obj = {}; + let obj = {}; defineProperty(obj, 'foo', new InjectedProperty('type', 'name')); expectAssertion(function() { @@ -32,7 +32,7 @@ QUnit.test('getting on an object without an owner or container should fail asser }); QUnit.test('getting on an object without an owner but with a container should not fail', function() { - var obj = { + let obj = { container: { lookup(key) { ok(true, 'should call container.lookup'); @@ -49,7 +49,7 @@ QUnit.test('getting on an object without an owner but with a container should no QUnit.test('getting should return a lookup on the container', function() { expect(2); - var obj = {}; + let obj = {}; setOwner(obj, { lookup(key) { @@ -64,7 +64,7 @@ QUnit.test('getting should return a lookup on the container', function() { }); QUnit.test('omitting the lookup name should default to the property name', function() { - var obj = {}; + let obj = {}; setOwner(obj, { lookup(key) { diff --git a/packages/ember-metal/tests/instrumentation_test.js b/packages/ember-metal/tests/instrumentation_test.js index 229407a1db6..e232c2402aa 100644 --- a/packages/ember-metal/tests/instrumentation_test.js +++ b/packages/ember-metal/tests/instrumentation_test.js @@ -12,7 +12,7 @@ QUnit.module('Ember Instrumentation', { }); QUnit.test('execute block even if no listeners', function() { - var result = instrument('render', {}, function() { + let result = instrument('render', {}, function() { return 'hello'; }); equal(result, 'hello', 'called block'); @@ -21,8 +21,8 @@ QUnit.test('execute block even if no listeners', function() { QUnit.test('subscribing to a simple path receives the listener', function() { expect(12); - var sentPayload = {}; - var count = 0; + let sentPayload = {}; + let count = 0; subscribe('render', { before(name, timestamp, payload) { @@ -58,8 +58,8 @@ QUnit.test('subscribing to a simple path receives the listener', function() { QUnit.test('returning a value from the before callback passes it to the after callback', function() { expect(2); - var passthru1 = {}; - var passthru2 = {}; + let passthru1 = {}; + let passthru2 = {}; subscribe('render', { before(name, timestamp, payload) { @@ -98,7 +98,7 @@ QUnit.test('instrument with 2 args (name, callback) no payload', function() { QUnit.test('instrument with 3 args (name, callback, binding) no payload', function() { expect(2); - var binding = {}; + let binding = {}; subscribe('render', { before(name, timestamp, payload) { deepEqual(payload, {}); @@ -115,7 +115,7 @@ QUnit.test('instrument with 3 args (name, callback, binding) no payload', functi QUnit.test('instrument with 3 args (name, payload, callback) with payload', function() { expect(1); - var expectedPayload = { hi: 1 }; + let expectedPayload = { hi: 1 }; subscribe('render', { before(name, timestamp, payload) { deepEqual(payload, expectedPayload); @@ -129,8 +129,8 @@ QUnit.test('instrument with 3 args (name, payload, callback) with payload', func QUnit.test('instrument with 4 args (name, payload, callback, binding) with payload', function() { expect(2); - var expectedPayload = { hi: 1 }; - var binding = {}; + let expectedPayload = { hi: 1 }; + let binding = {}; subscribe('render', { before(name, timestamp, payload) { deepEqual(payload, expectedPayload); @@ -147,7 +147,7 @@ QUnit.test('instrument with 4 args (name, payload, callback, binding) with paylo QUnit.test('raising an exception in the instrumentation attaches it to the payload', function() { expect(2); - var error = new Error('Instrumentation'); + let error = new Error('Instrumentation'); subscribe('render', { before() {}, @@ -186,9 +186,9 @@ QUnit.test('it is possible to add a new subscriber after the first instrument', QUnit.test('it is possible to remove a subscriber', function() { expect(4); - var count = 0; + let count = 0; - var subscriber = subscribe('render', { + let subscriber = subscribe('render', { before() { equal(count, 0); ok(true, 'Before callback was called'); diff --git a/packages/ember-metal/tests/is_blank_test.js b/packages/ember-metal/tests/is_blank_test.js index e5cc9370389..5a609b6f4a0 100644 --- a/packages/ember-metal/tests/is_blank_test.js +++ b/packages/ember-metal/tests/is_blank_test.js @@ -3,9 +3,9 @@ import isBlank from 'ember-metal/is_blank'; QUnit.module('Ember.isBlank'); QUnit.test('Ember.isBlank', function() { - var string = 'string'; - var fn = function() {}; - var object = { length: 0 }; + let string = 'string'; + let fn = function() {}; + let object = { length: 0 }; equal(true, isBlank(null), 'for null'); equal(true, isBlank(undefined), 'for undefined'); diff --git a/packages/ember-metal/tests/is_empty_test.js b/packages/ember-metal/tests/is_empty_test.js index 8a2046ed633..58ba00a0237 100644 --- a/packages/ember-metal/tests/is_empty_test.js +++ b/packages/ember-metal/tests/is_empty_test.js @@ -7,9 +7,9 @@ import { QUnit.module('Ember.isEmpty'); QUnit.test('Ember.isEmpty', function() { - var string = 'string'; - var fn = function() {}; - var object = { length: 0 }; + let string = 'string'; + let fn = function() {}; + let object = { length: 0 }; equal(true, isEmpty(null), 'for null'); equal(true, isEmpty(undefined), 'for undefined'); @@ -27,14 +27,14 @@ QUnit.test('Ember.isEmpty', function() { }); QUnit.test('Ember.isEmpty Ember.Map', function() { - var map = new Map(); + let map = new Map(); equal(true, isEmpty(map), 'Empty map is empty'); map.set('foo', 'bar'); equal(false, isEmpty(map), 'Map is not empty'); }); QUnit.test('Ember.isEmpty Ember.OrderedSet', function() { - var orderedSet = new OrderedSet(); + let orderedSet = new OrderedSet(); equal(true, isEmpty(orderedSet), 'Empty ordered set is empty'); orderedSet.add('foo'); equal(false, isEmpty(orderedSet), 'Ordered set is not empty'); diff --git a/packages/ember-metal/tests/is_none_test.js b/packages/ember-metal/tests/is_none_test.js index 7f8498daf86..b962cc18103 100644 --- a/packages/ember-metal/tests/is_none_test.js +++ b/packages/ember-metal/tests/is_none_test.js @@ -3,8 +3,8 @@ import isNone from 'ember-metal/is_none'; QUnit.module('Ember.isNone'); QUnit.test('Ember.isNone', function() { - var string = 'string'; - var fn = function() {}; + let string = 'string'; + let fn = function() {}; equal(true, isNone(null), 'for null'); equal(true, isNone(undefined), 'for undefined'); diff --git a/packages/ember-metal/tests/is_present_test.js b/packages/ember-metal/tests/is_present_test.js index d68c70f702a..fd4d8a9fdac 100644 --- a/packages/ember-metal/tests/is_present_test.js +++ b/packages/ember-metal/tests/is_present_test.js @@ -3,9 +3,9 @@ import isPresent from 'ember-metal/is_present'; QUnit.module('Ember.isPresent'); QUnit.test('Ember.isPresent', function() { - var string = 'string'; - var fn = function() {}; - var object = { length: 0 }; + let string = 'string'; + let fn = function() {}; + let object = { length: 0 }; equal(false, isPresent(), 'for no params'); equal(false, isPresent(null), 'for null'); diff --git a/packages/ember-metal/tests/libraries_test.js b/packages/ember-metal/tests/libraries_test.js index 284b5bd78a5..5354968c860 100644 --- a/packages/ember-metal/tests/libraries_test.js +++ b/packages/ember-metal/tests/libraries_test.js @@ -3,7 +3,7 @@ import { getDebugFunction, setDebugFunction } from 'ember-metal/debug'; import isEnabled from 'ember-metal/features'; import { Libraries } from 'ember-metal/libraries'; -var libs, registry; +let libs, registry; let originalWarn = getDebugFunction('warn'); QUnit.module('Libraries registry', { diff --git a/packages/ember-metal/tests/main_test.js b/packages/ember-metal/tests/main_test.js index cfa2fad322a..d92830a4b05 100644 --- a/packages/ember-metal/tests/main_test.js +++ b/packages/ember-metal/tests/main_test.js @@ -1,12 +1,12 @@ import Ember from 'ember-metal'; // testing reexports // From sindresourhus/semver-regex https://github.com/sindresorhus/semver-regex/blob/795b05628d96597ebcbe6d31ef4a432858365582/index.js#L3 -var SEMVER_REGEX = /^\bv?(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?\b$/; +const SEMVER_REGEX = /^\bv?(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?\b$/; QUnit.module('ember-metal/core/main'); QUnit.test('Ember registers itself', function() { - var lib = Ember.libraries._registry[0]; + let lib = Ember.libraries._registry[0]; equal(lib.name, 'Ember'); equal(lib.version, Ember.VERSION); diff --git a/packages/ember-metal/tests/map_test.js b/packages/ember-metal/tests/map_test.js index e75c6c3cbee..93d2850d46d 100644 --- a/packages/ember-metal/tests/map_test.js +++ b/packages/ember-metal/tests/map_test.js @@ -4,8 +4,8 @@ import { OrderedSet } from 'ember-metal/map'; -var object, number, string, map, variety; -var varieties = [['Map', Map], ['MapWithDefault', MapWithDefault]]; +let object, number, string, map, variety; +const varieties = [['Map', Map], ['MapWithDefault', MapWithDefault]]; function testMap(nameAndFunc) { variety = nameAndFunc[0]; @@ -20,10 +20,10 @@ function testMap(nameAndFunc) { } }); - var mapHasLength = function(expected, theMap) { + let mapHasLength = function(expected, theMap) { theMap = theMap || map; - var length = 0; + let length = 0; theMap.forEach(function() { length++; }); @@ -31,10 +31,10 @@ function testMap(nameAndFunc) { equal(length, expected, 'map should contain ' + expected + ' items'); }; - var mapHasEntries = function(entries, theMap) { + let mapHasEntries = function(entries, theMap) { theMap = theMap || map; - for (var i = 0; i < entries.length; i++) { + for (let i = 0; i < entries.length; i++) { equal(theMap.get(entries[i][0]), entries[i][1]); equal(theMap.has(entries[i][0]), true); } @@ -42,7 +42,7 @@ function testMap(nameAndFunc) { mapHasLength(entries.length, theMap); }; - var unboundThis; + let unboundThis; (function() { unboundThis = this; @@ -146,7 +146,7 @@ function testMap(nameAndFunc) { map.set(number, 'winning'); map.set(string, 'winning'); - var map2 = map.copy(); + let map2 = map.copy(); map2.set(object, 'losing'); map2.set(number, 'losing'); @@ -170,7 +170,7 @@ function testMap(nameAndFunc) { map.set(number, 'winning'); map.set(string, 'winning'); - var map2 = map.copy(); + let map2 = map.copy(); map2.delete(object); map2.delete(number); @@ -202,7 +202,7 @@ function testMap(nameAndFunc) { equal(map.size, 2); //Check copy - var copy = map.copy(); + let copy = map.copy(); equal(copy.size, 2); //Remove a key twice @@ -250,16 +250,16 @@ function testMap(nameAndFunc) { map.set('b', 2); map.set('c', 3); - var iteration = 0; + let iteration = 0; - var expectations = [ + let expectations = [ { value: 1, key: 'a', context: unboundThis }, { value: 2, key: 'b', context: unboundThis }, { value: 3, key: 'c', context: unboundThis } ]; map.forEach(function(value, key, theMap) { - var expectation = expectations[iteration]; + let expectation = expectations[iteration]; equal(value, expectation.value, 'value should be correct'); equal(key, expectation.key, 'key should be correct'); @@ -277,16 +277,16 @@ function testMap(nameAndFunc) { map.set('b', 2); map.set('c', 3); - var iteration = 0; - var context = {}; - var expectations = [ + let iteration = 0; + let context = {}; + let expectations = [ { value: 1, key: 'a', context: context }, { value: 2, key: 'b', context: context }, { value: 3, key: 'c', context: context } ]; map.forEach(function(value, key, theMap) { - var expectation = expectations[iteration]; + let expectation = expectations[iteration]; equal(value, expectation.value, 'value should be correct'); equal(key, expectation.key, 'key should be correct'); @@ -304,9 +304,9 @@ function testMap(nameAndFunc) { map.set('b', 2); map.set('c', 3); - var iteration = 0; + let iteration = 0; - var expectations = [ + let expectations = [ { value: 1, key: 'a', context: unboundThis }, { value: 2, key: 'b', context: unboundThis } ]; @@ -316,7 +316,7 @@ function testMap(nameAndFunc) { map.delete('c'); } - var expectation = expectations[iteration]; + let expectation = expectations[iteration]; equal(value, expectation.value, 'value should be correct'); equal(key, expectation.key, 'key should be correct'); @@ -334,9 +334,9 @@ function testMap(nameAndFunc) { map.set('b', 2); map.set('c', 3); - var iteration = 0; + let iteration = 0; - var expectations = [ + let expectations = [ { value: 1, key: 'a', context: unboundThis }, { value: 2, key: 'b', context: unboundThis }, { value: 3, key: 'c', context: unboundThis }, @@ -348,7 +348,7 @@ function testMap(nameAndFunc) { map.set('d', 4); } - var expectation = expectations[iteration]; + let expectation = expectations[iteration]; equal(value, expectation.value, 'value should be correct'); equal(key, expectation.key, 'key should be correct'); @@ -362,7 +362,7 @@ function testMap(nameAndFunc) { }); QUnit.test('clear', function() { - var iterations = 0; + let iterations = 0; map.set('a', 1); map.set('b', 2); @@ -414,7 +414,7 @@ function testMap(nameAndFunc) { QUnit.test('NaN Boxed', function() { //jshint -W053 - var boxed = new Number(NaN); + let boxed = new Number(NaN); equal(map.has(boxed), false); map.set(boxed, 'not-a-number'); @@ -427,7 +427,7 @@ function testMap(nameAndFunc) { }); QUnit.test('0 value', function() { - var obj = {}; + let obj = {}; equal(map.has(obj), false); equal(map.size, 0); @@ -444,39 +444,39 @@ function testMap(nameAndFunc) { }); } -for (var i = 0; i < varieties.length; i++) { +for (let i = 0; i < varieties.length; i++) { testMap(varieties[i]); } QUnit.module('MapWithDefault - default values'); QUnit.test('Retrieving a value that has not been set returns and sets a default value', function() { - var map = MapWithDefault.create({ + let map = MapWithDefault.create({ defaultValue(key) { return [key]; } }); - var value = map.get('ohai'); + let value = map.get('ohai'); deepEqual(value, ['ohai']); strictEqual(value, map.get('ohai')); }); QUnit.test('Map.prototype.constructor', function() { - var map = new Map(); + let map = new Map(); equal(map.constructor, Map); }); QUnit.test('MapWithDefault.prototype.constructor', function() { - var map = new MapWithDefault({ + let map = new MapWithDefault({ defaultValue(key) { return key; } }); equal(map.constructor, MapWithDefault); }); QUnit.test('Copying a MapWithDefault copies the default value', function() { - var map = MapWithDefault.create({ + let map = MapWithDefault.create({ defaultValue(key) { return [key]; } @@ -485,7 +485,7 @@ QUnit.test('Copying a MapWithDefault copies the default value', function() { map.set('ohai', 1); map.get('bai'); - var map2 = map.copy(); + let map2 = map.copy(); equal(map2.get('ohai'), 1); deepEqual(map2.get('bai'), ['bai']); @@ -497,9 +497,7 @@ QUnit.test('Copying a MapWithDefault copies the default value', function() { deepEqual(map2.get('default'), ['default']); - map2.defaultValue = function(key) { - return ['tom is on', key]; - }; + map2.defaultValue = key => ['tom is on', key]; deepEqual(map2.get('drugs'), ['tom is on', 'drugs']); }); @@ -515,7 +513,7 @@ QUnit.module('OrderedSet', { }); QUnit.test('add returns the set', function() { - var obj = {}; + let obj = {}; equal(map.add(obj), map); equal(map.add(obj), map, 'when it is already in the set'); }); diff --git a/packages/ember-metal/tests/meta_test.js b/packages/ember-metal/tests/meta_test.js index a047c4dbcb2..9ba10a850df 100644 --- a/packages/ember-metal/tests/meta_test.js +++ b/packages/ember-metal/tests/meta_test.js @@ -5,7 +5,7 @@ import { QUnit.module('Ember.meta'); QUnit.test('should return the same hash for an object', function() { - var obj = {}; + let obj = {}; meta(obj).foo = 'bar'; @@ -13,7 +13,7 @@ QUnit.test('should return the same hash for an object', function() { }); QUnit.test('meta is not enumerable', function () { - var proto, obj, props, prop; + let proto, obj, props, prop; proto = { foo: 'bar' }; meta(proto); obj = Object.create(proto); diff --git a/packages/ember-metal/tests/mixin/alias_method_test.js b/packages/ember-metal/tests/mixin/alias_method_test.js index e0a90110a42..c68bfd32e25 100644 --- a/packages/ember-metal/tests/mixin/alias_method_test.js +++ b/packages/ember-metal/tests/mixin/alias_method_test.js @@ -13,63 +13,63 @@ function validateAliasMethod(obj) { } QUnit.test('methods of another name are aliased when the mixin is applied', function() { - var MyMixin = Mixin.create({ + let MyMixin = Mixin.create({ fooMethod() { return 'FOO'; }, barMethod: aliasMethod('fooMethod') }); - var obj = MyMixin.apply({}); + let obj = MyMixin.apply({}); validateAliasMethod(obj); }); QUnit.test('should follow aliasMethods all the way down', function() { - var MyMixin = Mixin.create({ + let MyMixin = Mixin.create({ bar: aliasMethod('foo'), // put first to break ordered iteration baz() { return 'baz'; }, foo: aliasMethod('baz') }); - var obj = MyMixin.apply({}); + let obj = MyMixin.apply({}); equal(get(obj, 'bar')(), 'baz', 'should have followed aliasMethods'); }); QUnit.test('should alias methods from other dependent mixins', function() { - var BaseMixin = Mixin.create({ + let BaseMixin = Mixin.create({ fooMethod() { return 'FOO'; } }); - var MyMixin = Mixin.create(BaseMixin, { + let MyMixin = Mixin.create(BaseMixin, { barMethod: aliasMethod('fooMethod') }); - var obj = MyMixin.apply({}); + let obj = MyMixin.apply({}); validateAliasMethod(obj); }); QUnit.test('should alias methods from other mixins applied at same time', function() { - var BaseMixin = Mixin.create({ + let BaseMixin = Mixin.create({ fooMethod() { return 'FOO'; } }); - var MyMixin = Mixin.create({ + let MyMixin = Mixin.create({ barMethod: aliasMethod('fooMethod') }); - var obj = mixin({}, BaseMixin, MyMixin); + let obj = mixin({}, BaseMixin, MyMixin); validateAliasMethod(obj); }); QUnit.test('should alias methods from mixins already applied on object', function() { - var BaseMixin = Mixin.create({ + let BaseMixin = Mixin.create({ quxMethod() { return 'qux'; } }); - var MyMixin = Mixin.create({ + let MyMixin = Mixin.create({ bar: aliasMethod('foo'), barMethod: aliasMethod('fooMethod') }); - var obj = { + let obj = { fooMethod() { return 'FOO'; } }; diff --git a/packages/ember-metal/tests/mixin/apply_test.js b/packages/ember-metal/tests/mixin/apply_test.js index b84d318df6a..f8ccc3e98b0 100644 --- a/packages/ember-metal/tests/mixin/apply_test.js +++ b/packages/ember-metal/tests/mixin/apply_test.js @@ -9,8 +9,8 @@ QUnit.module('Ember.Mixin.apply'); function K() {} QUnit.test('using apply() should apply properties', function() { - var MixinA = Mixin.create({ foo: 'FOO', baz: K }); - var obj = {}; + let MixinA = Mixin.create({ foo: 'FOO', baz: K }); + let obj = {}; mixin(obj, MixinA); equal(get(obj, 'foo'), 'FOO', 'should apply foo'); @@ -18,7 +18,7 @@ QUnit.test('using apply() should apply properties', function() { }); QUnit.test('applying anonymous properties', function() { - var obj = {}; + let obj = {}; mixin(obj, { foo: 'FOO', baz: K @@ -29,13 +29,11 @@ QUnit.test('applying anonymous properties', function() { }); QUnit.test('applying null values', function() { - expectAssertion(function() { - mixin({}, null); - }); + expectAssertion(() => mixin({}, null)); }); QUnit.test('applying a property with an undefined value', function() { - var obj = { tagName: '' }; + let obj = { tagName: '' }; mixin(obj, { tagName: undefined }); strictEqual(get(obj, 'tagName'), ''); diff --git a/packages/ember-metal/tests/mixin/computed_test.js b/packages/ember-metal/tests/mixin/computed_test.js index ddefadef44e..e8ca56474ba 100644 --- a/packages/ember-metal/tests/mixin/computed_test.js +++ b/packages/ember-metal/tests/mixin/computed_test.js @@ -9,8 +9,8 @@ function K() { return this; } QUnit.module('Mixin Computed Properties'); QUnit.test('overriding computed properties', function() { - var MixinA, MixinB, MixinC, MixinD; - var obj; + let MixinA, MixinB, MixinC, MixinD; + let obj; MixinA = Mixin.create({ aProp: computed(function() { @@ -59,23 +59,23 @@ QUnit.test('overriding computed properties', function() { }); QUnit.test('calling set on overridden computed properties', function() { - var SuperMixin, SubMixin; - var obj; + let SuperMixin, SubMixin; + let obj; - var superGetOccurred = false; - var superSetOccurred = false; + let superGetOccurred = false; + let superSetOccurred = false; SuperMixin = Mixin.create({ aProp: computed({ - get: function(key) { superGetOccurred = true; }, - set: function(key, value) { superSetOccurred = true; } + get(key) { superGetOccurred = true; }, + set(key, value) { superSetOccurred = true; } }) }); SubMixin = Mixin.create(SuperMixin, { aProp: computed({ - get: function(key) { return this._super(...arguments); }, - set: function(key, value) { return this._super(...arguments); } + get(key) { return this._super(...arguments); }, + set(key, value) { return this._super(...arguments); } }) }); @@ -98,25 +98,25 @@ QUnit.test('calling set on overridden computed properties', function() { }); QUnit.test('setter behavior works properly when overriding computed properties', function() { - var obj = {}; + let obj = {}; - var MixinA = Mixin.create({ + let MixinA = Mixin.create({ cpWithSetter2: computed(K), cpWithSetter3: computed(K), cpWithoutSetter: computed(K) }); - var cpWasCalled = false; + let cpWasCalled = false; - var MixinB = Mixin.create({ + let MixinB = Mixin.create({ cpWithSetter2: computed({ get: K, - set: function(k, v) { cpWasCalled = true; } + set(k, v) { cpWasCalled = true; } }), cpWithSetter3: computed({ get: K, - set: function(k, v) { cpWasCalled = true; } + set(k, v) { cpWasCalled = true; } }), cpWithoutSetter: computed(function(k) { diff --git a/packages/ember-metal/tests/mixin/concatenated_properties_test.js b/packages/ember-metal/tests/mixin/concatenated_properties_test.js index 7b50041ff09..ea082ff51ae 100644 --- a/packages/ember-metal/tests/mixin/concatenated_properties_test.js +++ b/packages/ember-metal/tests/mixin/concatenated_properties_test.js @@ -7,104 +7,104 @@ import { QUnit.module('Mixin concatenatedProperties'); QUnit.test('defining concatenated properties should concat future version', function() { - var MixinA = Mixin.create({ + let MixinA = Mixin.create({ concatenatedProperties: ['foo'], foo: ['a', 'b', 'c'] }); - var MixinB = Mixin.create({ + let MixinB = Mixin.create({ foo: ['d', 'e', 'f'] }); - var obj = mixin({}, MixinA, MixinB); + let obj = mixin({}, MixinA, MixinB); deepEqual(get(obj, 'foo'), ['a', 'b', 'c', 'd', 'e', 'f']); }); QUnit.test('defining concatenated properties should concat future version', function() { - var MixinA = Mixin.create({ + let MixinA = Mixin.create({ concatenatedProperties: null }); - var MixinB = Mixin.create({ + let MixinB = Mixin.create({ concatenatedProperties: null }); - var obj = mixin({}, MixinA, MixinB); + let obj = mixin({}, MixinA, MixinB); deepEqual(obj.concatenatedProperties, []); }); QUnit.test('concatenatedProperties should be concatenated', function() { - var MixinA = Mixin.create({ + let MixinA = Mixin.create({ concatenatedProperties: ['foo'], foo: ['a', 'b', 'c'] }); - var MixinB = Mixin.create({ + let MixinB = Mixin.create({ concatenatedProperties: 'bar', foo: ['d', 'e', 'f'], bar: [1, 2, 3] }); - var MixinC = Mixin.create({ + let MixinC = Mixin.create({ bar: [4, 5, 6] }); - var obj = mixin({}, MixinA, MixinB, MixinC); + let obj = mixin({}, MixinA, MixinB, MixinC); deepEqual(get(obj, 'concatenatedProperties'), ['foo', 'bar'], 'get concatenatedProperties'); deepEqual(get(obj, 'foo'), ['a', 'b', 'c', 'd', 'e', 'f'], 'get foo'); deepEqual(get(obj, 'bar'), [1, 2, 3, 4, 5, 6], 'get bar'); }); QUnit.test('adding a prop that is not an array should make array', function() { - var MixinA = Mixin.create({ + let MixinA = Mixin.create({ concatenatedProperties: ['foo'], foo: [1, 2, 3] }); - var MixinB = Mixin.create({ + let MixinB = Mixin.create({ foo: 4 }); - var obj = mixin({}, MixinA, MixinB); + let obj = mixin({}, MixinA, MixinB); deepEqual(get(obj, 'foo'), [1, 2, 3, 4]); }); QUnit.test('adding a prop that is not an array should make array', function() { - var MixinA = Mixin.create({ + let MixinA = Mixin.create({ concatenatedProperties: ['foo'], foo: 'bar' }); - var obj = mixin({}, MixinA); + let obj = mixin({}, MixinA); deepEqual(get(obj, 'foo'), ['bar']); }); QUnit.test('adding a non-concatenable property that already has a defined value should result in an array with both values', function() { - var mixinA = Mixin.create({ + let mixinA = Mixin.create({ foo: 1 }); - var mixinB = Mixin.create({ + let mixinB = Mixin.create({ concatenatedProperties: ['foo'], foo: 2 }); - var obj = mixin({}, mixinA, mixinB); + let obj = mixin({}, mixinA, mixinB); deepEqual(get(obj, 'foo'), [1, 2]); }); QUnit.test('adding a concatenable property that already has a defined value should result in a concatenated value', function() { - var mixinA = Mixin.create({ + let mixinA = Mixin.create({ foobar: 'foo' }); - var mixinB = Mixin.create({ + let mixinB = Mixin.create({ concatenatedProperties: ['foobar'], foobar: 'bar' }); - var obj = mixin({}, mixinA, mixinB); + let obj = mixin({}, mixinA, mixinB); equal(get(obj, 'foobar'), 'foobar'); }); diff --git a/packages/ember-metal/tests/mixin/detect_test.js b/packages/ember-metal/tests/mixin/detect_test.js index 5742e9dc34b..475e862b009 100644 --- a/packages/ember-metal/tests/mixin/detect_test.js +++ b/packages/ember-metal/tests/mixin/detect_test.js @@ -3,8 +3,8 @@ import { Mixin } from 'ember-metal/mixin'; QUnit.module('Mixin.detect'); QUnit.test('detect() finds a directly applied mixin', function() { - var MixinA = Mixin.create(); - var obj = {}; + let MixinA = Mixin.create(); + let obj = {}; equal(MixinA.detect(obj), false, 'MixinA.detect(obj) before apply()'); @@ -13,9 +13,9 @@ QUnit.test('detect() finds a directly applied mixin', function() { }); QUnit.test('detect() finds nested mixins', function() { - var MixinA = Mixin.create({}); - var MixinB = Mixin.create(MixinA); - var obj = {}; + let MixinA = Mixin.create({}); + let MixinB = Mixin.create(MixinA); + let obj = {}; equal(MixinA.detect(obj), false, 'MixinA.detect(obj) before apply()'); @@ -24,13 +24,13 @@ QUnit.test('detect() finds nested mixins', function() { }); QUnit.test('detect() finds mixins on other mixins', function() { - var MixinA = Mixin.create({}); - var MixinB = Mixin.create(MixinA); + let MixinA = Mixin.create({}); + let MixinB = Mixin.create(MixinA); equal(MixinA.detect(MixinB), true, 'MixinA is part of MixinB'); equal(MixinB.detect(MixinA), false, 'MixinB is not part of MixinA'); }); QUnit.test('detect handles null values', function() { - var MixinA = Mixin.create(); + let MixinA = Mixin.create(); equal(MixinA.detect(null), false); }); diff --git a/packages/ember-metal/tests/mixin/introspection_test.js b/packages/ember-metal/tests/mixin/introspection_test.js index a764695b9b5..ac39559f629 100644 --- a/packages/ember-metal/tests/mixin/introspection_test.js +++ b/packages/ember-metal/tests/mixin/introspection_test.js @@ -8,35 +8,30 @@ import { Mixin } from 'ember-metal/mixin'; -var PrivateProperty = Mixin.create({ +const PrivateProperty = Mixin.create({ _foo: '_FOO' }); - -var PublicProperty = Mixin.create({ +const PublicProperty = Mixin.create({ foo: 'FOO' }); - -var PrivateMethod = Mixin.create({ +const PrivateMethod = Mixin.create({ _fooMethod() {} }); - -var PublicMethod = Mixin.create({ +const PublicMethod = Mixin.create({ fooMethod() {} }); - -var BarProperties = Mixin.create({ +const BarProperties = Mixin.create({ _bar: '_BAR', bar: 'bar' }); - -var BarMethods = Mixin.create({ +const BarMethods = Mixin.create({ _barMethod() {}, barMethod() {} }); -var Combined = Mixin.create(BarProperties, BarMethods); +const Combined = Mixin.create(BarProperties, BarMethods); -var obj; +let obj; QUnit.module('Basic introspection', { setup() { @@ -47,7 +42,7 @@ QUnit.module('Basic introspection', { QUnit.test('Ember.mixins()', function() { function mapGuids(ary) { - return ary.map(function(x) { return guidFor(x); }); + return ary.map(x => guidFor(x)); } deepEqual(mapGuids(Mixin.mixins(obj)), mapGuids([PrivateProperty, PublicProperty, PrivateMethod, PublicMethod, Combined, BarProperties, BarMethods]), 'should return included mixins'); diff --git a/packages/ember-metal/tests/mixin/merged_properties_test.js b/packages/ember-metal/tests/mixin/merged_properties_test.js index efa0820103d..a720ddf1e64 100644 --- a/packages/ember-metal/tests/mixin/merged_properties_test.js +++ b/packages/ember-metal/tests/mixin/merged_properties_test.js @@ -5,87 +5,87 @@ import { mixin, Mixin } from 'ember-metal/mixin'; QUnit.module('Mixin mergedProperties'); QUnit.test('defining mergedProperties should merge future version', function() { - var MixinA = Mixin.create({ + let MixinA = Mixin.create({ mergedProperties: ['foo'], foo: { a: true, b: true, c: true } }); - var MixinB = Mixin.create({ + let MixinB = Mixin.create({ foo: { d: true, e: true, f: true } }); - var obj = mixin({}, MixinA, MixinB); + let obj = mixin({}, MixinA, MixinB); deepEqual(get(obj, 'foo'), { a: true, b: true, c: true, d: true, e: true, f: true }); }); QUnit.test('defining mergedProperties on future mixin should merged into past', function() { - var MixinA = Mixin.create({ + let MixinA = Mixin.create({ foo: { a: true, b: true, c: true } }); - var MixinB = Mixin.create({ + let MixinB = Mixin.create({ mergedProperties: ['foo'], foo: { d: true, e: true, f: true } }); - var obj = mixin({}, MixinA, MixinB); + let obj = mixin({}, MixinA, MixinB); deepEqual(get(obj, 'foo'), { a: true, b: true, c: true, d: true, e: true, f: true }); }); QUnit.test('defining mergedProperties with null properties should keep properties null', function() { - var MixinA = Mixin.create({ + let MixinA = Mixin.create({ mergedProperties: ['foo'], foo: null }); - var MixinB = Mixin.create({ + let MixinB = Mixin.create({ foo: null }); - var obj = mixin({}, MixinA, MixinB); + let obj = mixin({}, MixinA, MixinB); equal(get(obj, 'foo'), null); }); QUnit.test('mergedProperties\' properties can get overwritten', function() { - var MixinA = Mixin.create({ + let MixinA = Mixin.create({ mergedProperties: ['foo'], foo: { a: 1 } }); - var MixinB = Mixin.create({ + let MixinB = Mixin.create({ foo: { a: 2 } }); - var obj = mixin({}, MixinA, MixinB); + let obj = mixin({}, MixinA, MixinB); deepEqual(get(obj, 'foo'), { a: 2 }); }); QUnit.test('mergedProperties should be concatenated', function() { - var MixinA = Mixin.create({ + let MixinA = Mixin.create({ mergedProperties: ['foo'], foo: { a: true, b: true, c: true } }); - var MixinB = Mixin.create({ + let MixinB = Mixin.create({ mergedProperties: 'bar', foo: { d: true, e: true, f: true }, bar: { a: true, l: true } }); - var MixinC = Mixin.create({ + let MixinC = Mixin.create({ bar: { e: true, x: true } }); - var obj = mixin({}, MixinA, MixinB, MixinC); + let obj = mixin({}, MixinA, MixinB, MixinC); deepEqual(get(obj, 'mergedProperties'), ['foo', 'bar'], 'get mergedProperties'); deepEqual(get(obj, 'foo'), { a: true, b: true, c: true, d: true, e: true, f: true }, 'get foo'); deepEqual(get(obj, 'bar'), { a: true, l: true, e: true, x: true }, 'get bar'); }); QUnit.test('mergedProperties should exist even if not explicitly set on create', function() { - var AnObj = EmberObject.extend({ + let AnObj = EmberObject.extend({ mergedProperties: ['options'], options: { a: 'a', @@ -95,7 +95,7 @@ QUnit.test('mergedProperties should exist even if not explicitly set on create', } }); - var obj = AnObj.create({ + let obj = AnObj.create({ options: { a: 'A' } @@ -106,19 +106,19 @@ QUnit.test('mergedProperties should exist even if not explicitly set on create', }); QUnit.test('defining mergedProperties at create time should not modify the prototype', function() { - var AnObj = EmberObject.extend({ + let AnObj = EmberObject.extend({ mergedProperties: ['options'], options: { a: 1 } }); - var objA = AnObj.create({ + let objA = AnObj.create({ options: { a: 2 } }); - var objB = AnObj.create({ + let objB = AnObj.create({ options: { a: 3 } @@ -131,7 +131,7 @@ QUnit.test('defining mergedProperties at create time should not modify the proto QUnit.test('mergedProperties\' overwriting methods can call _super', function() { expect(4); - var MixinA = Mixin.create({ + let MixinA = Mixin.create({ mergedProperties: ['foo'], foo: { meth(a) { @@ -141,7 +141,7 @@ QUnit.test('mergedProperties\' overwriting methods can call _super', function() } }); - var MixinB = Mixin.create({ + let MixinB = Mixin.create({ foo: { meth(a) { ok(true, 'MixinB\'s `foo.meth` method called'); @@ -150,7 +150,7 @@ QUnit.test('mergedProperties\' overwriting methods can call _super', function() } }); - var MixinC = Mixin.create({ + let MixinC = Mixin.create({ foo: { meth(a) { ok(true, 'MixinC\'s `foo.meth` method called'); @@ -159,23 +159,23 @@ QUnit.test('mergedProperties\' overwriting methods can call _super', function() } }); - var obj = mixin({}, MixinA, MixinB, MixinC); + let obj = mixin({}, MixinA, MixinB, MixinC); equal(obj.foo.meth('WOOT'), 'WAT'); }); QUnit.test('Merging an Array should raise an error', function() { expect(1); - var MixinA = Mixin.create({ + let MixinA = Mixin.create({ mergedProperties: ['foo'], foo: { a: true, b: true, c: true } }); - var MixinB = Mixin.create({ + let MixinB = Mixin.create({ foo: ['a'] }); - expectAssertion(function() { + expectAssertion(() => { mixin({}, MixinA, MixinB); }, 'You passed in `["a"]` as the value for `foo` but `foo` cannot be an Array'); }); diff --git a/packages/ember-metal/tests/mixin/method_test.js b/packages/ember-metal/tests/mixin/method_test.js index 53b1f002d93..adea9d73915 100644 --- a/packages/ember-metal/tests/mixin/method_test.js +++ b/packages/ember-metal/tests/mixin/method_test.js @@ -6,7 +6,7 @@ import { QUnit.module('Mixin Methods'); QUnit.test('defining simple methods', function() { - var MixinA, obj, props; + let MixinA, obj, props; props = { publicMethod() { return 'publicMethod'; }, @@ -23,7 +23,7 @@ QUnit.test('defining simple methods', function() { }); QUnit.test('overriding public methods', function() { - var MixinA, MixinB, MixinD, MixinF, obj; + let MixinA, MixinB, MixinD, MixinF, obj; MixinA = Mixin.create({ publicMethod() { return 'A'; } @@ -61,22 +61,22 @@ QUnit.test('overriding public methods', function() { QUnit.test('overriding inherited objects', function() { - var cnt = 0; - var MixinA = Mixin.create({ + let cnt = 0; + let MixinA = Mixin.create({ foo() { cnt++; } }); - var MixinB = Mixin.create({ + let MixinB = Mixin.create({ foo() { this._super(...arguments); cnt++; } }); - var objA = {}; + let objA = {}; MixinA.apply(objA); - var objB = Object.create(objA); + let objB = Object.create(objA); MixinB.apply(objB); cnt = 0; @@ -89,24 +89,24 @@ QUnit.test('overriding inherited objects', function() { }); QUnit.test('Including the same mixin more than once will only run once', function() { - var cnt = 0; - var MixinA = Mixin.create({ + let cnt = 0; + let MixinA = Mixin.create({ foo() { cnt++; } }); - var MixinB = Mixin.create(MixinA, { + let MixinB = Mixin.create(MixinA, { foo() { this._super(...arguments); } }); - var MixinC = Mixin.create(MixinA, { + let MixinC = Mixin.create(MixinA, { foo() { this._super(...arguments); } }); - var MixinD = Mixin.create(MixinB, MixinC, MixinA, { + let MixinD = Mixin.create(MixinB, MixinC, MixinA, { foo() { this._super(...arguments); } }); - var obj = {}; + let obj = {}; MixinD.apply(obj); MixinA.apply(obj); // try to apply again.. @@ -117,13 +117,13 @@ QUnit.test('Including the same mixin more than once will only run once', functio }); QUnit.test('_super from a single mixin with no superclass does not error', function() { - var MixinA = Mixin.create({ + let MixinA = Mixin.create({ foo() { this._super(...arguments); } }); - var obj = {}; + let obj = {}; MixinA.apply(obj); obj.foo(); @@ -133,8 +133,8 @@ QUnit.test('_super from a single mixin with no superclass does not error', funct QUnit.test('_super from a first-of-two mixins with no superclass function does not error', function() { // _super was previously calling itself in the second assertion. // Use remaining count of calls to ensure it doesn't loop indefinitely. - var remaining = 3; - var MixinA = Mixin.create({ + let remaining = 3; + let MixinA = Mixin.create({ foo() { if (remaining-- > 0) { this._super(...arguments); @@ -142,11 +142,11 @@ QUnit.test('_super from a first-of-two mixins with no superclass function does n } }); - var MixinB = Mixin.create({ + let MixinB = Mixin.create({ foo() { this._super(...arguments); } }); - var obj = {}; + let obj = {}; MixinA.apply(obj); MixinB.apply(obj); @@ -162,11 +162,11 @@ QUnit.module('Method Conflicts'); QUnit.test('overriding toString', function() { - var MixinA = Mixin.create({ + let MixinA = Mixin.create({ toString() { return 'FOO'; } }); - var obj = {}; + let obj = {}; MixinA.apply(obj); equal(obj.toString(), 'FOO', 'should override toString w/o error'); @@ -182,26 +182,26 @@ QUnit.test('overriding toString', function() { QUnit.module('system/mixin/method_test BUGS'); QUnit.test('applying several mixins at once with sup already defined causes infinite loop', function() { - var cnt = 0; - var MixinA = Mixin.create({ + let cnt = 0; + let MixinA = Mixin.create({ foo() { cnt++; } }); - var MixinB = Mixin.create({ + let MixinB = Mixin.create({ foo() { this._super(...arguments); cnt++; } }); - var MixinC = Mixin.create({ + let MixinC = Mixin.create({ foo() { this._super(...arguments); cnt++; } }); - var obj = {}; + let obj = {}; mixin(obj, MixinA); // sup already exists mixin(obj, MixinB, MixinC); // must be more than one mixin diff --git a/packages/ember-metal/tests/mixin/observer_test.js b/packages/ember-metal/tests/mixin/observer_test.js index 84ad9013d00..651f54f9f18 100644 --- a/packages/ember-metal/tests/mixin/observer_test.js +++ b/packages/ember-metal/tests/mixin/observer_test.js @@ -9,7 +9,7 @@ import { isWatching } from 'ember-metal/watching'; QUnit.module('Mixin observer'); testBoth('global observer helper', function(get, set) { - var MyMixin = Mixin.create({ + let MyMixin = Mixin.create({ count: 0, @@ -19,7 +19,7 @@ testBoth('global observer helper', function(get, set) { }); - var obj = mixin({}, MyMixin); + let obj = mixin({}, MyMixin); equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); set(obj, 'bar', 'BAZ'); @@ -27,7 +27,7 @@ testBoth('global observer helper', function(get, set) { }); testBoth('global observer helper takes multiple params', function(get, set) { - var MyMixin = Mixin.create({ + let MyMixin = Mixin.create({ count: 0, @@ -37,7 +37,7 @@ testBoth('global observer helper takes multiple params', function(get, set) { }); - var obj = mixin({}, MyMixin); + let obj = mixin({}, MyMixin); equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); set(obj, 'bar', 'BAZ'); @@ -46,7 +46,7 @@ testBoth('global observer helper takes multiple params', function(get, set) { }); testBoth('replacing observer should remove old observer', function(get, set) { - var MyMixin = Mixin.create({ + let MyMixin = Mixin.create({ count: 0, @@ -56,13 +56,13 @@ testBoth('replacing observer should remove old observer', function(get, set) { }); - var Mixin2 = Mixin.create({ + let Mixin2 = Mixin.create({ foo: observer('baz', function() { set(this, 'count', get(this, 'count') + 10); }) }); - var obj = mixin({}, MyMixin, Mixin2); + let obj = mixin({}, MyMixin, Mixin2); equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); set(obj, 'bar', 'BAZ'); @@ -73,9 +73,9 @@ testBoth('replacing observer should remove old observer', function(get, set) { }); testBoth('observing chain with property before', function(get, set) { - var obj2 = { baz: 'baz' }; + let obj2 = { baz: 'baz' }; - var MyMixin = Mixin.create({ + let MyMixin = Mixin.create({ count: 0, bar: obj2, foo: observer('bar.baz', function() { @@ -83,7 +83,7 @@ testBoth('observing chain with property before', function(get, set) { }) }); - var obj = mixin({}, MyMixin); + let obj = mixin({}, MyMixin); equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); set(obj2, 'baz', 'BAZ'); @@ -91,9 +91,9 @@ testBoth('observing chain with property before', function(get, set) { }); testBoth('observing chain with property after', function(get, set) { - var obj2 = { baz: 'baz' }; + let obj2 = { baz: 'baz' }; - var MyMixin = Mixin.create({ + let MyMixin = Mixin.create({ count: 0, foo: observer('bar.baz', function() { set(this, 'count', get(this, 'count') + 1); @@ -101,7 +101,7 @@ testBoth('observing chain with property after', function(get, set) { bar: obj2 }); - var obj = mixin({}, MyMixin); + let obj = mixin({}, MyMixin); equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); set(obj2, 'baz', 'BAZ'); @@ -109,9 +109,9 @@ testBoth('observing chain with property after', function(get, set) { }); testBoth('observing chain with property in mixin applied later', function(get, set) { - var obj2 = { baz: 'baz' }; + let obj2 = { baz: 'baz' }; - var MyMixin = Mixin.create({ + let MyMixin = Mixin.create({ count: 0, foo: observer('bar.baz', function() { @@ -119,9 +119,9 @@ testBoth('observing chain with property in mixin applied later', function(get, s }) }); - var MyMixin2 = Mixin.create({ bar: obj2 }); + let MyMixin2 = Mixin.create({ bar: obj2 }); - var obj = mixin({}, MyMixin); + let obj = mixin({}, MyMixin); equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); MyMixin2.apply(obj); @@ -132,16 +132,16 @@ testBoth('observing chain with property in mixin applied later', function(get, s }); testBoth('observing chain with existing property', function(get, set) { - var obj2 = { baz: 'baz' }; + let obj2 = { baz: 'baz' }; - var MyMixin = Mixin.create({ + let MyMixin = Mixin.create({ count: 0, foo: observer('bar.baz', function() { set(this, 'count', get(this, 'count') + 1); }) }); - var obj = mixin({ bar: obj2 }, MyMixin); + let obj = mixin({ bar: obj2 }, MyMixin); equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); set(obj2, 'baz', 'BAZ'); @@ -149,17 +149,17 @@ testBoth('observing chain with existing property', function(get, set) { }); testBoth('observing chain with property in mixin before', function(get, set) { - var obj2 = { baz: 'baz' }; - var MyMixin2 = Mixin.create({ bar: obj2 }); + let obj2 = { baz: 'baz' }; + let MyMixin2 = Mixin.create({ bar: obj2 }); - var MyMixin = Mixin.create({ + let MyMixin = Mixin.create({ count: 0, foo: observer('bar.baz', function() { set(this, 'count', get(this, 'count') + 1); }) }); - var obj = mixin({}, MyMixin2, MyMixin); + let obj = mixin({}, MyMixin2, MyMixin); equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); set(obj2, 'baz', 'BAZ'); @@ -167,17 +167,17 @@ testBoth('observing chain with property in mixin before', function(get, set) { }); testBoth('observing chain with property in mixin after', function(get, set) { - var obj2 = { baz: 'baz' }; - var MyMixin2 = Mixin.create({ bar: obj2 }); + let obj2 = { baz: 'baz' }; + let MyMixin2 = Mixin.create({ bar: obj2 }); - var MyMixin = Mixin.create({ + let MyMixin = Mixin.create({ count: 0, foo: observer('bar.baz', function() { set(this, 'count', get(this, 'count') + 1); }) }); - var obj = mixin({}, MyMixin, MyMixin2); + let obj = mixin({}, MyMixin, MyMixin2); equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); set(obj2, 'baz', 'BAZ'); @@ -185,19 +185,19 @@ testBoth('observing chain with property in mixin after', function(get, set) { }); testBoth('observing chain with overriden property', function(get, set) { - var obj2 = { baz: 'baz' }; - var obj3 = { baz: 'foo' }; + let obj2 = { baz: 'baz' }; + let obj3 = { baz: 'foo' }; - var MyMixin2 = Mixin.create({ bar: obj3 }); + let MyMixin2 = Mixin.create({ bar: obj3 }); - var MyMixin = Mixin.create({ + let MyMixin = Mixin.create({ count: 0, foo: observer('bar.baz', function() { set(this, 'count', get(this, 'count') + 1); }) }); - var obj = mixin({ bar: obj2 }, MyMixin, MyMixin2); + let obj = mixin({ bar: obj2 }, MyMixin, MyMixin2); equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); equal(isWatching(obj2, 'baz'), false, 'should not be watching baz'); diff --git a/packages/ember-metal/tests/mixin/reopen_test.js b/packages/ember-metal/tests/mixin/reopen_test.js index b3884fbb816..814cd545895 100644 --- a/packages/ember-metal/tests/mixin/reopen_test.js +++ b/packages/ember-metal/tests/mixin/reopen_test.js @@ -6,9 +6,9 @@ import Mixin from 'ember-metal/mixin'; QUnit.module('Ember.Mixin#reopen'); QUnit.test('using reopen() to add more properties to a simple', function() { - var MixinA = Mixin.create({ foo: 'FOO', baz: 'BAZ' }); + let MixinA = Mixin.create({ foo: 'FOO', baz: 'BAZ' }); MixinA.reopen({ bar: 'BAR', foo: 'FOO2' }); - var obj = {}; + let obj = {}; MixinA.apply(obj); equal(get(obj, 'foo'), 'FOO2', 'mixin() should override'); @@ -17,7 +17,7 @@ QUnit.test('using reopen() to add more properties to a simple', function() { }); QUnit.test('using reopen() and calling _super where there is not a super function does not cause infinite recursion', function() { - var Taco = EmberObject.extend({ + let Taco = EmberObject.extend({ createBreakfast() { // There is no original createBreakfast function. // Calling the wrapped _super function here @@ -33,10 +33,10 @@ QUnit.test('using reopen() and calling _super where there is not a super functio } }); - var taco = Taco.create(); + let taco = Taco.create(); - var result; - run(function() { + let result; + run(() => { try { result = taco.createBreakfast(); } catch(e) { diff --git a/packages/ember-metal/tests/mixin/required_test.js b/packages/ember-metal/tests/mixin/required_test.js index c192627e233..f5638bacdea 100644 --- a/packages/ember-metal/tests/mixin/required_test.js +++ b/packages/ember-metal/tests/mixin/required_test.js @@ -5,11 +5,11 @@ import { } from 'ember-metal/mixin'; import { get } from 'ember-metal/property_get'; -var PartialMixin, FinalMixin, obj; +let PartialMixin, FinalMixin, obj; QUnit.module('Module.required', { setup() { - expectDeprecation(function() { + expectDeprecation(() => { PartialMixin = Mixin.create({ foo: required(), bar: 'BAR' diff --git a/packages/ember-metal/tests/mixin/without_test.js b/packages/ember-metal/tests/mixin/without_test.js index d29abdc56e7..349c7e4e2f7 100644 --- a/packages/ember-metal/tests/mixin/without_test.js +++ b/packages/ember-metal/tests/mixin/without_test.js @@ -1,14 +1,14 @@ import { Mixin } from 'ember-metal/mixin'; QUnit.test('without should create a new mixin excluding named properties', function() { - var MixinA = Mixin.create({ + let MixinA = Mixin.create({ foo: 'FOO', bar: 'BAR' }); - var MixinB = MixinA.without('bar'); + let MixinB = MixinA.without('bar'); - var obj = {}; + let obj = {}; MixinB.apply(obj); equal(obj.foo, 'FOO', 'should defined foo'); diff --git a/packages/ember-metal/tests/observer_test.js b/packages/ember-metal/tests/observer_test.js index 366e027e7e7..14294740b92 100644 --- a/packages/ember-metal/tests/observer_test.js +++ b/packages/ember-metal/tests/observer_test.js @@ -40,8 +40,8 @@ function K() {} QUnit.module('addObserver'); testBoth('observer should fire when property is modified', function(get, set) { - var obj = {}; - var count = 0; + let obj = {}; + let count = 0; addObserver(obj, 'foo', function() { equal(get(obj, 'foo'), 'bar', 'should invoke AFTER value changed'); @@ -53,14 +53,14 @@ testBoth('observer should fire when property is modified', function(get, set) { }); testBoth('observer should fire when dependent property is modified', function(get, set) { - var obj = { bar: 'bar' }; + let obj = { bar: 'bar' }; defineProperty(obj, 'foo', computed(function() { return get(this, 'bar').toUpperCase(); }).property('bar')); get(obj, 'foo'); - var count = 0; + let count = 0; addObserver(obj, 'foo', function() { equal(get(obj, 'foo'), 'BAZ', 'should have invoked after prop change'); count++; @@ -71,8 +71,8 @@ testBoth('observer should fire when dependent property is modified', function(ge }); testBoth('observer should continue to fire after dependent properties are accessed', function(get, set) { - var observerCount = 0; - var obj = {}; + let observerCount = 0; + let obj = {}; defineProperty(obj, 'prop', computed(function () { return Math.random(); })); defineProperty(obj, 'anotherProp', computed('prop', function () { return get(this, 'prop') + Math.random(); })); @@ -81,7 +81,7 @@ testBoth('observer should continue to fire after dependent properties are access get(obj, 'anotherProp'); - for (var i = 0; i < 10; i++) { + for (let i = 0; i < 10; i++) { propertyWillChange(obj, 'prop'); propertyDidChange(obj, 'prop'); } @@ -91,8 +91,8 @@ testBoth('observer should continue to fire after dependent properties are access if (ENV.EXTEND_PROTOTYPES.Function) { testBoth('observer added declaratively via brace expansion should fire when property changes', function (get, set) { - var obj = { }; - var count = 0; + let obj = { }; + let count = 0; mixin(obj, { observeFooAndBar: function () { @@ -111,8 +111,8 @@ if (ENV.EXTEND_PROTOTYPES.Function) { }); testBoth('observer specified declaratively via brace expansion should fire when dependent property changes', function (get, set) { - var obj = { baz: 'Initial' }; - var count = 0; + let obj = { baz: 'Initial' }; + let count = 0; defineProperty(obj, 'foo', computed(function() { return get(this, 'bar').toLowerCase(); @@ -139,8 +139,8 @@ if (ENV.EXTEND_PROTOTYPES.Function) { } testBoth('observers watching multiple properties via brace expansion should fire when the properties change', function (get, set) { - var obj = { }; - var count = 0; + let obj = { }; + let count = 0; mixin(obj, { observeFooAndBar: observer('{foo,bar}', function () { @@ -159,8 +159,8 @@ testBoth('observers watching multiple properties via brace expansion should fire }); testBoth('observers watching multiple properties via brace expansion should fire when dependent properties change', function (get, set) { - var obj = { baz: 'Initial' }; - var count = 0; + let obj = { baz: 'Initial' }; + let count = 0; defineProperty(obj, 'foo', computed(function() { return get(this, 'bar').toLowerCase(); @@ -186,9 +186,9 @@ testBoth('observers watching multiple properties via brace expansion should fire }); testBoth('nested observers should fire in order', function(get, set) { - var obj = { foo: 'foo', bar: 'bar' }; - var fooCount = 0; - var barCount = 0; + let obj = { foo: 'foo', bar: 'bar' }; + let fooCount = 0; + let barCount = 0; addObserver(obj, 'foo', function() { fooCount++; }); addObserver(obj, 'bar', function() { @@ -203,15 +203,15 @@ testBoth('nested observers should fire in order', function(get, set) { }); testBoth('removing an chain observer on change should not fail', function(get, set) { - var foo = { bar: 'bar' }; - var obj1 = { foo: foo }; - var obj2 = { foo: foo }; - var obj3 = { foo: foo }; - var obj4 = { foo: foo }; - var count1 = 0; - var count2 = 0; - var count3 = 0; - var count4 = 0; + let foo = { bar: 'bar' }; + let obj1 = { foo: foo }; + let obj2 = { foo: foo }; + let obj3 = { foo: foo }; + let obj4 = { foo: foo }; + let count1 = 0; + let count2 = 0; + let count3 = 0; + let count4 = 0; function observer1() { count1++; } function observer2() { count2++; } @@ -237,15 +237,15 @@ testBoth('removing an chain observer on change should not fail', function(get, s }); testBoth('removing an chain before observer on change should not fail', function(get, set) { - var foo = { bar: 'bar' }; - var obj1 = { foo: foo }; - var obj2 = { foo: foo }; - var obj3 = { foo: foo }; - var obj4 = { foo: foo }; - var count1 = 0; - var count2 = 0; - var count3 = 0; - var count4 = 0; + let foo = { bar: 'bar' }; + let obj1 = { foo: foo }; + let obj2 = { foo: foo }; + let obj3 = { foo: foo }; + let obj4 = { foo: foo }; + let count1 = 0; + let count2 = 0; + let count3 = 0; + let count4 = 0; function observer1() { count1++; } function observer2() { count2++; } @@ -271,8 +271,8 @@ testBoth('removing an chain before observer on change should not fail', function }); testBoth('suspending an observer should not fire during callback', function(get, set) { - var obj = {}; - var target, otherTarget; + let obj = {}; + let target, otherTarget; target = { values: [], @@ -308,8 +308,8 @@ testBoth('suspending an observer should not fire during callback', function(get, testBoth('suspending an observer should not defer change notifications during callback', function(get, set) { - var obj = {}; - var target, otherTarget; + let obj = {}; + let target, otherTarget; target = { values: [], @@ -346,8 +346,8 @@ testBoth('suspending an observer should not defer change notifications during ca }); testBoth('suspending observers should not fire during callback', function(get, set) { - var obj = {}; - var target, otherTarget; + let obj = {}; + let target, otherTarget; target = { values: [], @@ -383,8 +383,8 @@ testBoth('suspending observers should not fire during callback', function(get, s testBoth('suspending observers should not defer change notifications during callback', function(get, set) { - var obj = {}; - var target, otherTarget; + let obj = {}; + let target, otherTarget; target = { values: [], @@ -421,8 +421,8 @@ testBoth('suspending observers should not defer change notifications during call }); testBoth('deferring property change notifications', function(get, set) { - var obj = { foo: 'foo' }; - var fooCount = 0; + let obj = { foo: 'foo' }; + let fooCount = 0; addObserver(obj, 'foo', function() { fooCount++; }); @@ -435,9 +435,9 @@ testBoth('deferring property change notifications', function(get, set) { }); testBoth('deferring property change notifications safely despite exceptions', function(get, set) { - var obj = { foo: 'foo' }; - var fooCount = 0; - var exc = new Error('Something unexpected happened!'); + let obj = { foo: 'foo' }; + let fooCount = 0; + let exc = new Error('Something unexpected happened!'); expect(2); addObserver(obj, 'foo', function() { fooCount++; }); @@ -465,8 +465,8 @@ testBoth('deferring property change notifications safely despite exceptions', fu }); testBoth('deferring property change notifications will not defer before observers', function(get, set) { - var obj = { foo: 'foo' }; - var fooCount = 0; + let obj = { foo: 'foo' }; + let fooCount = 0; _addBeforeObserver(obj, 'foo', function() { fooCount++; }); @@ -480,8 +480,8 @@ testBoth('deferring property change notifications will not defer before observer }); testBoth('addObserver should propagate through prototype', function(get, set) { - var obj = { foo: 'foo', count: 0 }; - var obj2; + let obj = { foo: 'foo', count: 0 }; + let obj2; addObserver(obj, 'foo', function() { this.count++; }); obj2 = Object.create(obj); @@ -498,13 +498,13 @@ testBoth('addObserver should propagate through prototype', function(get, set) { }); testBoth('addObserver should respect targets with methods', function(get, set) { - var observed = { foo: 'foo' }; + let observed = { foo: 'foo' }; - var target1 = { + let target1 = { count: 0, didChange(obj, keyName) { - var value = get(obj, keyName); + let value = get(obj, keyName); equal(this, target1, 'should invoke with this'); equal(obj, observed, 'param1 should be observed object'); equal(keyName, 'foo', 'param2 should be keyName'); @@ -513,11 +513,11 @@ testBoth('addObserver should respect targets with methods', function(get, set) { } }; - var target2 = { + let target2 = { count: 0, didChange(obj, keyName) { - var value = get(obj, keyName); + let value = get(obj, keyName); equal(this, target2, 'should invoke with this'); equal(obj, observed, 'param1 should be observed object'); equal(keyName, 'foo', 'param2 should be keyName'); @@ -535,9 +535,9 @@ testBoth('addObserver should respect targets with methods', function(get, set) { }); testBoth('addObserver should allow multiple objects to observe a property', function(get, set) { - var observed = { foo: 'foo' }; + let observed = { foo: 'foo' }; - var target1 = { + let target1 = { count: 0, didChange(obj, keyName, value) { @@ -545,7 +545,7 @@ testBoth('addObserver should allow multiple objects to observe a property', func } }; - var target2 = { + let target2 = { count: 0, didChange(obj, keyName, value) { @@ -568,8 +568,8 @@ testBoth('addObserver should allow multiple objects to observe a property', func QUnit.module('removeObserver'); testBoth('removing observer should stop firing', function(get, set) { - var obj = {}; - var count = 0; + let obj = {}; + let count = 0; function F() { count++; } addObserver(obj, 'foo', F); @@ -583,9 +583,9 @@ testBoth('removing observer should stop firing', function(get, set) { }); testBoth('local observers can be removed', function(get, set) { - var barObserved = 0; + let barObserved = 0; - var MyMixin = Mixin.create({ + let MyMixin = Mixin.create({ foo1: observer('bar', function() { barObserved++; }), @@ -595,7 +595,7 @@ testBoth('local observers can be removed', function(get, set) { }) }); - var obj = {}; + let obj = {}; MyMixin.apply(obj); set(obj, 'bar', 'HI!'); @@ -610,9 +610,9 @@ testBoth('local observers can be removed', function(get, set) { }); testBoth('removeObserver should respect targets with methods', function(get, set) { - var observed = { foo: 'foo' }; + let observed = { foo: 'foo' }; - var target1 = { + let target1 = { count: 0, didChange() { @@ -620,7 +620,7 @@ testBoth('removeObserver should respect targets with methods', function(get, set } }; - var target2 = { + let target2 = { count: 0, didChange() { @@ -651,8 +651,8 @@ testBoth('removeObserver should respect targets with methods', function(get, set QUnit.module('_addBeforeObserver'); testBoth('observer should fire before a property is modified', function(get, set) { - var obj = { foo: 'foo' }; - var count = 0; + let obj = { foo: 'foo' }; + let count = 0; _addBeforeObserver(obj, 'foo', function() { equal(get(obj, 'foo'), 'foo', 'should invoke before value changed'); @@ -664,14 +664,14 @@ testBoth('observer should fire before a property is modified', function(get, set }); testBoth('observer should fire before dependent property is modified', function(get, set) { - var obj = { bar: 'bar' }; + let obj = { bar: 'bar' }; defineProperty(obj, 'foo', computed(function() { return get(this, 'bar').toUpperCase(); }).property('bar')); get(obj, 'foo'); - var count = 0; + let count = 0; _addBeforeObserver(obj, 'foo', function() { equal(get(obj, 'foo'), 'BAR', 'should have invoked after prop change'); count++; @@ -682,8 +682,8 @@ testBoth('observer should fire before dependent property is modified', function( }); testBoth('before observer watching multiple properties via brace expansion should fire when properties change', function (get, set) { - var obj = {}; - var count = 0; + let obj = {}; + let count = 0; mixin(obj, { fooAndBarWatcher: _beforeObserver('{foo,bar}', function () { @@ -702,8 +702,8 @@ testBoth('before observer watching multiple properties via brace expansion shoul }); testBoth('before observer watching multiple properties via brace expansion should fire when dependent property changes', function (get, set) { - var obj = { baz: 'Initial' }; - var count = 0; + let obj = { baz: 'Initial' }; + let count = 0; defineProperty(obj, 'foo', computed(function() { return get(this, 'bar').toLowerCase(); @@ -729,8 +729,8 @@ testBoth('before observer watching multiple properties via brace expansion shoul }); testBoth('_addBeforeObserver should propagate through prototype', function(get, set) { - var obj = { foo: 'foo', count: 0 }; - var obj2; + let obj = { foo: 'foo', count: 0 }; + let obj2; _addBeforeObserver(obj, 'foo', function() { this.count++; }); obj2 = Object.create(obj); @@ -746,13 +746,13 @@ testBoth('_addBeforeObserver should propagate through prototype', function(get, }); testBoth('_addBeforeObserver should respect targets with methods', function(get, set) { - var observed = { foo: 'foo' }; + let observed = { foo: 'foo' }; - var target1 = { + let target1 = { count: 0, willChange(obj, keyName) { - var value = get(obj, keyName); + let value = get(obj, keyName); equal(this, target1, 'should invoke with this'); equal(obj, observed, 'param1 should be observed object'); equal(keyName, 'foo', 'param2 should be keyName'); @@ -761,11 +761,11 @@ testBoth('_addBeforeObserver should respect targets with methods', function(get, } }; - var target2 = { + let target2 = { count: 0, willChange(obj, keyName) { - var value = get(obj, keyName); + let value = get(obj, keyName); equal(this, target2, 'should invoke with this'); equal(obj, observed, 'param1 should be observed object'); equal(keyName, 'foo', 'param2 should be keyName'); @@ -786,7 +786,7 @@ testBoth('_addBeforeObserver should respect targets with methods', function(get, // CHAINED OBSERVERS // -var obj, count; +let obj, count; QUnit.module('addObserver - dependentkey with chained properties', { setup() { @@ -823,7 +823,7 @@ testBoth('depending on a chain with a computed property', function (get, set) { return { foo: 'bar' }; })); - var changed = 0; + let changed = 0; addObserver(obj, 'computed.foo', function () { changed++; }); @@ -836,7 +836,7 @@ testBoth('depending on a chain with a computed property', function (get, set) { }); testBoth('depending on a simple chain', function(get, set) { - var val; + let val; addObserver(obj, 'foo.bar.baz.biff', function(target, key) { val = get(target, key); count++; @@ -862,7 +862,7 @@ testBoth('depending on a simple chain', function(get, set) { equal(val, 'BUZZ'); equal(count, 5); - var foo = get(obj, 'foo'); + let foo = get(obj, 'foo'); set(obj, 'foo', 'BOO'); equal(val, undefined); @@ -873,7 +873,7 @@ testBoth('depending on a simple chain', function(get, set) { }); testBoth('depending on a chain with a capitalized first key', function(get, set) { - var val; + let val; addObserver(obj, 'Capital.foo.bar.baz.biff', function(target, key) { val = get(obj, key); @@ -900,7 +900,7 @@ testBoth('depending on a chain with a capitalized first key', function(get, set) equal(val, 'BUZZ'); equal(count, 5); - var foo = get(obj, 'foo'); + let foo = get(obj, 'foo'); set(obj, 'Capital.foo', 'BOO'); equal(val, undefined); @@ -919,8 +919,8 @@ QUnit.module('_removeBeforeObserver'); QUnit.module('props/observer_test - setting identical values'); testBoth('setting simple prop should not trigger', function(get, set) { - var obj = { foo: 'bar' }; - var count = 0; + let obj = { foo: 'bar' }; + let count = 0; addObserver(obj, 'foo', function() { count++; }); @@ -938,14 +938,14 @@ testBoth('setting simple prop should not trigger', function(get, set) { // dependent key change (which triggers a cache expiration and recomputation), observers will // not be fired if the CP setter is called with the last set value. testBoth('setting a cached computed property whose value has changed should trigger', function(get, set) { - var obj = {}; + let obj = {}; defineProperty(obj, 'foo', computed({ get: function() { return get(this, 'baz'); }, set: function(key, value) { return value; } }).property('baz')); - var count = 0; + let count = 0; addObserver(obj, 'foo', function() { count++; }); @@ -967,9 +967,9 @@ QUnit.module('Ember.immediateObserver (Deprecated)'); testBoth('immediate observers should fire synchronously', function(get, set) { expectDeprecation(/Usage of `Ember.immediateObserver` is deprecated, use `Ember.observer` instead./); - var obj = {}; - var observerCalled = 0; - var mixin; + let obj = {}; + let observerCalled = 0; + let mixin; // explicitly create a run loop so we do not inadvertently // trigger deferred behavior @@ -1000,9 +1000,9 @@ testBoth('immediate observers should fire synchronously', function(get, set) { if (ENV.EXTEND_PROTOTYPES.Function) { testBoth('immediate observers added declaratively via brace expansion fire synchronously', function (get, set) { - var obj = {}; - var observerCalled = 0; - var mixin; + let obj = {}; + let observerCalled = 0; + let mixin; // explicitly create a run loop so we do not inadvertently // trigger deferred behavior @@ -1035,9 +1035,9 @@ if (ENV.EXTEND_PROTOTYPES.Function) { testBoth('immediate observers watching multiple properties via brace expansion fire synchronously', function (get, set) { expectDeprecation(/Usage of `Ember.immediateObserver` is deprecated, use `Ember.observer` instead./); - var obj = {}; - var observerCalled = 0; - var mixin; + let obj = {}; + let observerCalled = 0; + let mixin; // explicitly create a run loop so we do not inadvertently // trigger deferred behavior @@ -1075,7 +1075,7 @@ testBoth('immediate observers are for internal properties only', function(get, s QUnit.module('changeProperties'); testBoth('observers added/removed during changeProperties should do the right thing.', function(get, set) { - var obj = { + let obj = { foo: 0 }; function Observer() { @@ -1098,12 +1098,12 @@ testBoth('observers added/removed during changeProperties should do the right th this.didChangeCount++; } }; - var addedBeforeFirstChangeObserver = new Observer(); - var addedAfterFirstChangeObserver = new Observer(); - var addedAfterLastChangeObserver = new Observer(); - var removedBeforeFirstChangeObserver = new Observer(); - var removedBeforeLastChangeObserver = new Observer(); - var removedAfterLastChangeObserver = new Observer(); + let addedBeforeFirstChangeObserver = new Observer(); + let addedAfterFirstChangeObserver = new Observer(); + let addedAfterLastChangeObserver = new Observer(); + let removedBeforeFirstChangeObserver = new Observer(); + let removedBeforeLastChangeObserver = new Observer(); + let removedAfterLastChangeObserver = new Observer(); removedBeforeFirstChangeObserver.add(); removedBeforeLastChangeObserver.add(); removedAfterLastChangeObserver.add(); @@ -1150,7 +1150,7 @@ testBoth('should not leak properties on the prototype', function () { function Beer() { } Beer.prototype.type = 'ipa'; - var beer = new Beer(); + let beer = new Beer(); addObserver(beer, 'type', K); deepEqual(Object.keys(beer), []); @@ -1161,7 +1161,7 @@ testBoth('observing a non existent property', function (get, set) { function Beer() { } Beer.prototype.type = 'ipa'; - var beer = new Beer(); + let beer = new Beer(); addObserver(beer, 'brand', K); @@ -1177,7 +1177,7 @@ testBoth('with observers switched on and off', function (get, set) { function Beer() { } Beer.prototype.type = 'ipa'; - var beer = new Beer(); + let beer = new Beer(); addObserver(beer, 'type', K); removeObserver(beer, 'type', K); @@ -1189,7 +1189,7 @@ testBoth('observers switched on and off with setter in between', function (get, function Beer() { } Beer.prototype.type = 'ipa'; - var beer = new Beer(); + let beer = new Beer(); addObserver(beer, 'type', K); set(beer, 'type', 'ale'); @@ -1202,7 +1202,7 @@ testBoth('observer switched on and off and then setter', function (get, set) { function Beer() { } Beer.prototype.type = 'ipa'; - var beer = new Beer(); + let beer = new Beer(); addObserver(beer, 'type', K); removeObserver(beer, 'type', K); @@ -1214,22 +1214,22 @@ testBoth('observer switched on and off and then setter', function (get, set) { testBoth('observers switched on and off with setter in between (observed property is not shadowing)', function (get, set) { function Beer() { } - var beer = new Beer(); + let beer = new Beer(); set(beer, 'type', 'ale'); deepEqual(Object.keys(beer), ['type'], 'only set'); - var otherBeer = new Beer(); + let otherBeer = new Beer(); addObserver(otherBeer, 'type', K); set(otherBeer, 'type', 'ale'); deepEqual(Object.keys(otherBeer), ['type'], 'addObserver -> set'); - var yetAnotherBeer = new Beer(); + let yetAnotherBeer = new Beer(); addObserver(yetAnotherBeer, 'type', K); set(yetAnotherBeer, 'type', 'ale'); removeObserver(beer, 'type', K); deepEqual(Object.keys(yetAnotherBeer), ['type'], 'addObserver -> set -> removeObserver'); - var itsMyLastBeer = new Beer(); + let itsMyLastBeer = new Beer(); set(itsMyLastBeer, 'type', 'ale'); removeObserver(beer, 'type', K); deepEqual(Object.keys(itsMyLastBeer), ['type'], 'set -> removeObserver'); @@ -1239,22 +1239,22 @@ testBoth('observers switched on and off with setter in between (observed propert function Beer() { } Beer.prototype.type = 'ipa'; - var beer = new Beer(); + let beer = new Beer(); set(beer, 'type', 'ale'); deepEqual(Object.keys(beer), ['type'], 'after set'); - var otherBeer = new Beer(); + let otherBeer = new Beer(); addObserver(otherBeer, 'type', K); set(otherBeer, 'type', 'ale'); deepEqual(Object.keys(otherBeer), ['type'], 'addObserver -> set'); - var yetAnotherBeer = new Beer(); + let yetAnotherBeer = new Beer(); addObserver(yetAnotherBeer, 'type', K); set(yetAnotherBeer, 'type', 'ale'); removeObserver(beer, 'type', K); deepEqual(Object.keys(yetAnotherBeer), ['type'], 'addObserver -> set -> removeObserver'); - var itsMyLastBeer = new Beer(); + let itsMyLastBeer = new Beer(); set(itsMyLastBeer, 'type', 'ale'); removeObserver(beer, 'type', K); deepEqual(Object.keys(itsMyLastBeer), ['type'], 'set -> removeObserver'); diff --git a/packages/ember-metal/tests/performance_test.js b/packages/ember-metal/tests/performance_test.js index 0450cc7a938..245e8287e7a 100644 --- a/packages/ember-metal/tests/performance_test.js +++ b/packages/ember-metal/tests/performance_test.js @@ -19,9 +19,9 @@ import { addObserver } from 'ember-metal/observer'; QUnit.module('Computed Properties - Number of times evaluated'); QUnit.test('computed properties that depend on multiple properties should run only once per run loop', function() { - var obj = { a: 'a', b: 'b', c: 'c' }; - var cpCount = 0; - var obsCount = 0; + let obj = { a: 'a', b: 'b', c: 'c' }; + let cpCount = 0; + let obsCount = 0; defineProperty(obj, 'abc', computed(function(key) { cpCount++; @@ -49,9 +49,9 @@ QUnit.test('computed properties that depend on multiple properties should run on }); QUnit.test('computed properties are not executed if they are the last segment of an observer chain pain', function() { - var foo = { bar: { baz: { } } }; + let foo = { bar: { baz: { } } }; - var count = 0; + let count = 0; defineProperty(foo.bar.baz, 'bam', computed(function() { count++; diff --git a/packages/ember-metal/tests/properties_test.js b/packages/ember-metal/tests/properties_test.js index 15b2fa29bfb..87627acb3cc 100644 --- a/packages/ember-metal/tests/properties_test.js +++ b/packages/ember-metal/tests/properties_test.js @@ -5,7 +5,7 @@ import { deprecateProperty } from 'ember-metal/deprecate_property'; QUnit.module('Ember.defineProperty'); QUnit.test('toString', function() { - var obj = {}; + let obj = {}; defineProperty(obj, 'toString', undefined, function() { return 'FOO'; }); equal(obj.toString(), 'FOO', 'should replace toString'); }); @@ -13,7 +13,7 @@ QUnit.test('toString', function() { QUnit.test('for data properties, didDefineProperty hook should be called if implemented', function() { expect(2); - var obj = { + let obj = { didDefineProperty(obj, keyName, value) { equal(keyName, 'foo', 'key name should be foo'); equal(value, 'bar', 'value should be bar'); @@ -26,9 +26,9 @@ QUnit.test('for data properties, didDefineProperty hook should be called if impl QUnit.test('for computed properties, didDefineProperty hook should be called if implemented', function() { expect(2); - var computedProperty = computed(function() { return this; }); + let computedProperty = computed(function() { return this; }); - var obj = { + let obj = { didDefineProperty(obj, keyName, value) { equal(keyName, 'foo', 'key name should be foo'); strictEqual(value, computedProperty, 'value should be passed as computed property'); @@ -41,14 +41,14 @@ QUnit.test('for computed properties, didDefineProperty hook should be called if QUnit.test('for descriptor properties, didDefineProperty hook should be called if implemented', function() { expect(2); - var descriptor = { + let descriptor = { writable: true, configurable: false, enumerable: true, value: 42 }; - var obj = { + let obj = { didDefineProperty(obj, keyName, value) { equal(keyName, 'answer', 'key name should be answer'); strictEqual(value, descriptor, 'value should be passed as descriptor'); @@ -62,7 +62,7 @@ QUnit.module('Ember.deprecateProperty'); QUnit.test('enables access to deprecated property and returns the value of the new property', function() { expect(3); - var obj = { foo: 'bar' }; + let obj = { foo: 'bar' }; deprecateProperty(obj, 'baz', 'foo'); @@ -75,11 +75,11 @@ QUnit.test('enables access to deprecated property and returns the value of the n QUnit.test('deprecatedKey is not enumerable', function() { expect(2); - var obj = { foo: 'bar', blammo: 'whammy' }; + let obj = { foo: 'bar', blammo: 'whammy' }; deprecateProperty(obj, 'baz', 'foo'); - for (var prop in obj) { + for (let prop in obj) { if (obj.hasOwnProperty(prop)) { notEqual(prop, 'baz'); } @@ -88,7 +88,7 @@ QUnit.test('deprecatedKey is not enumerable', function() { QUnit.test('enables setter to deprecated property and updates the value of the new property', function() { expect(3); - var obj = { foo: 'bar' }; + let obj = { foo: 'bar' }; deprecateProperty(obj, 'baz', 'foo'); diff --git a/packages/ember-metal/tests/props_helper.js b/packages/ember-metal/tests/props_helper.js index ab08c9eb6ae..daf5e2743f3 100644 --- a/packages/ember-metal/tests/props_helper.js +++ b/packages/ember-metal/tests/props_helper.js @@ -1,9 +1,9 @@ import { ENV } from 'ember-environment'; -import {get as getFromEmberMetal, getWithDefault as getWithDefaultFromEmberMetal} from 'ember-metal/property_get'; -import {set as setFromEmberMetal} from 'ember-metal/property_set'; +import { get as getFromEmberMetal, getWithDefault as getWithDefaultFromEmberMetal } from 'ember-metal/property_get'; +import { set as setFromEmberMetal } from 'ember-metal/property_set'; // used by unit tests to test both accessor mode and non-accessor mode -var testBoth = function(testname, callback) { +export function testBoth(testname, callback) { function emberget(x, y) { return getFromEmberMetal(x, y); } function emberset(x, y, z) { return setFromEmberMetal(x, y, z); } function aget(x, y) { return x[y]; } @@ -20,9 +20,9 @@ var testBoth = function(testname, callback) { ok('SKIPPING ACCESSORS'); } }); -}; +} -var testWithDefault = function(testname, callback) { +export function testWithDefault(testname, callback) { function emberget(x, y) { return getFromEmberMetal(x, y); } function embergetwithdefault(x, y, z) { return getWithDefaultFromEmberMetal(x, y, z); } function getwithdefault(x, y, z) { return x.getWithDefault(y, z); } @@ -53,6 +53,4 @@ var testWithDefault = function(testname, callback) { ok('SKIPPING ACCESSORS'); } }); -}; - -export {testWithDefault, testBoth}; +} diff --git a/packages/ember-metal/tests/run_loop/add_queue_test.js b/packages/ember-metal/tests/run_loop/add_queue_test.js index 4f1c5cb9b20..cb20d5cd6d4 100644 --- a/packages/ember-metal/tests/run_loop/add_queue_test.js +++ b/packages/ember-metal/tests/run_loop/add_queue_test.js @@ -1,7 +1,7 @@ import run from 'ember-metal/run_loop'; -var originalQueues = run.queues; -var queues; +const originalQueues = run.queues; +let queues; QUnit.module('system/run_loop/add_queue_test', { setup() { diff --git a/packages/ember-metal/tests/run_loop/debounce_test.js b/packages/ember-metal/tests/run_loop/debounce_test.js index 1780403d1d4..c28b1dba8c6 100644 --- a/packages/ember-metal/tests/run_loop/debounce_test.js +++ b/packages/ember-metal/tests/run_loop/debounce_test.js @@ -1,7 +1,8 @@ import run from 'ember-metal/run_loop'; -var originalDebounce = run.backburner.debounce; -var wasCalled = false; +const originalDebounce = run.backburner.debounce; +let wasCalled = false; + QUnit.module('Ember.run.debounce', { setup() { run.backburner.debounce = function() { wasCalled = true; }; @@ -12,7 +13,7 @@ QUnit.module('Ember.run.debounce', { }); QUnit.test('Ember.run.debounce uses Backburner.debounce', function() { - run.debounce(function() {}); + run.debounce(() => {}); ok(wasCalled, 'Ember.run.debounce used'); }); diff --git a/packages/ember-metal/tests/run_loop/later_test.js b/packages/ember-metal/tests/run_loop/later_test.js index a62104d82cc..c880b99202c 100644 --- a/packages/ember-metal/tests/run_loop/later_test.js +++ b/packages/ember-metal/tests/run_loop/later_test.js @@ -1,14 +1,14 @@ import isNone from 'ember-metal/is_none'; import run from 'ember-metal/run_loop'; -var originalSetTimeout = window.setTimeout; -var originalDateValueOf = Date.prototype.valueOf; +const originalSetTimeout = window.setTimeout; +const originalDateValueOf = Date.prototype.valueOf; const originalPlatform = run.backburner._platform; function wait(callback, maxWaitCount) { maxWaitCount = isNone(maxWaitCount) ? 100 : maxWaitCount; - originalSetTimeout(function() { + originalSetTimeout(() => { if (maxWaitCount > 0 && (run.hasScheduledTimers() || run.currentRunLoop)) { wait(callback, maxWaitCount - 1); @@ -41,49 +41,49 @@ QUnit.module('run.later', { }); asyncTest('should invoke after specified period of time - function only', function() { - var invoked = false; + let invoked = false; - run(function() { - run.later(function() { invoked = true; }, 100); + run(() => { + run.later(() => invoked = true, 100); }); - wait(function() { + wait(() => { QUnit.start(); equal(invoked, true, 'should have invoked later item'); }); }); asyncTest('should invoke after specified period of time - target/method', function() { - var obj = { invoked: false }; + let obj = { invoked: false }; - run(function() { + run(() => { run.later(obj, function() { this.invoked = true; }, 100); }); - wait(function() { + wait(() => { QUnit.start(); equal(obj.invoked, true, 'should have invoked later item'); }); }); asyncTest('should invoke after specified period of time - target/method/args', function() { - var obj = { invoked: 0 }; + let obj = { invoked: 0 }; - run(function() { + run(() => { run.later(obj, function(amt) { this.invoked += amt; }, 10, 100); }); - wait(function() { + wait(() => { QUnit.start(); equal(obj.invoked, 10, 'should have invoked later item'); }); }); asyncTest('should always invoke within a separate runloop', function() { - var obj = { invoked: 0 }; - var firstRunLoop, secondRunLoop; + let obj = { invoked: 0 }; + let firstRunLoop, secondRunLoop; - run(function() { + run(() => { firstRunLoop = run.currentRunLoop; run.later(obj, function(amt) { @@ -98,7 +98,7 @@ asyncTest('should always invoke within a separate runloop', function() { ok(!run.currentRunLoop, 'shouldn\'t be in a run loop after flush'); equal(obj.invoked, 0, 'shouldn\'t have invoked later item yet'); - wait(function() { + wait(() => { QUnit.start(); equal(obj.invoked, 10, 'should have invoked later item'); ok(secondRunLoop, 'second run loop took place'); @@ -111,7 +111,7 @@ asyncTest('should always invoke within a separate runloop', function() { // See https://github.com/emberjs/ember.js/issues/3526 for more information. // asyncTest('callback order', function() { -// var array = []; +// let array = []; // function fn(val) { array.push(val); } // run(function() { @@ -136,14 +136,14 @@ asyncTest('should always invoke within a separate runloop', function() { // See https://github.com/emberjs/ember.js/issues/3522 for more information. // asyncTest('callbacks coalesce into same run loop if expiring at the same time', function() { -// var array = []; +// let array = []; // function fn(val) { array.push(run.currentRunLoop); } // run(function() { // // Force +new Date to return the same result while scheduling // // run.later timers. Otherwise: non-determinism! -// var now = +new Date(); +// let now = +new Date(); // Date.prototype.valueOf = function() { return now; }; // run.later(this, fn, 10); @@ -166,18 +166,18 @@ asyncTest('should always invoke within a separate runloop', function() { // }); asyncTest('inception calls to run.later should run callbacks in separate run loops', function() { - var runLoop, finished; + let runLoop, finished; - run(function() { + run(() => { runLoop = run.currentRunLoop; ok(runLoop); - run.later(function() { + run.later(() => { ok(run.currentRunLoop && run.currentRunLoop !== runLoop, 'first later callback has own run loop'); runLoop = run.currentRunLoop; - run.later(function() { + run.later(() => { ok(run.currentRunLoop && run.currentRunLoop !== runLoop, 'second later callback has own run loop'); finished = true; @@ -185,7 +185,7 @@ asyncTest('inception calls to run.later should run callbacks in separate run loo }, 40); }); - wait(function() { + wait(() => { QUnit.start(); ok(finished, 'all .later callbacks run'); }); @@ -198,10 +198,10 @@ asyncTest('setTimeout should never run with a negative wait', function() { // older browsers (IE <= 8) break with a negative wait, which // happens when an expired timer callback takes a while to run, // which is what we simulate here. - var newSetTimeoutUsed; + let newSetTimeoutUsed; run.backburner._platform = { setTimeout() { - var wait = arguments[arguments.length - 1]; + let wait = arguments[arguments.length - 1]; newSetTimeoutUsed = true; ok(!isNaN(wait) && wait >= 0, 'wait is a non-negative number'); @@ -209,9 +209,9 @@ asyncTest('setTimeout should never run with a negative wait', function() { } }; - var count = 0; - run(function() { - run.later(function() { + let count = 0; + run(() => { + run.later(() => { count++; // This will get run first. Waste some time. @@ -223,12 +223,12 @@ asyncTest('setTimeout should never run with a negative wait', function() { pauseUntil(+new Date() + 60); }, 1); - run.later(function() { + run.later(() => { equal(count, 1, 'callbacks called in order'); }, 50); }); - wait(function() { + wait(() => { QUnit.start(); ok(newSetTimeoutUsed, 'stub setTimeout was used'); }); diff --git a/packages/ember-metal/tests/run_loop/next_test.js b/packages/ember-metal/tests/run_loop/next_test.js index a12fef6a119..8c50fe62ede 100644 --- a/packages/ember-metal/tests/run_loop/next_test.js +++ b/packages/ember-metal/tests/run_loop/next_test.js @@ -3,29 +3,27 @@ import run from 'ember-metal/run_loop'; QUnit.module('run.next'); asyncTest('should invoke immediately on next timeout', function() { - var invoked = false; + let invoked = false; - run(function() { - run.next(function() { invoked = true; }); - }); + run(() => run.next(() => invoked = true)); equal(invoked, false, 'should not have invoked yet'); - setTimeout(function() { + setTimeout(() => { QUnit.start(); equal(invoked, true, 'should have invoked later item'); }, 20); }); asyncTest('callback should be called from within separate loop', function() { - var firstRunLoop, secondRunLoop; - run(function() { + let firstRunLoop, secondRunLoop; + run(() => { firstRunLoop = run.currentRunLoop; - run.next(function() { secondRunLoop = run.currentRunLoop; }); + run.next(() => secondRunLoop = run.currentRunLoop); }); - setTimeout(function() { + setTimeout(() => { QUnit.start(); ok(secondRunLoop, 'callback was called from within run loop'); ok(firstRunLoop && secondRunLoop !== firstRunLoop, 'two separate run loops were invoked'); @@ -33,14 +31,14 @@ asyncTest('callback should be called from within separate loop', function() { }); asyncTest('multiple calls to run.next share coalesce callbacks into same run loop', function() { - var firstRunLoop, secondRunLoop, thirdRunLoop; - run(function() { + let firstRunLoop, secondRunLoop, thirdRunLoop; + run(() => { firstRunLoop = run.currentRunLoop; - run.next(function() { secondRunLoop = run.currentRunLoop; }); - run.next(function() { thirdRunLoop = run.currentRunLoop; }); + run.next(() => secondRunLoop = run.currentRunLoop); + run.next(() => thirdRunLoop = run.currentRunLoop); }); - setTimeout(function() { + setTimeout(() => { QUnit.start(); ok(secondRunLoop && secondRunLoop === thirdRunLoop, 'callbacks coalesced into same run loop'); }, 20); diff --git a/packages/ember-metal/tests/run_loop/once_test.js b/packages/ember-metal/tests/run_loop/once_test.js index f6509e61fed..8adbdaf91ab 100644 --- a/packages/ember-metal/tests/run_loop/once_test.js +++ b/packages/ember-metal/tests/run_loop/once_test.js @@ -3,9 +3,9 @@ import run from 'ember-metal/run_loop'; QUnit.module('system/run_loop/once_test'); QUnit.test('calling invokeOnce more than once invokes only once', function() { - var count = 0; - run(function() { - var F = function() { count++; }; + let count = 0; + run(() => { + function F() { count++; } run.once(F); run.once(F); run.once(F); @@ -15,10 +15,10 @@ QUnit.test('calling invokeOnce more than once invokes only once', function() { }); QUnit.test('should differentiate based on target', function() { - var A = { count: 0 }; - var B = { count: 0 }; - run(function() { - var F = function() { this.count++; }; + let A = { count: 0 }; + let B = { count: 0 }; + run(() => { + function F() { this.count++; } run.once(A, F); run.once(B, F); run.once(A, F); @@ -31,10 +31,11 @@ QUnit.test('should differentiate based on target', function() { QUnit.test('should ignore other arguments - replacing previous ones', function() { - var A = { count: 0 }; - var B = { count: 0 }; - run(function() { - var F = function(amt) { this.count += amt; }; + let A = { count: 0 }; + let B = { count: 0 }; + + run(() => { + function F(amt) { this.count += amt; } run.once(A, F, 10); run.once(B, F, 20); run.once(A, F, 30); @@ -46,10 +47,8 @@ QUnit.test('should ignore other arguments - replacing previous ones', function() }); QUnit.test('should be inside of a runloop when running', function() { - run(function() { - run.once(function() { - ok(!!run.currentRunLoop, 'should have a runloop'); - }); + run(() => { + run.once(() => ok(!!run.currentRunLoop, 'should have a runloop')); }); }); diff --git a/packages/ember-metal/tests/run_loop/run_bind_test.js b/packages/ember-metal/tests/run_loop/run_bind_test.js index e48f0037033..cae45334e89 100644 --- a/packages/ember-metal/tests/run_loop/run_bind_test.js +++ b/packages/ember-metal/tests/run_loop/run_bind_test.js @@ -5,7 +5,7 @@ QUnit.module('system/run_loop/run_bind_test'); QUnit.test('Ember.run.bind builds a run-loop wrapped callback handler', function() { expect(3); - var obj = { + let obj = { value: 0, increment(increment) { ok(run.currentRunLoop, 'expected a run-loop'); @@ -13,7 +13,7 @@ QUnit.test('Ember.run.bind builds a run-loop wrapped callback handler', function } }; - var proxiedFunction = run.bind(obj, obj.increment, 1); + let proxiedFunction = run.bind(obj, obj.increment, 1); equal(proxiedFunction(), 1); equal(obj.value, 1); }); @@ -21,16 +21,16 @@ QUnit.test('Ember.run.bind builds a run-loop wrapped callback handler', function QUnit.test('Ember.run.bind keeps the async callback arguments', function() { expect(4); - var asyncCallback = function(increment, increment2, increment3) { + function asyncCallback(increment, increment2, increment3) { ok(run.currentRunLoop, 'expected a run-loop'); equal(increment, 1); equal(increment2, 2); equal(increment3, 3); - }; + } - var asyncFunction = function(fn) { + function asyncFunction(fn) { fn(2, 3); - }; + } asyncFunction(run.bind(asyncCallback, asyncCallback, 1)); }); diff --git a/packages/ember-metal/tests/run_loop/run_test.js b/packages/ember-metal/tests/run_loop/run_test.js index e4da70af3fe..20c8c8b37e2 100644 --- a/packages/ember-metal/tests/run_loop/run_test.js +++ b/packages/ember-metal/tests/run_loop/run_test.js @@ -3,13 +3,13 @@ import run from 'ember-metal/run_loop'; QUnit.module('system/run_loop/run_test'); QUnit.test('Ember.run invokes passed function, returning value', function() { - var obj = { + let obj = { foo() { return [this.bar, 'FOO']; }, bar: 'BAR', checkArgs(arg1, arg2) { return [arg1, this.bar, arg2]; } }; - equal(run(function() { return 'FOO'; }), 'FOO', 'pass function only'); + equal(run(() => 'FOO'), 'FOO', 'pass function only'); deepEqual(run(obj, obj.foo), ['BAR', 'FOO'], 'pass obj and obj.method'); deepEqual(run(obj, 'foo'), ['BAR', 'FOO'], 'pass obj and "method"'); deepEqual(run(obj, obj.checkArgs, 'hello', 'world'), ['hello', 'BAR', 'world'], 'pass obj, obj.method, and extra arguments'); diff --git a/packages/ember-metal/tests/run_loop/schedule_test.js b/packages/ember-metal/tests/run_loop/schedule_test.js index 87f53a4c4a3..f39dcf0b984 100644 --- a/packages/ember-metal/tests/run_loop/schedule_test.js +++ b/packages/ember-metal/tests/run_loop/schedule_test.js @@ -3,11 +3,11 @@ import run from 'ember-metal/run_loop'; QUnit.module('system/run_loop/schedule_test'); QUnit.test('scheduling item in queue should defer until finished', function() { - var cnt = 0; + let cnt = 0; - run(function() { - run.schedule('actions', function() { cnt++; }); - run.schedule('actions', function() { cnt++; }); + run(() => { + run.schedule('actions', () => cnt++); + run.schedule('actions', () => cnt++); equal(cnt, 0, 'should not run action yet'); }); @@ -15,14 +15,14 @@ QUnit.test('scheduling item in queue should defer until finished', function() { }); QUnit.test('nested runs should queue each phase independently', function() { - var cnt = 0; + let cnt = 0; - run(function() { - run.schedule('actions', function() { cnt++; }); + run(() => { + run.schedule('actions', () => cnt++); equal(cnt, 0, 'should not run action yet'); - run(function() { - run.schedule('actions', function() { cnt++; }); + run(() => { + run.schedule('actions', () => cnt++); }); equal(cnt, 1, 'should not run action yet'); }); @@ -31,31 +31,33 @@ QUnit.test('nested runs should queue each phase independently', function() { }); QUnit.test('prior queues should be flushed before moving on to next queue', function() { - var order = []; + let order = []; - run(function() { - var runLoop = run.currentRunLoop; + run(() => { + let runLoop = run.currentRunLoop; ok(runLoop, 'run loop present'); - run.schedule('sync', function() { + run.schedule('sync', () => { order.push('sync'); equal(runLoop, run.currentRunLoop, 'same run loop used'); }); - run.schedule('actions', function() { + + run.schedule('actions', () => { order.push('actions'); equal(runLoop, run.currentRunLoop, 'same run loop used'); - run.schedule('actions', function() { + run.schedule('actions', () => { order.push('actions'); equal(runLoop, run.currentRunLoop, 'same run loop used'); }); - run.schedule('sync', function() { + run.schedule('sync', () => { order.push('sync'); equal(runLoop, run.currentRunLoop, 'same run loop used'); }); }); - run.schedule('destroy', function() { + + run.schedule('destroy', () => { order.push('destroy'); equal(runLoop, run.currentRunLoop, 'same run loop used'); }); @@ -65,12 +67,8 @@ QUnit.test('prior queues should be flushed before moving on to next queue', func }); QUnit.test('makes sure it does not trigger an autorun during testing', function() { - expectAssertion(function() { - run.schedule('actions', function() {}); - }, /wrap any code with asynchronous side-effects in a run/); + expectAssertion(() => run.schedule('actions', () => {}), /wrap any code with asynchronous side-effects in a run/); // make sure not just the first violation is asserted. - expectAssertion(function() { - run.schedule('actions', function() {}); - }, /wrap any code with asynchronous side-effects in a run/); + expectAssertion(() => run.schedule('actions', () => {}), /wrap any code with asynchronous side-effects in a run/); }); diff --git a/packages/ember-metal/tests/run_loop/sync_test.js b/packages/ember-metal/tests/run_loop/sync_test.js index 188b41d02f2..b48fdf28004 100644 --- a/packages/ember-metal/tests/run_loop/sync_test.js +++ b/packages/ember-metal/tests/run_loop/sync_test.js @@ -3,9 +3,9 @@ import run from 'ember-metal/run_loop'; QUnit.module('system/run_loop/sync_test'); QUnit.test('sync() will immediately flush the sync queue only', function() { - var cnt = 0; + let cnt = 0; - run(function() { + run(() => { function cntup() { cnt++; } function syncfunc() { diff --git a/packages/ember-metal/tests/run_loop/unwind_test.js b/packages/ember-metal/tests/run_loop/unwind_test.js index e4a1a250a45..8b9bd07fdbb 100644 --- a/packages/ember-metal/tests/run_loop/unwind_test.js +++ b/packages/ember-metal/tests/run_loop/unwind_test.js @@ -4,10 +4,10 @@ import EmberError from 'ember-metal/error'; QUnit.module('system/run_loop/unwind_test'); QUnit.test('RunLoop unwinds despite unhandled exception', function() { - var initialRunLoop = run.currentRunLoop; + let initialRunLoop = run.currentRunLoop; - throws(function() { - run(function() { + throws(() => { + run(() => { run.schedule('actions', function() { throw new EmberError('boom!'); }); }); }, Error, 'boom!'); @@ -25,7 +25,7 @@ QUnit.test('RunLoop unwinds despite unhandled exception', function() { QUnit.test('run unwinds despite unhandled exception', function() { var initialRunLoop = run.currentRunLoop; - throws(function() { + throws(() => { run(function() { throw new EmberError('boom!'); }); diff --git a/packages/ember-metal/tests/utils/can_invoke_test.js b/packages/ember-metal/tests/utils/can_invoke_test.js index 6fb9fa94f98..5f4003f3fd0 100644 --- a/packages/ember-metal/tests/utils/can_invoke_test.js +++ b/packages/ember-metal/tests/utils/can_invoke_test.js @@ -1,6 +1,6 @@ import { canInvoke } from 'ember-metal/utils'; -var obj; +let obj; QUnit.module('Ember.canInvoke', { setup() { diff --git a/packages/ember-metal/tests/utils/generate_guid_test.js b/packages/ember-metal/tests/utils/generate_guid_test.js index 79a0ec86656..7a3057a15d4 100644 --- a/packages/ember-metal/tests/utils/generate_guid_test.js +++ b/packages/ember-metal/tests/utils/generate_guid_test.js @@ -3,7 +3,7 @@ import { generateGuid } from 'ember-metal/utils'; QUnit.module('Ember.generateGuid'); QUnit.test('Prefix', function() { - var a = {}; + let a = {}; ok(generateGuid(a, 'tyrell').indexOf('tyrell') > -1, 'guid can be prefixed'); }); diff --git a/packages/ember-metal/tests/utils/guid_for_test.js b/packages/ember-metal/tests/utils/guid_for_test.js index fa4d62b9a16..da9aceff417 100644 --- a/packages/ember-metal/tests/utils/guid_for_test.js +++ b/packages/ember-metal/tests/utils/guid_for_test.js @@ -4,22 +4,22 @@ import { QUnit.module('guidFor'); -var sameGuid = function(a, b, message) { +function sameGuid(a, b, message) { equal(guidFor(a), guidFor(b), message); -}; +} -var diffGuid = function(a, b, message) { +function diffGuid(a, b, message) { ok(guidFor(a) !== guidFor(b), message); -}; +} -var nanGuid = function(obj) { - var type = typeof obj; +function nanGuid(obj) { + let type = typeof obj; ok(isNaN(parseInt(guidFor(obj), 0)), 'guids for ' + type + 'don\'t parse to numbers'); -}; +} QUnit.test('Object', function() { - var a = {}; - var b = {}; + let a = {}; + let b = {}; sameGuid(a, a, 'same object always yields same guid'); diffGuid(a, b, 'different objects yield different guids'); @@ -27,9 +27,9 @@ QUnit.test('Object', function() { }); QUnit.test('strings', function() { - var a = 'string A'; - var aprime = 'string A'; - var b = 'String B'; + let a = 'string A'; + let aprime = 'string A'; + let b = 'String B'; sameGuid(a, a, 'same string always yields same guid'); sameGuid(a, aprime, 'identical strings always yield the same guid'); @@ -38,9 +38,9 @@ QUnit.test('strings', function() { }); QUnit.test('numbers', function() { - var a = 23; - var aprime = 23; - var b = 34; + let a = 23; + let aprime = 23; + let b = 34; sameGuid(a, a, 'same numbers always yields same guid'); sameGuid(a, aprime, 'identical numbers always yield the same guid'); @@ -49,9 +49,9 @@ QUnit.test('numbers', function() { }); QUnit.test('numbers', function() { - var a = true; - var aprime = true; - var b = false; + let a = true; + let aprime = true; + let b = false; sameGuid(a, a, 'same booleans always yields same guid'); sameGuid(a, aprime, 'identical booleans always yield the same guid'); @@ -61,9 +61,9 @@ QUnit.test('numbers', function() { }); QUnit.test('null and undefined', function() { - var a = null; - var aprime = null; - var b; + let a = null; + let aprime = null; + let b; sameGuid(a, a, 'null always returns the same guid'); sameGuid(b, b, 'undefined always returns the same guid'); @@ -74,9 +74,9 @@ QUnit.test('null and undefined', function() { }); QUnit.test('arrays', function() { - var a = ['a', 'b', 'c']; - var aprime = ['a', 'b', 'c']; - var b = ['1', '2', '3']; + let a = ['a', 'b', 'c']; + let aprime = ['a', 'b', 'c']; + let b = ['1', '2', '3']; sameGuid(a, a, 'same instance always yields same guid'); diffGuid(a, aprime, 'identical arrays always yield the same guid'); diff --git a/packages/ember-metal/tests/utils/try_invoke_test.js b/packages/ember-metal/tests/utils/try_invoke_test.js index 9e31733970a..55644636976 100644 --- a/packages/ember-metal/tests/utils/try_invoke_test.js +++ b/packages/ember-metal/tests/utils/try_invoke_test.js @@ -1,6 +1,6 @@ import { tryInvoke } from 'ember-metal/utils'; -var obj; +let obj; QUnit.module('Ember.tryInvoke', { setup() { diff --git a/packages/ember-metal/tests/watching/is_watching_test.js b/packages/ember-metal/tests/watching/is_watching_test.js index e49ce7c7373..f0020d8fba8 100644 --- a/packages/ember-metal/tests/watching/is_watching_test.js +++ b/packages/ember-metal/tests/watching/is_watching_test.js @@ -13,10 +13,9 @@ import { isWatching } from 'ember-metal/watching'; QUnit.module('isWatching'); -function testObserver(setup, teardown, key) { - var obj = {}; - var fn = function() {}; - key = key || 'foo'; +function testObserver(setup, teardown, key = 'key') { + let obj = {}; + function fn() {} equal(isWatching(obj, key), false, 'precond - isWatching is false by default'); setup(obj, key, fn); @@ -26,21 +25,17 @@ function testObserver(setup, teardown, key) { } QUnit.test('isWatching is true for regular local observers', function() { - testObserver(function(obj, key, fn) { + testObserver((obj, key, fn) => { Mixin.create({ didChange: observer(key, fn) }).apply(obj); - }, function(obj, key, fn) { - removeObserver(obj, key, obj, fn); - }); + }, (obj, key, fn) => removeObserver(obj, key, obj, fn)); }); QUnit.test('isWatching is true for nonlocal observers', function() { - testObserver(function(obj, key, fn) { + testObserver((obj, key, fn) => { addObserver(obj, key, obj, fn); - }, function(obj, key, fn) { - removeObserver(obj, key, obj, fn); - }); + }, (obj, key, fn) => removeObserver(obj, key, obj, fn)); }); QUnit.test('isWatching is true for chained observers', function() { @@ -52,30 +47,24 @@ QUnit.test('isWatching is true for chained observers', function() { }); QUnit.test('isWatching is true for computed properties', function() { - testObserver(function(obj, key, fn) { + testObserver((obj, key, fn) => { defineProperty(obj, 'computed', computed(fn).property(key)); get(obj, 'computed'); - }, function(obj, key, fn) { - defineProperty(obj, 'computed', null); - }); + }, (obj, key, fn) => defineProperty(obj, 'computed', null)); }); QUnit.test('isWatching is true for chained computed properties', function() { - testObserver(function(obj, key, fn) { + testObserver((obj, key, fn) => { defineProperty(obj, 'computed', computed(fn).property(key + '.bar')); get(obj, 'computed'); - }, function(obj, key, fn) { - defineProperty(obj, 'computed', null); - }); + }, (obj, key, fn) => defineProperty(obj, 'computed', null)); }); // can't watch length on Array - it is special... // But you should be able to watch a length property of an object QUnit.test('isWatching is true for \'length\' property on object', function() { - testObserver(function(obj, key, fn) { + testObserver((obj, key, fn) => { defineProperty(obj, 'length', null, '26.2 miles'); addObserver(obj, 'length', obj, fn); - }, function(obj, key, fn) { - removeObserver(obj, 'length', obj, fn); - }, 'length'); + }, (obj, key, fn) => removeObserver(obj, 'length', obj, fn), 'length'); }); diff --git a/packages/ember-metal/tests/watching/unwatch_test.js b/packages/ember-metal/tests/watching/unwatch_test.js index 94eb7d76c34..4ec9b41657a 100644 --- a/packages/ember-metal/tests/watching/unwatch_test.js +++ b/packages/ember-metal/tests/watching/unwatch_test.js @@ -8,7 +8,7 @@ import { addListener } from 'ember-metal/events'; import { computed } from 'ember-metal/computed'; import { set } from 'ember-metal/property_set'; -var willCount, didCount; +let willCount, didCount; QUnit.module('unwatch', { setup() { @@ -17,21 +17,18 @@ QUnit.module('unwatch', { }); function addListeners(obj, keyPath) { - addListener(obj, keyPath + ':before', function() { - willCount++; - }); - addListener(obj, keyPath + ':change', function() { - didCount++; - }); + addListener(obj, keyPath + ':before', () => willCount++); + addListener(obj, keyPath + ':change', () => didCount++); } testBoth('unwatching a computed property - regular get/set', function(get, set) { - var obj = {}; + let obj = {}; + defineProperty(obj, 'foo', computed({ - get: function() { + get() { return this.__foo; }, - set: function(keyName, value) { + set(keyName, value) { this.__foo = value; return this.__foo; } @@ -52,7 +49,7 @@ testBoth('unwatching a computed property - regular get/set', function(get, set) testBoth('unwatching a regular property - regular get/set', function(get, set) { - var obj = { foo: 'BIFF' }; + let obj = { foo: 'BIFF' }; addListeners(obj, 'foo'); watch(obj, 'foo'); @@ -68,7 +65,7 @@ testBoth('unwatching a regular property - regular get/set', function(get, set) { }); QUnit.test('unwatching should be nested', function() { - var obj = { foo: 'BIFF' }; + let obj = { foo: 'BIFF' }; addListeners(obj, 'foo'); watch(obj, 'foo'); @@ -91,7 +88,7 @@ QUnit.test('unwatching should be nested', function() { }); testBoth('unwatching "length" property on an object', function(get, set) { - var obj = { foo: 'RUN' }; + let obj = { foo: 'RUN' }; addListeners(obj, 'length'); // Can watch length when it is undefined @@ -109,7 +106,7 @@ testBoth('unwatching "length" property on an object', function(get, set) { }); testBoth('unwatching should not destroy non MANDATORY_SETTER descriptor', function(get, set) { - var obj = { get foo() { return 'RUN'; } }; + let obj = { get foo() { return 'RUN'; } }; equal(obj.foo, 'RUN', 'obj.foo'); watch(obj, 'foo'); diff --git a/packages/ember-metal/tests/watching/watch_test.js b/packages/ember-metal/tests/watching/watch_test.js index fa57fa27b6d..e81821466d9 100644 --- a/packages/ember-metal/tests/watching/watch_test.js +++ b/packages/ember-metal/tests/watching/watch_test.js @@ -12,7 +12,7 @@ import { destroy } from 'ember-metal/watching'; -var willCount, didCount, +let willCount, didCount, willKeys, didKeys, originalLookup, lookup; @@ -43,12 +43,12 @@ function addListeners(obj, keyPath) { } testBoth('watching a computed property', function(get, set) { - var obj = {}; + let obj = {}; defineProperty(obj, 'foo', computed({ - get: function() { + get() { return this.__foo; }, - set: function(keyName, value) { + set(keyName, value) { if (value !== undefined) { this.__foo = value; } @@ -64,7 +64,7 @@ testBoth('watching a computed property', function(get, set) { }); testBoth('watching a regular defined property', function(get, set) { - var obj = { foo: 'baz' }; + let obj = { foo: 'baz' }; addListeners(obj, 'foo'); watch(obj, 'foo'); @@ -79,7 +79,7 @@ testBoth('watching a regular defined property', function(get, set) { }); testBoth('watching a regular undefined property', function(get, set) { - var obj = { }; + let obj = { }; addListeners(obj, 'foo'); watch(obj, 'foo'); @@ -96,8 +96,8 @@ testBoth('watching a regular undefined property', function(get, set) { }); testBoth('watches should inherit', function(get, set) { - var obj = { foo: 'baz' }; - var objB = Object.create(obj); + let obj = { foo: 'baz' }; + let objB = Object.create(obj); addListeners(obj, 'foo'); watch(obj, 'foo'); @@ -110,7 +110,7 @@ testBoth('watches should inherit', function(get, set) { }); QUnit.test('watching an object THEN defining it should work also', function() { - var obj = {}; + let obj = {}; addListeners(obj, 'foo'); watch(obj, 'foo'); @@ -124,8 +124,8 @@ QUnit.test('watching an object THEN defining it should work also', function() { }); QUnit.test('watching a chain then defining the property', function () { - var obj = {}; - var foo = { bar: 'bar' }; + let obj = {}; + let foo = { bar: 'bar' }; addListeners(obj, 'foo.bar'); addListeners(foo, 'bar'); @@ -141,9 +141,9 @@ QUnit.test('watching a chain then defining the property', function () { }); QUnit.test('watching a chain then defining the nested property', function () { - var bar = {}; - var obj = { foo: bar }; - var baz = { baz: 'baz' }; + let bar = {}; + let obj = { foo: bar }; + let baz = { baz: 'baz' }; addListeners(obj, 'foo.bar.baz'); addListeners(baz, 'baz'); @@ -159,12 +159,12 @@ QUnit.test('watching a chain then defining the nested property', function () { }); testBoth('watching an object value then unwatching should restore old value', function(get, set) { - var obj = { foo: { bar: { baz: { biff: 'BIFF' } } } }; + let obj = { foo: { bar: { baz: { biff: 'BIFF' } } } }; addListeners(obj, 'foo.bar.baz.biff'); watch(obj, 'foo.bar.baz.biff'); - var foo = get(obj, 'foo'); + let foo = get(obj, 'foo'); equal(get(get(get(foo, 'bar'), 'baz'), 'biff'), 'BIFF', 'biff should exist'); unwatch(obj, 'foo.bar.baz.biff'); @@ -172,15 +172,15 @@ testBoth('watching an object value then unwatching should restore old value', fu }); QUnit.test('when watching another object, destroy should remove chain watchers from the other object', function() { - var objA = {}; - var objB = { foo: 'bar' }; + let objA = {}; + let objB = { foo: 'bar' }; objA.b = objB; addListeners(objA, 'b.foo'); watch(objA, 'b.foo'); - var meta_objB = meta(objB); - var chainNode = meta(objA).readableChains()._chains.b._chains.foo; + let meta_objB = meta(objB); + let chainNode = meta(objA).readableChains()._chains.b._chains.foo; equal(meta_objB.peekWatching('foo'), 1, 'should be watching foo'); equal(meta_objB.readableChainWatchers().has('foo', chainNode), true, 'should have chain watcher'); @@ -194,7 +194,7 @@ QUnit.test('when watching another object, destroy should remove chain watchers f // TESTS for length property testBoth('watching "length" property on an object', function(get, set) { - var obj = { length: '26.2 miles' }; + let obj = { length: '26.2 miles' }; addListeners(obj, 'length'); watch(obj, 'length'); @@ -209,7 +209,7 @@ testBoth('watching "length" property on an object', function(get, set) { }); testBoth('watching "length" property on an array', function(get, set) { - var arr = []; + let arr = []; addListeners(arr, 'length'); watch(arr, 'length'); @@ -224,8 +224,8 @@ testBoth('watching "length" property on an array', function(get, set) { }); testBoth('watch + ES5 getter', function(get) { - var parent = { b: 1 }; - var child = { + let parent = { b: 1 }; + let child = { get b() { return parent.b; } @@ -244,7 +244,7 @@ testBoth('watch + ES5 getter', function(get) { }); testBoth('watch + Ember.set + no-descriptor', function(get, set) { - var child = { }; + let child = { }; equal(child.b, undefined, 'child.b '); equal(get(child, 'b'), undefined, 'Ember.get(child, "b")'); diff --git a/packages/ember-metal/tests/weak_map_test.js b/packages/ember-metal/tests/weak_map_test.js index 1452e600488..d9d81db25a5 100644 --- a/packages/ember-metal/tests/weak_map_test.js +++ b/packages/ember-metal/tests/weak_map_test.js @@ -56,25 +56,11 @@ QUnit.test('invoking the WeakMap constructor with arguments is not supported at QUnit.test('that error is thrown when using a primitive key', function(assert) { let map = new WeakMap(); - expectAssertion(function() { - map.set('a', 1); - }, /Uncaught TypeError: Invalid value used as weak map key/); - - expectAssertion(function() { - map.set(1, 1); - }, /Uncaught TypeError: Invalid value used as weak map key/); - - expectAssertion(function() { - map.set(true, 1); - }, /Uncaught TypeError: Invalid value used as weak map key/); - - expectAssertion(function() { - map.set(null, 1); - }, /Uncaught TypeError: Invalid value used as weak map key/); - - expectAssertion(function() { - map.set(undefined, 1); - }, /Uncaught TypeError: Invalid value used as weak map key/); + expectAssertion(() => map.set('a', 1), /Uncaught TypeError: Invalid value used as weak map key/); + expectAssertion(() => map.set(1, 1), /Uncaught TypeError: Invalid value used as weak map key/); + expectAssertion(() => map.set(true, 1), /Uncaught TypeError: Invalid value used as weak map key/); + expectAssertion(() => map.set(null, 1), /Uncaught TypeError: Invalid value used as weak map key/); + expectAssertion(() => map.set(undefined, 1), /Uncaught TypeError: Invalid value used as weak map key/); }); QUnit.test('that .has and .delete work as expected', function(assert) { diff --git a/packages/ember-routing/lib/ext/controller.js b/packages/ember-routing/lib/ext/controller.js index 206645d7ea6..74c295b6a07 100644 --- a/packages/ember-routing/lib/ext/controller.js +++ b/packages/ember-routing/lib/ext/controller.js @@ -31,10 +31,10 @@ ControllerMixin.reopen({ @private */ _qpChanged(controller, _prop) { - var prop = _prop.substr(0, _prop.length - 3); + let prop = _prop.substr(0, _prop.length - 3); - var delegate = controller._qpDelegate; - var value = get(controller, prop); + let delegate = controller._qpDelegate; + let value = get(controller, prop); delegate(prop, value); }, @@ -112,8 +112,8 @@ ControllerMixin.reopen({ */ transitionToRoute() { // target may be either another controller or a router - var target = get(this, 'target'); - var method = target.transitionToRoute || target.transitionTo; + let target = get(this, 'target'); + let method = target.transitionToRoute || target.transitionTo; return method.apply(target, arguments); }, @@ -175,8 +175,8 @@ ControllerMixin.reopen({ */ replaceRoute() { // target may be either another controller or a router - var target = get(this, 'target'); - var method = target.replaceRoute || target.replaceWith; + let target = get(this, 'target'); + let method = target.replaceRoute || target.replaceWith; return method.apply(target, arguments); } }); diff --git a/packages/ember-routing/lib/location/api.js b/packages/ember-routing/lib/location/api.js index 6595b879cc0..667977c5866 100644 --- a/packages/ember-routing/lib/location/api.js +++ b/packages/ember-routing/lib/location/api.js @@ -166,10 +166,10 @@ export default { @private */ create(options) { - var implementation = options && options.implementation; + let implementation = options && options.implementation; assert('Ember.Location.create: you must specify a \'implementation\' option', !!implementation); - var implementationClass = this.implementations[implementation]; + let implementationClass = this.implementations[implementation]; assert(`Ember.Location.create: ${implementation} is not a valid implementation`, !!implementationClass); return implementationClass.create(...arguments); diff --git a/packages/ember-routing/lib/location/auto_location.js b/packages/ember-routing/lib/location/auto_location.js index 1451ce991b1..e2586909d68 100644 --- a/packages/ember-routing/lib/location/auto_location.js +++ b/packages/ember-routing/lib/location/auto_location.js @@ -115,12 +115,12 @@ export default EmberObject.extend({ @private */ detect() { - var rootURL = this.rootURL; + let rootURL = this.rootURL; assert('rootURL must end with a trailing forward slash e.g. "/app/"', rootURL.charAt(rootURL.length - 1) === '/'); - var implementation = detectImplementation({ + let implementation = detectImplementation({ location: this.location, history: this.history, userAgent: this.userAgent, @@ -134,7 +134,7 @@ export default EmberObject.extend({ implementation = 'none'; } - var concrete = getOwner(this).lookup(`location:${implementation}`); + let concrete = getOwner(this).lookup(`location:${implementation}`); set(concrete, 'rootURL', rootURL); assert(`Could not find location '${implementation}'.`, !!concrete); @@ -150,7 +150,7 @@ export default EmberObject.extend({ formatURL: delegateToConcreteImplementation('formatURL'), willDestroy() { - var concreteImplementation = get(this, 'concreteImplementation'); + let concreteImplementation = get(this, 'concreteImplementation'); if (concreteImplementation) { concreteImplementation.destroy(); @@ -160,7 +160,7 @@ export default EmberObject.extend({ function delegateToConcreteImplementation(methodName) { return function(...args) { - var concreteImplementation = get(this, 'concreteImplementation'); + let concreteImplementation = get(this, 'concreteImplementation'); assert('AutoLocation\'s detect() method should be called before calling any other hooks.', !!concreteImplementation); return tryInvoke(concreteImplementation, methodName, args); }; @@ -181,19 +181,19 @@ function delegateToConcreteImplementation(methodName) { */ function detectImplementation(options) { - var location = options.location; - var userAgent = options.userAgent; - var history = options.history; - var documentMode = options.documentMode; - var global = options.global; - var rootURL = options.rootURL; + let location = options.location; + let userAgent = options.userAgent; + let history = options.history; + let documentMode = options.documentMode; + let global = options.global; + let rootURL = options.rootURL; - var implementation = 'none'; - var cancelRouterSetup = false; - var currentPath = getFullPath(location); + let implementation = 'none'; + let cancelRouterSetup = false; + let currentPath = getFullPath(location); if (supportsHistory(userAgent, history)) { - var historyPath = getHistoryPath(rootURL, location); + let historyPath = getHistoryPath(rootURL, location); // If the browser supports history and we have a history path, we can use // the history location with no redirects. @@ -209,7 +209,7 @@ function detectImplementation(options) { } } } else if (supportsHashChange(documentMode, global)) { - var hashPath = getHashPath(rootURL, location); + let hashPath = getHashPath(rootURL, location); // Be sure we're using a hashed path, otherwise let's switch over it to so // we start off clean and consistent. We'll count an index path with no @@ -239,11 +239,11 @@ function detectImplementation(options) { starts off as a hashed URL) */ export function getHistoryPath(rootURL, location) { - var path = getPath(location); - var hash = getHash(location); - var query = getQuery(location); - var rootURLIndex = path.indexOf(rootURL); - var routeHash, hashParts; + let path = getPath(location); + let hash = getHash(location); + let query = getQuery(location); + let rootURLIndex = path.indexOf(rootURL); + let routeHash, hashParts; assert(`Path ${path} does not start with the provided rootURL ${rootURL}`, rootURLIndex === 0); @@ -284,9 +284,9 @@ export function getHistoryPath(rootURL, location) { @method _getHashPath */ export function getHashPath(rootURL, location) { - var path = rootURL; - var historyPath = getHistoryPath(rootURL, location); - var routePath = historyPath.substr(rootURL.length); + let path = rootURL; + let historyPath = getHistoryPath(rootURL, location); + let routePath = historyPath.substr(rootURL.length); if (routePath !== '') { if (routePath.charAt(0) !== '/') { diff --git a/packages/ember-routing/lib/location/hash_location.js b/packages/ember-routing/lib/location/hash_location.js index e13c614634a..240430e3098 100644 --- a/packages/ember-routing/lib/location/hash_location.js +++ b/packages/ember-routing/lib/location/hash_location.js @@ -51,8 +51,8 @@ export default EmberObject.extend({ @method getURL */ getURL() { - var originalPath = this.getHash().substr(1); - var outPath = originalPath; + let originalPath = this.getHash().substr(1); + let outPath = originalPath; if (outPath.charAt(0) !== '/') { outPath = '/'; @@ -106,11 +106,11 @@ export default EmberObject.extend({ @param callback {Function} */ onUpdateURL(callback) { - var guid = guidFor(this); + let guid = guidFor(this); jQuery(window).on(`hashchange.ember-location-${guid}`, () => { run(() => { - var path = this.getURL(); + let path = this.getURL(); if (get(this, 'lastSetURL') === path) { return; } set(this, 'lastSetURL', null); @@ -142,7 +142,7 @@ export default EmberObject.extend({ @method willDestroy */ willDestroy() { - var guid = guidFor(this); + let guid = guidFor(this); jQuery(window).off(`hashchange.ember-location-${guid}`); } diff --git a/packages/ember-routing/lib/location/history_location.js b/packages/ember-routing/lib/location/history_location.js index eb0ed1e8d69..ab886cac431 100644 --- a/packages/ember-routing/lib/location/history_location.js +++ b/packages/ember-routing/lib/location/history_location.js @@ -11,7 +11,7 @@ import jQuery from 'ember-views/system/jquery'; @submodule ember-routing */ -var popstateFired = false; +let popstateFired = false; /** Ember.HistoryLocation implements the location API using the browser's @@ -37,7 +37,7 @@ export default EmberObject.extend({ @method initState */ initState() { - var history = get(this, 'history') || window.history; + let history = get(this, 'history') || window.history; set(this, 'history', history); if (history && 'state' in history) { @@ -64,22 +64,22 @@ export default EmberObject.extend({ @return url {String} */ getURL() { - var location = get(this, 'location'); - var path = location.pathname; + let location = get(this, 'location'); + let path = location.pathname; - var rootURL = get(this, 'rootURL'); - var baseURL = get(this, 'baseURL'); + let rootURL = get(this, 'rootURL'); + let baseURL = get(this, 'baseURL'); // remove trailing slashes if they exists rootURL = rootURL.replace(/\/$/, ''); baseURL = baseURL.replace(/\/$/, ''); // remove baseURL and rootURL from start of path - var url = path + let url = path .replace(new RegExp('^' + baseURL), '') .replace(new RegExp('^' + rootURL), ''); - var search = location.search || ''; + let search = location.search || ''; url += search; url += this.getHash(); @@ -94,7 +94,7 @@ export default EmberObject.extend({ @param path {String} */ setURL(path) { - var state = this.getState(); + let state = this.getState(); path = this.formatURL(path); if (!state || state.path !== path) { @@ -111,7 +111,7 @@ export default EmberObject.extend({ @param path {String} */ replaceURL(path) { - var state = this.getState(); + let state = this.getState(); path = this.formatURL(path); if (!state || state.path !== path) { @@ -145,7 +145,7 @@ export default EmberObject.extend({ @param path {String} */ pushState(path) { - var state = { path: path }; + let state = { path: path }; get(this, 'history').pushState(state, null, path); @@ -163,7 +163,7 @@ export default EmberObject.extend({ @param path {String} */ replaceState(path) { - var state = { path: path }; + let state = { path: path }; get(this, 'history').replaceState(state, null, path); this._historyState = state; @@ -181,7 +181,7 @@ export default EmberObject.extend({ @param callback {Function} */ onUpdateURL(callback) { - var guid = guidFor(this); + let guid = guidFor(this); jQuery(window).on(`popstate.ember-location-${guid}`, (e) => { // Ignore initial page load popstate event in Chrome @@ -202,8 +202,8 @@ export default EmberObject.extend({ @return formatted url {String} */ formatURL(url) { - var rootURL = get(this, 'rootURL'); - var baseURL = get(this, 'baseURL'); + let rootURL = get(this, 'rootURL'); + let baseURL = get(this, 'baseURL'); if (url !== '') { // remove trailing slashes if they exists @@ -225,7 +225,7 @@ export default EmberObject.extend({ @method willDestroy */ willDestroy() { - var guid = guidFor(this); + let guid = guidFor(this); jQuery(window).off(`popstate.ember-location-${guid}`); }, diff --git a/packages/ember-routing/lib/services/routing.js b/packages/ember-routing/lib/services/routing.js index 036104787f5..bffc16cec90 100644 --- a/packages/ember-routing/lib/services/routing.js +++ b/packages/ember-routing/lib/services/routing.js @@ -38,9 +38,9 @@ export default Service.extend({ }, transitionTo(routeName, models, queryParams, shouldReplace) { - var router = get(this, 'router'); + let router = get(this, 'router'); - var transition = router._doTransition(routeName, models, queryParams); + let transition = router._doTransition(routeName, models, queryParams); if (shouldReplace) { transition.method('replace'); @@ -50,29 +50,29 @@ export default Service.extend({ }, normalizeQueryParams(routeName, models, queryParams) { - var router = get(this, 'router'); + let router = get(this, 'router'); router._prepareQueryParams(routeName, models, queryParams); }, generateURL(routeName, models, queryParams) { - var router = get(this, 'router'); + let router = get(this, 'router'); if (!router.router) { return; } - var visibleQueryParams = {}; + let visibleQueryParams = {}; assign(visibleQueryParams, queryParams); this.normalizeQueryParams(routeName, models, visibleQueryParams); - var args = routeArgs(routeName, models, visibleQueryParams); + let args = routeArgs(routeName, models, visibleQueryParams); return router.generate.apply(router, args); }, isActiveForRoute(contexts, queryParams, routeName, routerState, isCurrentWhenSpecified) { - var router = get(this, 'router'); + let router = get(this, 'router'); - var handlers = router.router.recognizer.handlersFor(routeName); - var leafName = handlers[handlers.length - 1].handler; - var maximumContexts = numberOfContextsAcceptedByHandler(routeName, handlers); + let handlers = router.router.recognizer.handlersFor(routeName); + let leafName = handlers[handlers.length - 1].handler; + let maximumContexts = numberOfContextsAcceptedByHandler(routeName, handlers); // NOTE: any ugliness in the calculation of activeness is largely // due to the fact that we support automatic normalizing of @@ -93,8 +93,8 @@ export default Service.extend({ }); function numberOfContextsAcceptedByHandler(handler, handlerInfos) { - var req = 0; - for (var i = 0; i < handlerInfos.length; i++) { + let req = 0; + for (let i = 0; i < handlerInfos.length; i++) { req = req + handlerInfos[i].names.length; if (handlerInfos[i].handler === handler) { break; diff --git a/packages/ember-routing/lib/system/cache.js b/packages/ember-routing/lib/system/cache.js index db999b429a0..c0a0ed6197a 100644 --- a/packages/ember-routing/lib/system/cache.js +++ b/packages/ember-routing/lib/system/cache.js @@ -8,23 +8,22 @@ export default EmberObject.extend({ return bucketKey in this.cache; }, stash(bucketKey, key, value) { - var bucket = this.cache[bucketKey]; + let bucket = this.cache[bucketKey]; if (!bucket) { bucket = this.cache[bucketKey] = {}; } bucket[key] = value; }, lookup(bucketKey, prop, defaultValue) { - var cache = this.cache; + let cache = this.cache; if (!(bucketKey in cache)) { return defaultValue; } - var bucket = cache[bucketKey]; + let bucket = cache[bucketKey]; if (prop in bucket) { return bucket[prop]; } else { return defaultValue; } - }, - cache: null + } }); diff --git a/packages/ember-routing/lib/system/dsl.js b/packages/ember-routing/lib/system/dsl.js index d1d5621a4bd..b1b9eb2db6e 100644 --- a/packages/ember-routing/lib/system/dsl.js +++ b/packages/ember-routing/lib/system/dsl.js @@ -22,7 +22,7 @@ export default DSL; DSL.prototype = { route(name, options, callback) { - var dummyErrorRoute = `/_unused_dummy_error_path_route_${name}/:error`; + let dummyErrorRoute = `/_unused_dummy_error_path_route_${name}/:error`; if (arguments.length === 2 && typeof options === 'function') { callback = options; options = {}; @@ -51,8 +51,8 @@ DSL.prototype = { } if (callback) { - var fullName = getFullName(this, name, options.resetNamespace); - var dsl = new DSL(fullName, this.options); + let fullName = getFullName(this, name, options.resetNamespace); + let dsl = new DSL(fullName, this.options); createRoute(dsl, 'loading'); createRoute(dsl, 'error', { path: dummyErrorRoute }); @@ -66,7 +66,7 @@ DSL.prototype = { }, push(url, name, callback) { - var parts = name.split('.'); + let parts = name.split('.'); if (url === '' || url === '/' || parts[parts.length - 1] === 'index') { this.explicitIndex = true; } this.matches.push([url, name, callback]); @@ -88,15 +88,15 @@ DSL.prototype = { }, generate() { - var dslMatches = this.matches; + let dslMatches = this.matches; if (!this.explicitIndex) { this.route('index', { path: '/' }); } - return function(match) { - for (var i = 0; i < dslMatches.length; i++) { - var dslMatch = dslMatches[i]; + return match => { + for (let i = 0; i < dslMatches.length; i++) { + let dslMatch = dslMatches[i]; match(dslMatch[0]).to(dslMatch[1], dslMatch[2]); } }; @@ -118,7 +118,7 @@ function getFullName(dsl, name, resetNamespace) { function createRoute(dsl, name, options, callback) { options = options || {}; - var fullName = getFullName(dsl, name, options.resetNamespace); + let fullName = getFullName(dsl, name, options.resetNamespace); if (typeof options.path !== 'string') { options.path = `/${name}`; @@ -128,7 +128,7 @@ function createRoute(dsl, name, options, callback) { } DSL.map = function(callback) { - var dsl = new DSL(); + let dsl = new DSL(); callback.call(dsl); return dsl; }; diff --git a/packages/ember-routing/lib/system/generate_controller.js b/packages/ember-routing/lib/system/generate_controller.js index 39e9728d1d5..79e4551598b 100644 --- a/packages/ember-routing/lib/system/generate_controller.js +++ b/packages/ember-routing/lib/system/generate_controller.js @@ -15,16 +15,14 @@ import { get } from 'ember-metal/property_get'; */ export function generateControllerFactory(owner, controllerName, context) { - var Factory, fullName; - - Factory = owner._lookupFactory('controller:basic').extend({ + let Factory = owner._lookupFactory('controller:basic').extend({ isGenerated: true, toString() { return `(generated ${controllerName} controller)`; } }); - fullName = `controller:${controllerName}`; + let fullName = `controller:${controllerName}`; owner.register(fullName, Factory); @@ -47,8 +45,8 @@ export function generateControllerFactory(owner, controllerName, context) { export default function generateController(owner, controllerName, context) { generateControllerFactory(owner, controllerName, context); - var fullName = `controller:${controllerName}`; - var instance = owner.lookup(fullName); + let fullName = `controller:${controllerName}`; + let instance = owner.lookup(fullName); if (get(instance, 'namespace.LOG_ACTIVE_GENERATION')) { info(`generated -> ${fullName}`, { fullName: fullName }); diff --git a/packages/ember-routing/lib/system/route.js b/packages/ember-routing/lib/system/route.js index fc7c422355a..cca2f3646d2 100644 --- a/packages/ember-routing/lib/system/route.js +++ b/packages/ember-routing/lib/system/route.js @@ -32,7 +32,7 @@ import { import { getOwner } from 'container/owner'; import isEmpty from 'ember-metal/is_empty'; import symbol from 'ember-metal/symbol'; -var slice = Array.prototype.slice; +const { slice } = Array.prototype; function K() { return this; } @@ -40,8 +40,8 @@ function defaultSerialize(model, params) { if (params.length < 1) { return; } if (!model) { return; } - var name = params[0]; - var object = {}; + let name = params[0]; + let object = {}; if (params.length === 1) { if (name in model) { @@ -82,7 +82,7 @@ export function hasDefaultSerialize(route) { @uses Ember.Evented @public */ -var Route = EmberObject.extend(ActionHandler, Evented, { +let Route = EmberObject.extend(ActionHandler, Evented, { /** Configuration hash for this route's queryParams. The possible configuration options and their defaults are as follows @@ -146,12 +146,12 @@ var Route = EmberObject.extend(ActionHandler, Evented, { @property _qp */ _qp: computed(function() { - var controllerProto, combinedQueryParameterConfiguration; + let controllerProto, combinedQueryParameterConfiguration; - var controllerName = this.controllerName || this.routeName; - var definedControllerClass = getOwner(this)._lookupFactory(`controller:${controllerName}`); - var queryParameterConfiguraton = get(this, 'queryParams'); - var hasRouterDefinedQueryParams = !!Object.keys(queryParameterConfiguraton).length; + let controllerName = this.controllerName || this.routeName; + let definedControllerClass = getOwner(this)._lookupFactory(`controller:${controllerName}`); + let queryParameterConfiguraton = get(this, 'queryParams'); + let hasRouterDefinedQueryParams = !!Object.keys(queryParameterConfiguraton).length; if (definedControllerClass) { // the developer has authored a controller class in their application for this route @@ -160,8 +160,8 @@ var Route = EmberObject.extend(ActionHandler, Evented, { // at least `{}` controllerProto = definedControllerClass.proto(); - var controllerDefinedQueryParameterConfiguration = get(controllerProto, 'queryParams'); - var normalizedControllerQueryParameterConfiguration = normalizeControllerQueryParams(controllerDefinedQueryParameterConfiguration); + let controllerDefinedQueryParameterConfiguration = get(controllerProto, 'queryParams'); + let normalizedControllerQueryParameterConfiguration = normalizeControllerQueryParams(controllerDefinedQueryParameterConfiguration); combinedQueryParameterConfiguration = mergeEachQueryParams(normalizedControllerQueryParameterConfiguration, queryParameterConfiguraton); if (isEnabled('ember-routing-route-configured-query-params')) { @@ -172,16 +172,16 @@ var Route = EmberObject.extend(ActionHandler, Evented, { } else if (hasRouterDefinedQueryParams) { // the developer has not defined a controller but *has* supplied route query params. // Generate a class for them so we can later insert default values - var generatedControllerClass = generateControllerFactory(getOwner(this), controllerName); + let generatedControllerClass = generateControllerFactory(getOwner(this), controllerName); controllerProto = generatedControllerClass.proto(); combinedQueryParameterConfiguration = queryParameterConfiguraton; } - var qps = []; - var map = {}; - var propertyNames = []; + let qps = []; + let map = {}; + let propertyNames = []; - for (var propName in combinedQueryParameterConfiguration) { + for (let propName in combinedQueryParameterConfiguration) { if (!combinedQueryParameterConfiguration.hasOwnProperty(propName)) { continue; } // to support the dubious feature of using unknownProperty @@ -191,7 +191,7 @@ var Route = EmberObject.extend(ActionHandler, Evented, { continue; } - var desc = combinedQueryParameterConfiguration[propName]; + let desc = combinedQueryParameterConfiguration[propName]; if (isEnabled('ember-routing-route-configured-query-params')) { // apply default values to controllers @@ -206,25 +206,25 @@ var Route = EmberObject.extend(ActionHandler, Evented, { } } - var scope = desc.scope || 'model'; - var parts; + let scope = desc.scope || 'model'; + let parts; if (scope === 'controller') { parts = []; } - var urlKey = desc.as || this.serializeQueryParamKey(propName); - var defaultValue = get(controllerProto, propName); + let urlKey = desc.as || this.serializeQueryParamKey(propName); + let defaultValue = get(controllerProto, propName); if (Array.isArray(defaultValue)) { defaultValue = emberA(defaultValue.slice()); } - var type = desc.type || typeOf(defaultValue); + let type = desc.type || typeOf(defaultValue); - var defaultValueSerialized = this.serializeQueryParam(defaultValue, urlKey, type); - var scopedPropertyName = `${controllerName}:${propName}`; - var qp = { + let defaultValueSerialized = this.serializeQueryParam(defaultValue, urlKey, type); + let scopedPropertyName = `${controllerName}:${propName}`; + let qp = { undecoratedDefaultValue: get(controllerProto, propName), defaultValue: defaultValue, serializedDefaultValue: defaultValueSerialized, @@ -258,7 +258,7 @@ var Route = EmberObject.extend(ActionHandler, Evented, { in the active route hierarchy. */ inactive: (prop, value) => { - var qp = map[prop]; + let qp = map[prop]; this._qpChanged(prop, value, qp); }, /* @@ -267,7 +267,7 @@ var Route = EmberObject.extend(ActionHandler, Evented, { in the active route hierarchy. */ active: (prop, value) => { - var qp = map[prop]; + let qp = map[prop]; this._qpChanged(prop, value, qp); return this._activeQPChanged(map[prop], value); }, @@ -276,7 +276,7 @@ var Route = EmberObject.extend(ActionHandler, Evented, { and the route is currently in the active route hierarchy. */ allowOverrides: (prop, value) => { - var qp = map[prop]; + let qp = map[prop]; this._qpChanged(prop, value, qp); return this._updatingQPChanged(map[prop]); } @@ -297,24 +297,24 @@ var Route = EmberObject.extend(ActionHandler, Evented, { @method _stashNames */ _stashNames(_handlerInfo, dynamicParent) { - var handlerInfo = _handlerInfo; + let handlerInfo = _handlerInfo; if (this._names) { return; } - var names = this._names = handlerInfo._names; + let names = this._names = handlerInfo._names; if (!names.length) { handlerInfo = dynamicParent; names = handlerInfo && handlerInfo._names || []; } - var qps = get(this, '_qp.qps'); + let qps = get(this, '_qp.qps'); - var namePaths = new Array(names.length); - for (var a = 0; a < names.length; ++a) { + let namePaths = new Array(names.length); + for (let a = 0; a < names.length; ++a) { namePaths[a] = `${handlerInfo.name}.${names[a]}`; } - for (var i = 0; i < qps.length; ++i) { - var qp = qps[i]; + for (let i = 0; i < qps.length; ++i) { + let qp = qps[i]; if (qp.scope === 'model') { qp.parts = namePaths; } @@ -328,7 +328,7 @@ var Route = EmberObject.extend(ActionHandler, Evented, { @property _activeQPChanged */ _activeQPChanged(qp, value) { - var router = this.router; + let router = this.router; router._activeQPChanged(qp.scopedPropertyName, value); }, @@ -337,7 +337,7 @@ var Route = EmberObject.extend(ActionHandler, Evented, { @method _updatingQPChanged */ _updatingQPChanged(qp) { - var router = this.router; + let router = this.router; router._updatingQPChanged(qp.urlKey); }, @@ -352,16 +352,16 @@ var Route = EmberObject.extend(ActionHandler, Evented, { @public */ paramsFor(name) { - var route = getOwner(this).lookup(`route:${name}`); + let route = getOwner(this).lookup(`route:${name}`); if (!route) { return {}; } - var transition = this.router.router.activeTransition; - var state = transition ? transition.state : this.router.router.state; + let transition = this.router.router.activeTransition; + let state = transition ? transition.state : this.router.router.state; - var params = {}; + let params = {}; assign(params, state.params[name]); assign(params, getQueryParamsFor(route, state)); @@ -476,7 +476,7 @@ var Route = EmberObject.extend(ActionHandler, Evented, { @since 1.7.0 */ _reset(isExiting, transition) { - var controller = this.controller; + let controller = this.controller; controller._qpDelegate = get(this, '_qp.states.inactive'); this.resetController(controller, isExiting, transition); @@ -498,7 +498,7 @@ var Route = EmberObject.extend(ActionHandler, Evented, { template. ```javascript - var PostsList = Ember.Route.extend({ + let PostsList = Ember.Route.extend({ templateName: 'posts/list' }); @@ -759,11 +759,11 @@ var Route = EmberObject.extend(ActionHandler, Evented, { @private */ queryParamsDidChange(changed, totalPresent, removed) { - var qpMap = get(this, '_qp').map; + let qpMap = get(this, '_qp').map; - var totalChanged = Object.keys(changed).concat(Object.keys(removed)); - for (var i = 0; i < totalChanged.length; ++i) { - var qp = qpMap[totalChanged[i]]; + let totalChanged = Object.keys(changed).concat(Object.keys(removed)); + for (let i = 0; i < totalChanged.length; ++i) { + let qp = qpMap[totalChanged[i]]; if (qp && get(this._optionsForQueryParam(qp), 'refreshModel') && this.router.currentState) { this.refresh(); } @@ -778,24 +778,24 @@ var Route = EmberObject.extend(ActionHandler, Evented, { // Transition object is absent for intermediate transitions. if (!transition) { return; } - var handlerInfos = transition.state.handlerInfos; - var router = this.router; - var qpMeta = router._queryParamsFor(handlerInfos[handlerInfos.length - 1].name); - var changes = router._qpUpdates; - var replaceUrl; + let handlerInfos = transition.state.handlerInfos; + let router = this.router; + let qpMeta = router._queryParamsFor(handlerInfos[handlerInfos.length - 1].name); + let changes = router._qpUpdates; + let replaceUrl; stashParamNames(router, handlerInfos); - for (var i = 0; i < qpMeta.qps.length; ++i) { - var qp = qpMeta.qps[i]; - var route = qp.route; - var controller = route.controller; - var presentKey = qp.urlKey in params && qp.urlKey; + for (let i = 0; i < qpMeta.qps.length; ++i) { + let qp = qpMeta.qps[i]; + let route = qp.route; + let controller = route.controller; + let presentKey = qp.urlKey in params && qp.urlKey; // Do a reverse lookup to see if the changed query // param URL key corresponds to a QP property on // this controller. - var value, svalue; + let value, svalue; if (changes && qp.urlKey in changes) { // Value updated in/before setupController value = get(controller, qp.prop); @@ -814,11 +814,11 @@ var Route = EmberObject.extend(ActionHandler, Evented, { controller._qpDelegate = get(route, '_qp.states.inactive'); - var thisQueryParamChanged = (svalue !== qp.serializedValue); + let thisQueryParamChanged = (svalue !== qp.serializedValue); if (thisQueryParamChanged) { if (transition.queryParamsOnly && replaceUrl !== false) { - var options = route._optionsForQueryParam(qp); - var replaceConfigValue = get(options, 'replace'); + let options = route._optionsForQueryParam(qp); + let replaceConfigValue = get(options, 'replace'); if (replaceConfigValue) { replaceUrl = true; } else if (replaceConfigValue === false) { @@ -833,7 +833,7 @@ var Route = EmberObject.extend(ActionHandler, Evented, { // Stash current serialized value of controller. qp.serializedValue = svalue; - var thisQueryParamHasDefaultValue = (qp.serializedDefaultValue === svalue); + let thisQueryParamHasDefaultValue = (qp.serializedDefaultValue === svalue); if (!thisQueryParamHasDefaultValue) { finalParams.push({ value: svalue, @@ -848,8 +848,8 @@ var Route = EmberObject.extend(ActionHandler, Evented, { } qpMeta.qps.forEach(function(qp) { - var routeQpMeta = get(qp.route, '_qp'); - var finalizedController = qp.route.controller; + let routeQpMeta = get(qp.route, '_qp'); + let finalizedController = qp.route.controller; finalizedController._qpDelegate = get(routeQpMeta, 'states.active'); }); @@ -992,8 +992,8 @@ var Route = EmberObject.extend(ActionHandler, Evented, { App.IndexRoute = Ember.Route.extend({ actions: { moveToChocolateCereal: function() { - var cereal = { cerealId: 'ChocolateYumminess' }; - var breakfast = { breakfastId: 'CerealAndMilk' }; + let cereal = { cerealId: 'ChocolateYumminess' }; + let breakfast = { breakfastId: 'CerealAndMilk' }; this.transitionTo('cereal', breakfast, cereal); } @@ -1030,7 +1030,7 @@ var Route = EmberObject.extend(ActionHandler, Evented, { @public */ transitionTo(name, context) { - var router = this.router; + let router = this.router; return router.transitionTo(...arguments); }, @@ -1052,7 +1052,7 @@ var Route = EmberObject.extend(ActionHandler, Evented, { @public */ intermediateTransitionTo() { - var router = this.router; + let router = this.router; router.intermediateTransitionTo(...arguments); }, @@ -1114,7 +1114,7 @@ var Route = EmberObject.extend(ActionHandler, Evented, { @public */ replaceWith() { - var router = this.router; + let router = this.router; return router.replaceWith(...arguments); }, @@ -1157,9 +1157,9 @@ var Route = EmberObject.extend(ActionHandler, Evented, { if ((this.router && this.router.router) || !isTesting()) { this.router.send(...args); } else { - var name = args[0]; + let name = args[0]; args = slice.call(args, 1); - var action = this.actions[name]; + let action = this.actions[name]; if (action) { return this.actions[name].apply(this, args); } @@ -1173,10 +1173,10 @@ var Route = EmberObject.extend(ActionHandler, Evented, { @method setup */ setup(context, transition) { - var controller; + let controller; - var controllerName = this.controllerName || this.routeName; - var definedController = this.controllerFor(controllerName, true); + let controllerName = this.controllerName || this.routeName; + let definedController = this.controllerFor(controllerName, true); if (!definedController) { controller = this.generateController(controllerName, context); @@ -1187,30 +1187,30 @@ var Route = EmberObject.extend(ActionHandler, Evented, { // Assign the route's controller so that it can more easily be // referenced in action handlers. Side effects. Side effects everywhere. if (!this.controller) { - var propNames = get(this, '_qp.propertyNames'); + let propNames = get(this, '_qp.propertyNames'); addQueryParamsObservers(controller, propNames); this.controller = controller; } - var queryParams = get(this, '_qp'); + let queryParams = get(this, '_qp'); - var states = queryParams.states; + let states = queryParams.states; if (transition) { // Update the model dep values used to calculate cache keys. stashParamNames(this.router, transition.state.handlerInfos); - var params = transition.params; - var allParams = queryParams.propertyNames; - var cache = this._bucketCache; + let params = transition.params; + let allParams = queryParams.propertyNames; + let cache = this._bucketCache; allParams.forEach(function(prop) { - var aQp = queryParams.map[prop]; + let aQp = queryParams.map[prop]; aQp.values = params; - var cacheKey = calculateCacheKey(aQp.prefix, aQp.parts, aQp.values); + let cacheKey = calculateCacheKey(aQp.prefix, aQp.parts, aQp.values); if (cache) { - var value = cache.lookup(cacheKey, prop, aQp.undecoratedDefaultValue); + let value = cache.lookup(cacheKey, prop, aQp.undecoratedDefaultValue); set(controller, prop, value); } }); @@ -1219,7 +1219,7 @@ var Route = EmberObject.extend(ActionHandler, Evented, { controller._qpDelegate = states.allowOverrides; if (transition) { - var qpValues = getQueryParamsFor(this, transition.state); + let qpValues = getQueryParamsFor(this, transition.state); controller.setProperties(qpValues); } @@ -1238,10 +1238,10 @@ var Route = EmberObject.extend(ActionHandler, Evented, { _qpChanged(prop, value, qp) { if (!qp) { return; } - var cacheKey = calculateCacheKey(qp.prefix || '', qp.parts, qp.values); + let cacheKey = calculateCacheKey(qp.prefix || '', qp.parts, qp.values); // Update model-dep cache - var cache = this._bucketCache; + let cache = this._bucketCache; if (cache) { cache.stash(cacheKey, prop, value); } @@ -1294,7 +1294,7 @@ var Route = EmberObject.extend(ActionHandler, Evented, { App.PostRoute = Ember.Route.extend({ beforeModel: function(transition) { if (!App.Post) { - var self = this; + let self = this; return Ember.$.getScript('post.js').then(null, function(e) { self.transitionTo('help'); @@ -1467,10 +1467,10 @@ var Route = EmberObject.extend(ActionHandler, Evented, { @public */ model(params, transition) { - var match, name, sawParams, value; - var queryParams = get(this, '_qp.map'); + let match, name, sawParams, value; + let queryParams = get(this, '_qp.map'); - for (var prop in params) { + for (let prop in params) { if (prop === 'queryParams' || (queryParams && prop in queryParams)) { continue; } @@ -1487,7 +1487,7 @@ var Route = EmberObject.extend(ActionHandler, Evented, { } else if (!name) { if (transition.resolveIndex < 1) { return; } - var parentModel = transition.state.handlerInfos[transition.resolveIndex - 1].context; + let parentModel = transition.state.handlerInfos[transition.resolveIndex - 1].context; return parentModel; } @@ -1516,7 +1516,7 @@ var Route = EmberObject.extend(ActionHandler, Evented, { @private */ findModel() { - var store = get(this, 'store'); + let store = get(this, 'store'); return store.find(...arguments); }, @@ -1535,13 +1535,13 @@ var Route = EmberObject.extend(ActionHandler, Evented, { @private */ store: computed(function() { - var owner = getOwner(this); - var routeName = this.routeName; - var namespace = get(this, 'router.namespace'); + let owner = getOwner(this); + let routeName = this.routeName; + let namespace = get(this, 'router.namespace'); return { find(name, value) { - var modelClass = owner._lookupFactory(`model:${name}`); + let modelClass = owner._lookupFactory(`model:${name}`); assert( `You used the dynamic segment ${name}_id in your route ${routeName}, but ${namespace}.${classify(name)} did not exist and you did not override your route's \`model\` hook.`, !!modelClass); @@ -1682,9 +1682,9 @@ var Route = EmberObject.extend(ActionHandler, Evented, { @public */ controllerFor(name, _skipAssert) { - var owner = getOwner(this); - var route = owner.lookup(`route:${name}`); - var controller; + let owner = getOwner(this); + let route = owner.lookup(`route:${name}`); + let controller; if (route && route.controllerName) { name = route.controllerName; @@ -1720,7 +1720,7 @@ var Route = EmberObject.extend(ActionHandler, Evented, { @private */ generateController(name, model) { - var owner = getOwner(this); + let owner = getOwner(this); model = model || this.modelFor(name); @@ -1759,13 +1759,13 @@ var Route = EmberObject.extend(ActionHandler, Evented, { @public */ modelFor(name) { - var route = getOwner(this).lookup(`route:${name}`); - var transition = this.router ? this.router.router.activeTransition : null; + let route = getOwner(this).lookup(`route:${name}`); + let transition = this.router ? this.router.router.activeTransition : null; // If we are mid-transition, we want to try and look up // resolved parent contexts on the current transitionEvent. if (transition) { - var modelLookupName = (route && route.routeName) || name; + let modelLookupName = (route && route.routeName) || name; if (transition.resolvedModels.hasOwnProperty(modelLookupName)) { return transition.resolvedModels[modelLookupName]; } @@ -1787,7 +1787,7 @@ var Route = EmberObject.extend(ActionHandler, Evented, { ```javascript App.PostsRoute = Ember.Route.extend({ renderTemplate: function(controller, model) { - var favController = this.controllerFor('favoritePost'); + let favController = this.controllerFor('favoritePost'); // Render the `favoritePost` template into // the outlet `posts`, and display the `favoritePost` @@ -1929,9 +1929,9 @@ var Route = EmberObject.extend(ActionHandler, Evented, { render(_name, options) { assert('The name in the given arguments is undefined', arguments.length > 0 ? !isNone(arguments[0]) : true); - var namePassed = typeof _name === 'string' && !!_name; - var isDefaultRender = arguments.length === 0 || isEmpty(arguments[0]); - var name; + let namePassed = typeof _name === 'string' && !!_name; + let isDefaultRender = arguments.length === 0 || isEmpty(arguments[0]); + let name; if (typeof _name === 'object' && !options) { name = this.routeName; @@ -1940,7 +1940,7 @@ var Route = EmberObject.extend(ActionHandler, Evented, { name = _name; } - var renderOptions = buildRenderOptions(this, namePassed, isDefaultRender, name, options); + let renderOptions = buildRenderOptions(this, namePassed, isDefaultRender, name, options); this.connections.push(renderOptions); run.once(this.router, '_setOutlets'); }, @@ -1990,8 +1990,8 @@ var Route = EmberObject.extend(ActionHandler, Evented, { @public */ disconnectOutlet(options) { - var outletName; - var parentView; + let outletName; + let parentView; if (!options || typeof options === 'string') { outletName = options; } else { @@ -2005,7 +2005,7 @@ var Route = EmberObject.extend(ActionHandler, Evented, { parentView = parentView && parentView.replace(/\//g, '.'); outletName = outletName || 'main'; this._disconnectOutlet(outletName, parentView); - for (var i = 0; i < this.router.router.currentHandlerInfos.length; i++) { + for (let i = 0; i < this.router.router.currentHandlerInfos.length; i++) { // This non-local state munging is sadly necessary to maintain // backward compatibility with our existing semantics, which allow // any route to disconnectOutlet things originally rendered by any @@ -2016,12 +2016,12 @@ var Route = EmberObject.extend(ActionHandler, Evented, { }, _disconnectOutlet(outletName, parentView) { - var parent = parentRoute(this); + let parent = parentRoute(this); if (parent && parentView === parent.routeName) { parentView = undefined; } - for (var i = 0; i < this.connections.length; i++) { - var connection = this.connections[i]; + for (let i = 0; i < this.connections.length; i++) { + let connection = this.connections[i]; if (connection.outlet === outletName && connection.into === parentView) { // This neuters the disconnected outlet such that it doesn't // render anything, but it leaves an entry in the outlet @@ -2067,16 +2067,16 @@ Route.reopenClass({ }); function parentRoute(route) { - var handlerInfo = handlerInfoFor(route, route.router.router.state.handlerInfos, -1); + let handlerInfo = handlerInfoFor(route, route.router.router.state.handlerInfos, -1); return handlerInfo && handlerInfo.handler; } function handlerInfoFor(route, handlerInfos, _offset) { if (!handlerInfos) { return; } - var offset = _offset || 0; - var current; - for (var i = 0; i < handlerInfos.length; i++) { + let offset = _offset || 0; + let current; + for (let i = 0; i < handlerInfos.length; i++) { current = handlerInfos[i].handler; if (current === route) { return handlerInfos[i + offset]; } } @@ -2154,29 +2154,29 @@ function getFullQueryParams(router, state) { state.fullQueryParams = {}; assign(state.fullQueryParams, state.queryParams); - var targetRouteName = state.handlerInfos[state.handlerInfos.length - 1].name; + let targetRouteName = state.handlerInfos[state.handlerInfos.length - 1].name; router._deserializeQueryParams(targetRouteName, state.fullQueryParams); return state.fullQueryParams; } function getQueryParamsFor(route, state) { state.queryParamsFor = state.queryParamsFor || {}; - var name = route.routeName; + let name = route.routeName; if (state.queryParamsFor[name]) { return state.queryParamsFor[name]; } - var fullQueryParams = getFullQueryParams(route.router, state); + let fullQueryParams = getFullQueryParams(route.router, state); - var params = state.queryParamsFor[name] = {}; + let params = state.queryParamsFor[name] = {}; // Copy over all the query params for this route/controller into params hash. - var qpMeta = get(route, '_qp'); - var qps = qpMeta.qps; - for (var i = 0; i < qps.length; ++i) { + let qpMeta = get(route, '_qp'); + let qps = qpMeta.qps; + for (let i = 0; i < qps.length; ++i) { // Put deserialized qp on params hash. - var qp = qps[i]; + let qp = qps[i]; - var qpValueWasPassedIn = (qp.prop in fullQueryParams); + let qpValueWasPassedIn = (qp.prop in fullQueryParams); params[qp.prop] = qpValueWasPassedIn ? fullQueryParams[qp.prop] : copyDefaultValue(qp.defaultValue); @@ -2198,8 +2198,8 @@ function copyDefaultValue(value) { the existing objects. */ function mergeEachQueryParams(controllerQP, routeQP) { - var keysAlreadyMergedOrSkippable; - var qps = {}; + let keysAlreadyMergedOrSkippable; + let qps = {}; if (isEnabled('ember-routing-route-configured-query-params')) { keysAlreadyMergedOrSkippable = {}; @@ -2214,10 +2214,10 @@ function mergeEachQueryParams(controllerQP, routeQP) { // first loop over all controller qps, merging them with any matching route qps // into a new empty object to avoid mutating. - for (var cqpName in controllerQP) { + for (let cqpName in controllerQP) { if (!controllerQP.hasOwnProperty(cqpName)) { continue; } - var newControllerParameterConfiguration = {}; + let newControllerParameterConfiguration = {}; assign(newControllerParameterConfiguration, controllerQP[cqpName]); assign(newControllerParameterConfiguration, routeQP[cqpName]); @@ -2229,10 +2229,10 @@ function mergeEachQueryParams(controllerQP, routeQP) { // loop over all route qps, skipping those that were merged in the first pass // because they also appear in controller qps - for (var rqpName in routeQP) { + for (let rqpName in routeQP) { if (!routeQP.hasOwnProperty(rqpName) || keysAlreadyMergedOrSkippable[rqpName]) { continue; } - var newRouteParameterConfiguration = {}; + let newRouteParameterConfiguration = {}; assign(newRouteParameterConfiguration, routeQP[rqpName], controllerQP[rqpName]); qps[rqpName] = newRouteParameterConfiguration; } diff --git a/packages/ember-routing/lib/system/router.js b/packages/ember-routing/lib/system/router.js index 86240f3f2e7..f5a1f4a39e0 100644 --- a/packages/ember-routing/lib/system/router.js +++ b/packages/ember-routing/lib/system/router.js @@ -35,7 +35,7 @@ import 'router/transition'; function K() { return this; } -var slice = [].slice; +const { slice } = Array.prototype; /** @@ -48,7 +48,7 @@ var slice = [].slice; @uses Ember.Evented @public */ -var EmberRouter = EmberObject.extend(Evented, { +const EmberRouter = EmberObject.extend(Evented, { /** The `location` property determines the type of URL's that your application will use. @@ -80,17 +80,17 @@ var EmberRouter = EmberObject.extend(Evented, { rootURL: '/', _initRouterJs() { - var router = this.router = new Router(); + let router = this.router = new Router(); router.triggerEvent = triggerEvent; router._triggerWillChangeContext = K; router._triggerWillLeave = K; - var dslCallbacks = this.constructor.dslCallbacks || [K]; - var dsl = this._buildDSL(); + let dslCallbacks = this.constructor.dslCallbacks || [K]; + let dsl = this._buildDSL(); dsl.route('application', { path: '/', resetNamespace: true, overrideNameAssertion: true }, function() { - for (var i = 0; i < dslCallbacks.length; i++) { + for (let i = 0; i < dslCallbacks.length; i++) { dslCallbacks[i].call(this); } }); @@ -171,13 +171,13 @@ var EmberRouter = EmberObject.extend(Evented, { @private */ startRouting() { - var initialURL = get(this, 'initialURL'); + let initialURL = get(this, 'initialURL'); if (this.setupRouter()) { if (typeof initialURL === 'undefined') { initialURL = get(this, 'location').getURL(); } - var initialTransition = this.handleURL(initialURL); + let initialTransition = this.handleURL(initialURL); if (initialTransition && initialTransition.error) { throw initialTransition.error; } @@ -188,8 +188,8 @@ var EmberRouter = EmberObject.extend(Evented, { this._initRouterJs(); this._setupLocation(); - var router = this.router; - var location = get(this, 'location'); + let router = this.router; + let location = get(this, 'location'); // Allow the Location class to cancel the router setup while it refreshes // the page @@ -216,7 +216,7 @@ var EmberRouter = EmberObject.extend(Evented, { you could use this hook. (Note: requires also including GA scripts, etc.) ```javascript - var Router = Ember.Router.extend({ + let Router = Ember.Router.extend({ location: config.locationType, didTransition: function() { @@ -252,21 +252,21 @@ var EmberRouter = EmberObject.extend(Evented, { }, _setOutlets() { - var handlerInfos = this.router.currentHandlerInfos; - var route; - var defaultParentState; - var liveRoutes = null; + let handlerInfos = this.router.currentHandlerInfos; + let route; + let defaultParentState; + let liveRoutes = null; if (!handlerInfos) { return; } - for (var i = 0; i < handlerInfos.length; i++) { + for (let i = 0; i < handlerInfos.length; i++) { route = handlerInfos[i].handler; - var connections = route.connections; - var ownState; - for (var j = 0; j < connections.length; j++) { - var appended = appendLiveRoute(liveRoutes, defaultParentState, connections[j]); + let connections = route.connections; + let ownState; + for (let j = 0; j < connections.length; j++) { + let appended = appendLiveRoute(liveRoutes, defaultParentState, connections[j]); liveRoutes = appended.liveRoutes; if (appended.ownState.render.name === route.routeName || appended.ownState.render.outlet === 'main') { ownState = appended.ownState; @@ -279,10 +279,10 @@ var EmberRouter = EmberObject.extend(Evented, { } if (!this._toplevelView) { let owner = getOwner(this); - var OutletView = owner._lookupFactory('view:-outlet'); + let OutletView = owner._lookupFactory('view:-outlet'); this._toplevelView = OutletView.create(); this._toplevelView.setOutletState(liveRoutes); - var instance = owner.lookup('-application-instance:main'); + let instance = owner.lookup('-application-instance:main'); instance.didCreateRootView(this._toplevelView); } else { this._toplevelView.setOutletState(liveRoutes); @@ -315,7 +315,7 @@ var EmberRouter = EmberObject.extend(Evented, { }, _doURLTransition(routerJsMethod, url) { - var transition = this.router[routerJsMethod](url || '/'); + let transition = this.router[routerJsMethod](url || '/'); didBeginTransition(transition, this); return transition; }, @@ -337,19 +337,19 @@ var EmberRouter = EmberObject.extend(Evented, { @public */ transitionTo(...args) { - var queryParams; + let queryParams; if (resemblesURL(args[0])) { return this._doURLTransition('transitionTo', args[0]); } - var possibleQueryParams = args[args.length - 1]; + let possibleQueryParams = args[args.length - 1]; if (possibleQueryParams && possibleQueryParams.hasOwnProperty('queryParams')) { queryParams = args.pop().queryParams; } else { queryParams = {}; } - var targetRouteName = args.shift(); + let targetRouteName = args.shift(); return this._doTransition(targetRouteName, args, queryParams); }, @@ -358,7 +358,7 @@ var EmberRouter = EmberObject.extend(Evented, { updatePaths(this); - var infos = this.router.currentHandlerInfos; + let infos = this.router.currentHandlerInfos; if (get(this, 'namespace').LOG_TRANSITIONS) { Logger.log(`Intermediate-transitioned into '${EmberRouter._routePath(infos)}'`); } @@ -369,7 +369,7 @@ var EmberRouter = EmberObject.extend(Evented, { }, generate() { - var url = this.router.generate(...arguments); + let url = this.router.generate(...arguments); return this.location.formatURL(url); }, @@ -382,7 +382,7 @@ var EmberRouter = EmberObject.extend(Evented, { @private */ isActive(routeName) { - var router = this.router; + let router = this.router; return router.isActive(...arguments); }, @@ -486,7 +486,7 @@ var EmberRouter = EmberObject.extend(Evented, { _connectActiveComponentNode(templateName, componentNode) { assert('cannot connect an activeView that already exists', !this._activeViews[templateName]); - var _activeViews = this._activeViews; + let _activeViews = this._activeViews; function disconnectActiveView() { delete _activeViews[templateName]; } @@ -496,18 +496,18 @@ var EmberRouter = EmberObject.extend(Evented, { }, _setupLocation() { - var location = get(this, 'location'); - var rootURL = get(this, 'rootURL'); + let location = get(this, 'location'); + let rootURL = get(this, 'rootURL'); let owner = getOwner(this); if ('string' === typeof location && owner) { - var resolvedLocation = owner.lookup(`location:${location}`); + let resolvedLocation = owner.lookup(`location:${location}`); if ('undefined' !== typeof resolvedLocation) { location = set(this, 'location', resolvedLocation); } else { // Allow for deprecated registration of custom location API's - var options = { + let options = { implementation: location }; @@ -536,13 +536,13 @@ var EmberRouter = EmberObject.extend(Evented, { }, _getHandlerFunction() { - var seen = new EmptyObject(); + let seen = new EmptyObject(); let owner = getOwner(this); - var DefaultRoute = owner._lookupFactory('route:basic'); + let DefaultRoute = owner._lookupFactory('route:basic'); return (name) => { - var routeName = 'route:' + name; - var handler = owner.lookup(routeName); + let routeName = 'route:' + name; + let handler = owner.lookup(routeName); if (seen[name]) { return handler; @@ -566,10 +566,10 @@ var EmberRouter = EmberObject.extend(Evented, { _getSerializerFunction() { return (name) => { - var serializer = this._serializeMethods[name]; + let serializer = this._serializeMethods[name]; if (!serializer) { - var handler = this.router.getHandler(name); + let handler = this.router.getHandler(name); deprecate( `Defining a serialize function on route '${name}' is deprecated. Instead, define it in the router's map as an option.`, @@ -585,8 +585,8 @@ var EmberRouter = EmberObject.extend(Evented, { }, _setupRouter(router, location) { - var lastURL; - var emberRouter = this; + let lastURL; + let emberRouter = this; router.getHandler = this._getHandlerFunction(); @@ -594,7 +594,7 @@ var EmberRouter = EmberObject.extend(Evented, { router.getSerializer = this._getSerializerFunction(); } - var doUpdateURL = function() { + let doUpdateURL = function() { location.setURL(lastURL); }; @@ -604,7 +604,7 @@ var EmberRouter = EmberObject.extend(Evented, { }; if (location.replaceURL) { - var doReplaceURL = function() { + let doReplaceURL = function() { location.replaceURL(lastURL); }; @@ -624,10 +624,10 @@ var EmberRouter = EmberObject.extend(Evented, { }, _serializeQueryParams(targetRouteName, queryParams) { - var groupedByUrlKey = {}; + let groupedByUrlKey = {}; forEachQueryParam(this, targetRouteName, queryParams, function(key, value, qp) { - var urlKey = qp.urlKey; + let urlKey = qp.urlKey; if (!groupedByUrlKey[urlKey]) { groupedByUrlKey[urlKey] = []; } @@ -638,10 +638,10 @@ var EmberRouter = EmberObject.extend(Evented, { delete queryParams[key]; }); - for (var key in groupedByUrlKey) { - var qps = groupedByUrlKey[key]; + for (let key in groupedByUrlKey) { + let qps = groupedByUrlKey[key]; assert(`You're not allowed to have more than one controller property map to the same query param key, but both \`${qps[0].qp.scopedPropertyName}\` and \`${qps[1] ? qps[1].qp.scopedPropertyName : ''}\` map to \`${qps[0].qp.urlKey}\`. You can fix this by mapping one of the controller properties to a different query param key via the \`as\` config option, e.g. \`${qps[0].qp.prop}: { as: \'other-${qps[0].qp.prop}\' }\``, qps.length <= 1); - var qp = qps[0].qp; + let qp = qps[0].qp; queryParams[qp.urlKey] = qp.route.serializeQueryParam(qps[0].value, qp.urlKey, qp.type); } }, @@ -654,9 +654,9 @@ var EmberRouter = EmberObject.extend(Evented, { }, _pruneDefaultQueryParamValues(targetRouteName, queryParams) { - var qps = this._queryParamsFor(targetRouteName); - for (var key in queryParams) { - var qp = qps.map[key]; + let qps = this._queryParamsFor(targetRouteName); + for (let key in queryParams) { + let qp = qps.map[key]; if (qp && qp.serializedDefaultValue === queryParams[key]) { delete queryParams[key]; } @@ -664,10 +664,10 @@ var EmberRouter = EmberObject.extend(Evented, { }, _doTransition(_targetRouteName, models, _queryParams) { - var targetRouteName = _targetRouteName || getActiveTargetName(this.router); + let targetRouteName = _targetRouteName || getActiveTargetName(this.router); assert(`The route ${targetRouteName} was not found`, targetRouteName && this.router.hasRoute(targetRouteName)); - var queryParams = {}; + let queryParams = {}; // merge in any queryParams from the active transition which could include // queryparams from the url on initial load. if (this.router.activeTransition) { @@ -677,8 +677,8 @@ var EmberRouter = EmberObject.extend(Evented, { assign(queryParams, _queryParams); this._prepareQueryParams(targetRouteName, models, queryParams); - var transitionArgs = routeArgs(targetRouteName, models, queryParams); - var transition = this.router.transitionTo.apply(this.router, transitionArgs); + let transitionArgs = routeArgs(targetRouteName, models, queryParams); + let transition = this.router.transitionTo.apply(this.router, transitionArgs); didBeginTransition(transition, this); @@ -702,20 +702,20 @@ var EmberRouter = EmberObject.extend(Evented, { return this._qpCache[leafRouteName]; } - var map = {}; - var qps = []; + let map = {}; + let qps = []; this._qpCache[leafRouteName] = { map: map, qps: qps }; - var routerjs = this.router; - var recogHandlerInfos = routerjs.recognizer.handlersFor(leafRouteName); + let routerjs = this.router; + let recogHandlerInfos = routerjs.recognizer.handlersFor(leafRouteName); - for (var i = 0; i < recogHandlerInfos.length; ++i) { - var recogHandler = recogHandlerInfos[i]; - var route = routerjs.getHandler(recogHandler.handler); - var qpMeta = get(route, '_qp'); + for (let i = 0; i < recogHandlerInfos.length; ++i) { + let recogHandler = recogHandlerInfos[i]; + let route = routerjs.getHandler(recogHandler.handler); + let qpMeta = get(route, '_qp'); if (!qpMeta) { continue; } @@ -730,19 +730,19 @@ var EmberRouter = EmberObject.extend(Evented, { }, _hydrateUnsuppliedQueryParams(leafRouteName, contexts, queryParams) { - var state = calculatePostTransitionState(this, leafRouteName, contexts); - var handlerInfos = state.handlerInfos; - var appCache = this._bucketCache; + let state = calculatePostTransitionState(this, leafRouteName, contexts); + let handlerInfos = state.handlerInfos; + let appCache = this._bucketCache; stashParamNames(this, handlerInfos); - for (var i = 0; i < handlerInfos.length; ++i) { - var route = handlerInfos[i].handler; - var qpMeta = get(route, '_qp'); + for (let i = 0; i < handlerInfos.length; ++i) { + let route = handlerInfos[i].handler; + let qpMeta = get(route, '_qp'); - for (var j = 0, qpLen = qpMeta.qps.length; j < qpLen; ++j) { - var qp = qpMeta.qps[j]; + for (let j = 0, qpLen = qpMeta.qps.length; j < qpLen; ++j) { + let qp = qpMeta.qps[j]; - var presentProp = qp.prop in queryParams && qp.prop || + let presentProp = qp.prop in queryParams && qp.prop || qp.scopedPropertyName in queryParams && qp.scopedPropertyName; if (presentProp) { @@ -751,7 +751,7 @@ var EmberRouter = EmberObject.extend(Evented, { delete queryParams[presentProp]; } } else { - var cacheKey = calculateCacheKey(qp.ctrl, qp.parts, state.params); + let cacheKey = calculateCacheKey(qp.ctrl, qp.parts, state.params); queryParams[qp.scopedPropertyName] = appCache.lookup(cacheKey, qp.prop, qp.defaultValue); } } @@ -814,11 +814,11 @@ var EmberRouter = EmberObject.extend(Evented, { @private */ function forEachRouteAbove(originRoute, transition, callback) { - var handlerInfos = transition.state.handlerInfos; - var originRouteFound = false; - var handlerInfo, route; + let handlerInfos = transition.state.handlerInfos; + let originRouteFound = false; + let handlerInfo, route; - for (var i = handlerInfos.length - 1; i >= 0; --i) { + for (let i = handlerInfos.length - 1; i >= 0; --i) { handlerInfo = handlerInfos[i]; route = handlerInfo.handler; @@ -838,7 +838,7 @@ function forEachRouteAbove(originRoute, transition, callback) { // These get invoked when an action bubbles above ApplicationRoute // and are not meant to be overridable. -var defaultActionHandlers = { +let defaultActionHandlers = { willResolveModel(transition, originRoute) { originRoute.router._scheduleLoadingEvent(transition, originRoute); @@ -846,10 +846,10 @@ var defaultActionHandlers = { error(error, transition, originRoute) { // Attempt to find an appropriate error substate to enter. - var router = originRoute.router; + let router = originRoute.router; - var tryTopLevel = forEachRouteAbove(originRoute, transition, function(route, childRoute) { - var childErrorRouteName = findChildRouteName(route, childRoute, 'error'); + let tryTopLevel = forEachRouteAbove(originRoute, transition, function(route, childRoute) { + let childErrorRouteName = findChildRouteName(route, childRoute, 'error'); if (childErrorRouteName) { router.intermediateTransitionTo(childErrorRouteName, error); return; @@ -870,10 +870,10 @@ var defaultActionHandlers = { loading(transition, originRoute) { // Attempt to find an appropriate loading substate to enter. - var router = originRoute.router; + let router = originRoute.router; - var tryTopLevel = forEachRouteAbove(originRoute, transition, function(route, childRoute) { - var childLoadingRouteName = findChildRouteName(route, childRoute, 'loading'); + let tryTopLevel = forEachRouteAbove(originRoute, transition, function(route, childRoute) { + let childLoadingRouteName = findChildRouteName(route, childRoute, 'loading'); if (childLoadingRouteName) { router.intermediateTransitionTo(childLoadingRouteName); @@ -897,8 +897,8 @@ var defaultActionHandlers = { }; function logError(_error, initialMessage) { - var errorArgs = []; - var error; + let errorArgs = []; + let error; if (_error && typeof _error === 'object' && typeof _error.errorThrown === 'object') { error = _error.errorThrown; } else { @@ -918,10 +918,10 @@ function logError(_error, initialMessage) { } function findChildRouteName(parentRoute, originatingChildRoute, name) { - var router = parentRoute.router; - var childName; - var targetChildRouteName = originatingChildRoute.routeName.split('.').pop(); - var namespace = parentRoute.routeName === 'application' ? '' : parentRoute.routeName + '.'; + let router = parentRoute.router; + let childName; + let targetChildRouteName = originatingChildRoute.routeName.split('.').pop(); + let namespace = parentRoute.routeName === 'application' ? '' : parentRoute.routeName + '.'; // First, try a named loading state, e.g. 'foo_loading' childName = namespace + targetChildRouteName + '_' + name; @@ -943,17 +943,17 @@ function routeHasBeenDefined(router, name) { } export function triggerEvent(handlerInfos, ignoreFailure, args) { - var name = args.shift(); + let name = args.shift(); if (!handlerInfos) { if (ignoreFailure) { return; } throw new EmberError(`Can't trigger action '${name}' because your app hasn't finished transitioning into its first route. To trigger an action on destination routes during a transition, you can call \`.send()\` on the \`Transition\` object passed to the \`model/beforeModel/afterModel\` hooks.`); } - var eventWasHandled = false; - var handlerInfo, handler; + let eventWasHandled = false; + let handlerInfo, handler; - for (var i = handlerInfos.length - 1; i >= 0; i--) { + for (let i = handlerInfos.length - 1; i >= 0; i--) { handlerInfo = handlerInfos[i]; handler = handlerInfo.handler; @@ -963,7 +963,7 @@ export function triggerEvent(handlerInfos, ignoreFailure, args) { } else { // Should only hit here if a non-bubbling error action is triggered on a route. if (name === 'error') { - var errorId = guidFor(args[0]); + let errorId = guidFor(args[0]); handler.router._markErrorAsHandled(errorId); } return; @@ -982,13 +982,13 @@ export function triggerEvent(handlerInfos, ignoreFailure, args) { } function calculatePostTransitionState(emberRouter, leafRouteName, contexts) { - var routerjs = emberRouter.router; - var state = routerjs.applyIntent(leafRouteName, contexts); - var handlerInfos = state.handlerInfos; - var params = state.params; + let routerjs = emberRouter.router; + let state = routerjs.applyIntent(leafRouteName, contexts); + let handlerInfos = state.handlerInfos; + let params = state.params; - for (var i = 0; i < handlerInfos.length; ++i) { - var handlerInfo = handlerInfos[i]; + for (let i = 0; i < handlerInfos.length; ++i) { + let handlerInfo = handlerInfos[i]; if (!handlerInfo.isResolved) { handlerInfo = handlerInfo.becomeResolved(null, handlerInfo.context); } @@ -1083,14 +1083,14 @@ EmberRouter.reopenClass({ }, _routePath(handlerInfos) { - var path = []; + let path = []; // We have to handle coalescing resource names that // are prefixed with their parent's names, e.g. // ['foo', 'foo.bar.baz'] => 'foo.bar.baz', not 'foo.foo.bar.baz' function intersectionMatches(a1, a2) { - for (var i = 0; i < a1.length; ++i) { + for (let i = 0; i < a1.length; ++i) { if (a1[i] !== a2[i]) { return false; } @@ -1098,8 +1098,8 @@ EmberRouter.reopenClass({ return true; } - var name, nameParts, oldNameParts; - for (var i = 1; i < handlerInfos.length; i++) { + let name, nameParts, oldNameParts; + for (let i = 1; i < handlerInfos.length; i++) { name = handlerInfos[i].name; nameParts = name.split('.'); oldNameParts = slice.call(path); @@ -1119,7 +1119,7 @@ EmberRouter.reopenClass({ }); function didBeginTransition(transition, router) { - var routerState = RouterState.create({ + let routerState = RouterState.create({ emberRouter: router, routerJs: router.router, routerJsState: transition.state @@ -1131,7 +1131,7 @@ function didBeginTransition(transition, router) { router.set('targetState', routerState); transition.promise = transition.catch(function(error) { - var errorId = guidFor(error); + let errorId = guidFor(error); if (router._isErrorHandled(errorId)) { router._clearHandledError(errorId); @@ -1146,12 +1146,12 @@ function resemblesURL(str) { } function forEachQueryParam(router, targetRouteName, queryParams, callback) { - var qpCache = router._queryParamsFor(targetRouteName); + let qpCache = router._queryParamsFor(targetRouteName); - for (var key in queryParams) { + for (let key in queryParams) { if (!queryParams.hasOwnProperty(key)) { continue; } - var value = queryParams[key]; - var qp = qpCache.map[key]; + let value = queryParams[key]; + let qp = qpCache.map[key]; if (qp) { callback(key, value, qp); @@ -1161,22 +1161,22 @@ function forEachQueryParam(router, targetRouteName, queryParams, callback) { function findLiveRoute(liveRoutes, name) { if (!liveRoutes) { return; } - var stack = [liveRoutes]; + let stack = [liveRoutes]; while (stack.length > 0) { - var test = stack.shift(); + let test = stack.shift(); if (test.render.name === name) { return test; } - var outlets = test.outlets; - for (var outletName in outlets) { + let outlets = test.outlets; + for (let outletName in outlets) { stack.push(outlets[outletName]); } } } function appendLiveRoute(liveRoutes, defaultParentState, renderOptions) { - var target; - var myState = { + let target; + let myState = { render: renderOptions, outlets: new EmptyObject() }; @@ -1226,7 +1226,7 @@ function appendOrphan(liveRoutes, into, myState) { function representEmptyRoute(liveRoutes, defaultParentState, route) { // the route didn't render anything - var alreadyAppended = findLiveRoute(liveRoutes, route.routeName); + let alreadyAppended = findLiveRoute(liveRoutes, route.routeName); if (alreadyAppended) { // But some other route has already rendered our default // template, so that becomes the default target for any diff --git a/packages/ember-routing/lib/system/router_state.js b/packages/ember-routing/lib/system/router_state.js index 5684747f07b..b06a9350b5a 100644 --- a/packages/ember-routing/lib/system/router_state.js +++ b/packages/ember-routing/lib/system/router_state.js @@ -2,21 +2,19 @@ import isEmpty from 'ember-metal/is_empty'; import EmberObject from 'ember-runtime/system/object'; import assign from 'ember-metal/assign'; -const keys = Object.keys; - -var RouterState = EmberObject.extend({ +export default EmberObject.extend({ emberRouter: null, routerJs: null, routerJsState: null, isActiveIntent(routeName, models, queryParams, queryParamsMustMatch) { - var state = this.routerJsState; + let state = this.routerJsState; if (!this.routerJs.isActiveIntent(routeName, models, null, state)) { return false; } - var emptyQueryParams = isEmpty(keys(queryParams)); + let emptyQueryParams = isEmpty(Object.keys(queryParams)); if (queryParamsMustMatch && !emptyQueryParams) { - var visibleQueryParams = {}; + let visibleQueryParams = {}; assign(visibleQueryParams, queryParams); this.emberRouter._prepareQueryParams(routeName, models, visibleQueryParams); @@ -28,7 +26,7 @@ var RouterState = EmberObject.extend({ }); function shallowEqual(a, b) { - var k; + let k; for (k in a) { if (a.hasOwnProperty(k) && a[k] !== b[k]) { return false; } } @@ -37,5 +35,3 @@ function shallowEqual(a, b) { } return true; } - -export default RouterState; diff --git a/packages/ember-routing/lib/utils.js b/packages/ember-routing/lib/utils.js index b7ca4747e97..df5aa910a05 100644 --- a/packages/ember-routing/lib/utils.js +++ b/packages/ember-routing/lib/utils.js @@ -1,8 +1,10 @@ import assign from 'ember-metal/assign'; import { get } from 'ember-metal/property_get'; +const ALL_PERIODS_REGEX = /\./g; + export function routeArgs(targetRouteName, models, queryParams) { - var args = []; + let args = []; if (typeof targetRouteName === 'string') { args.push('' + targetRouteName); } @@ -12,7 +14,7 @@ export function routeArgs(targetRouteName, models, queryParams) { } export function getActiveTargetName(router) { - var handlerInfos = router.activeTransition ? + let handlerInfos = router.activeTransition ? router.activeTransition.state.handlerInfos : router.state.handlerInfos; return handlerInfos[handlerInfos.length - 1].name; @@ -25,13 +27,13 @@ export function stashParamNames(router, handlerInfos) { // keeps separate a handlerInfo's list of parameter names depending // on whether a URL transition or named transition is happening. // Hopefully we can remove this in the future. - var targetRouteName = handlerInfos[handlerInfos.length - 1].name; - var recogHandlers = router.router.recognizer.handlersFor(targetRouteName); - var dynamicParent = null; + let targetRouteName = handlerInfos[handlerInfos.length - 1].name; + let recogHandlers = router.router.recognizer.handlersFor(targetRouteName); + let dynamicParent = null; - for (var i = 0; i < handlerInfos.length; ++i) { - var handlerInfo = handlerInfos[i]; - var names = recogHandlers[i].names; + for (let i = 0; i < handlerInfos.length; ++i) { + let handlerInfo = handlerInfos[i]; + let names = recogHandlers[i].names; if (names.length) { dynamicParent = handlerInfo; @@ -39,7 +41,7 @@ export function stashParamNames(router, handlerInfos) { handlerInfo._names = names; - var route = handlerInfo.handler; + let route = handlerInfo.handler; route._stashNames(handlerInfo, dynamicParent); } @@ -56,11 +58,11 @@ function _calculateCacheValuePrefix(prefix, part) { // given : prefix = site.article, part = site.article.id // - returns: site.article. (use get(values[site.article], 'id') to get the dynamic part - used below) - var prefixParts = prefix.split('.'); - var currPrefix = ''; + let prefixParts = prefix.split('.'); + let currPrefix = ''; - for (var i = 0; i < prefixParts.length; i++) { - var currPart = prefixParts.slice(0, i + 1).join('.'); + for (let i = 0; i < prefixParts.length; i++) { + let currPart = prefixParts.slice(0, i + 1).join('.'); if (part.indexOf(currPart) !== 0) { break; } @@ -74,15 +76,15 @@ function _calculateCacheValuePrefix(prefix, part) { Stolen from Controller */ export function calculateCacheKey(prefix, _parts, values) { - var parts = _parts || []; - var suffixes = ''; - for (var i = 0; i < parts.length; ++i) { - var part = parts[i]; - var cacheValuePrefix = _calculateCacheValuePrefix(prefix, part); - var value; + let parts = _parts || []; + let suffixes = ''; + for (let i = 0; i < parts.length; ++i) { + let part = parts[i]; + let cacheValuePrefix = _calculateCacheValuePrefix(prefix, part); + let value; if (values) { if (cacheValuePrefix && cacheValuePrefix in values) { - var partRemovedPrefix = (part.indexOf(cacheValuePrefix) === 0) ? part.substr(cacheValuePrefix.length + 1) : part; + let partRemovedPrefix = (part.indexOf(cacheValuePrefix) === 0) ? part.substr(cacheValuePrefix.length + 1) : part; value = get(values[cacheValuePrefix], partRemovedPrefix); } else { value = get(values, part); @@ -92,7 +94,6 @@ export function calculateCacheKey(prefix, _parts, values) { } return prefix + suffixes.replace(ALL_PERIODS_REGEX, '-'); } -var ALL_PERIODS_REGEX = /\./g; /* @@ -132,9 +133,9 @@ export function normalizeControllerQueryParams(queryParams) { return queryParams._qpMap; } - var qpMap = queryParams._qpMap = {}; + let qpMap = queryParams._qpMap = {}; - for (var i = 0; i < queryParams.length; ++i) { + for (let i = 0; i < queryParams.length; ++i) { accumulateQueryParamDescriptors(queryParams[i], qpMap); } @@ -142,18 +143,18 @@ export function normalizeControllerQueryParams(queryParams) { } function accumulateQueryParamDescriptors(_desc, accum) { - var desc = _desc; - var tmp; + let desc = _desc; + let tmp; if (typeof desc === 'string') { tmp = {}; tmp[desc] = { as: null }; desc = tmp; } - for (var key in desc) { + for (let key in desc) { if (!desc.hasOwnProperty(key)) { return; } - var singleDesc = desc[key]; + let singleDesc = desc[key]; if (typeof singleDesc === 'string') { singleDesc = { as: singleDesc }; } diff --git a/packages/ember-routing/tests/location/auto_location_test.js b/packages/ember-routing/tests/location/auto_location_test.js index bcbf5d63f6d..0001b5202b4 100644 --- a/packages/ember-routing/tests/location/auto_location_test.js +++ b/packages/ember-routing/tests/location/auto_location_test.js @@ -52,7 +52,7 @@ function createLocation(location, history) { return autolocation; } -var location; +let location; QUnit.module('Ember.AutoLocation', { teardown() { @@ -65,13 +65,13 @@ QUnit.module('Ember.AutoLocation', { QUnit.test('AutoLocation should return concrete implementation\'s value for `getURL`', function() { expect(1); - var browserLocation = mockBrowserLocation(); - var browserHistory = mockBrowserHistory(); + let browserLocation = mockBrowserLocation(); + let browserHistory = mockBrowserHistory(); location = createLocation(browserLocation, browserHistory); location.detect(); - var concreteImplementation = get(location, 'concreteImplementation'); + let concreteImplementation = get(location, 'concreteImplementation'); concreteImplementation.getURL = function() { return '/lincoln/park'; @@ -83,8 +83,8 @@ QUnit.test('AutoLocation should return concrete implementation\'s value for `get QUnit.test('AutoLocation should use a HistoryLocation instance when pushStates is supported', function() { expect(1); - var browserLocation = mockBrowserLocation(); - var browserHistory = mockBrowserHistory(); + let browserLocation = mockBrowserLocation(); + let browserHistory = mockBrowserHistory(); location = createLocation(browserLocation, browserHistory); location.detect(); @@ -95,7 +95,7 @@ QUnit.test('AutoLocation should use a HistoryLocation instance when pushStates i QUnit.test('AutoLocation should use a HashLocation instance when pushStates are not supported, but hashchange events are and the URL is already in the HashLocation format', function() { expect(1); - var browserLocation = mockBrowserLocation({ + let browserLocation = mockBrowserLocation({ hash: '#/testd' }); @@ -120,7 +120,7 @@ QUnit.test('AutoLocation should use a NoneLocation instance when neither history QUnit.test('AutoLocation should use an index path (i.e. \'/\') without any location.hash as OK for HashLocation', function() { expect(1); - var browserLocation = mockBrowserLocation({ + let browserLocation = mockBrowserLocation({ href: 'http://test.com/', pathname: '/', hash: '', @@ -143,7 +143,7 @@ QUnit.test('AutoLocation should use an index path (i.e. \'/\') without any locat QUnit.test('AutoLocation should transform the URL for hashchange-only browsers viewing a HistoryLocation-formatted path', function() { expect(3); - var browserLocation = mockBrowserLocation({ + let browserLocation = mockBrowserLocation({ hash: '', hostname: 'test.com', href: 'http://test.com/test', @@ -157,7 +157,7 @@ QUnit.test('AutoLocation should transform the URL for hashchange-only browsers v } }); - var location = createLocation(browserLocation); + let location = createLocation(browserLocation); location.global = { onhashchange() { } }; @@ -171,7 +171,7 @@ QUnit.test('AutoLocation should transform the URL for hashchange-only browsers v QUnit.test('AutoLocation should replace the URL for pushState-supported browsers viewing a HashLocation-formatted url', function() { expect(2); - var browserLocation = mockBrowserLocation({ + let browserLocation = mockBrowserLocation({ hash: '#/test', hostname: 'test.com', href: 'http://test.com/#/test', @@ -181,13 +181,13 @@ QUnit.test('AutoLocation should replace the URL for pushState-supported browsers search: '' }); - var browserHistory = mockBrowserHistory({ + let browserHistory = mockBrowserHistory({ replaceState(state, title, path) { equal(path, '/test', 'history.replaceState should be called with normalized HistoryLocation url'); } }); - var location = createLocation(browserLocation, browserHistory); + let location = createLocation(browserLocation, browserHistory); location.detect(); ok(get(location, 'concreteImplementation'), HistoryLocation); @@ -195,8 +195,8 @@ QUnit.test('AutoLocation should replace the URL for pushState-supported browsers QUnit.test('AutoLocation requires any rootURL given to end in a trailing forward slash', function() { expect(3); - var browserLocation = mockBrowserLocation(); - var expectedMsg = /rootURL must end with a trailing forward slash e.g. "\/app\/"/; + let browserLocation = mockBrowserLocation(); + let expectedMsg = /rootURL must end with a trailing forward slash e.g. "\/app\/"/; location = createLocation(browserLocation); location.rootURL = 'app'; @@ -219,24 +219,24 @@ QUnit.test('AutoLocation requires any rootURL given to end in a trailing forward QUnit.test('AutoLocation provides its rootURL to the concreteImplementation', function() { expect(1); - var browserLocation = mockBrowserLocation({ + let browserLocation = mockBrowserLocation({ pathname: '/some/subdir/derp' }); - var browserHistory = mockBrowserHistory(); + let browserHistory = mockBrowserHistory(); location = createLocation(browserLocation, browserHistory); location.rootURL = '/some/subdir/'; location.detect(); - var concreteLocation = get(location, 'concreteImplementation'); + let concreteLocation = get(location, 'concreteImplementation'); equal(location.rootURL, concreteLocation.rootURL); }); QUnit.test('getHistoryPath() should return a normalized, HistoryLocation-supported path', function() { expect(3); - var browserLocation = mockBrowserLocation({ + let browserLocation = mockBrowserLocation({ href: 'http://test.com/app/about?foo=bar#foo', pathname: '/app/about', search: '?foo=bar', @@ -265,7 +265,7 @@ QUnit.test('getHistoryPath() should return a normalized, HistoryLocation-support QUnit.test('getHashPath() should return a normalized, HashLocation-supported path', function() { expect(3); - var browserLocation = mockBrowserLocation({ + let browserLocation = mockBrowserLocation({ href: 'http://test.com/app/#/about?foo=bar#foo', pathname: '/app/', search: '', diff --git a/packages/ember-routing/tests/location/hash_location_test.js b/packages/ember-routing/tests/location/hash_location_test.js index 1eed7826b3b..107e323317e 100644 --- a/packages/ember-routing/tests/location/hash_location_test.js +++ b/packages/ember-routing/tests/location/hash_location_test.js @@ -4,7 +4,7 @@ import run from 'ember-metal/run_loop'; import HashLocation from 'ember-routing/location/hash_location'; import jQuery from 'ember-views/system/jquery'; -var HashTestLocation, location; +let HashTestLocation, location; function createLocation(options) { if (!options) { options = {}; } @@ -14,11 +14,11 @@ function createLocation(options) { function mockBrowserLocation(path) { // This is a neat trick to auto-magically extract the hostname from any // url by letting the browser do the work ;) - var tmp = document.createElement('a'); + let tmp = document.createElement('a'); tmp.href = path; - var protocol = (!tmp.protocol || tmp.protocol === ':') ? 'http' : tmp.protocol; - var pathname = (tmp.pathname.match(/^\//)) ? tmp.pathname : '/' + tmp.pathname; + let protocol = (!tmp.protocol || tmp.protocol === ':') ? 'http' : tmp.protocol; + let pathname = (tmp.pathname.match(/^\//)) ? tmp.pathname : '/' + tmp.pathname; return { hash: tmp.hash, @@ -124,7 +124,7 @@ QUnit.test('HashLocation.replaceURL() correctly replaces to the path with a page QUnit.test('HashLocation.onUpdateURL() registers a hashchange callback', function() { expect(3); - var oldInit = jQuery.fn.init; + let oldInit = jQuery.fn.init; jQuery.fn.init = function(element) { equal(element, window); @@ -142,7 +142,7 @@ QUnit.test('HashLocation.onUpdateURL() registers a hashchange callback', functio willDestroy() {} }); - var guid = guidFor(location); + let guid = guidFor(location); location.onUpdateURL(function () {}); @@ -157,7 +157,7 @@ QUnit.test('HashLocation.onUpdateURL callback executes as expected', function() _location: mockBrowserLocation('/#/foo/bar') }); - var callback = function (param) { + let callback = function (param) { equal(param, '/foo/bar', 'path is passed as param'); }; @@ -176,7 +176,7 @@ QUnit.test('HashLocation.onUpdateURL doesn\'t execute callback if lastSetURL === lastSetURL: '/foo/bar' }); - var callback = function (param) { + let callback = function (param) { ok(false, 'callback should not be called'); }; @@ -196,7 +196,7 @@ QUnit.test('HashLocation.formatURL() prepends a # to the provided string', funct QUnit.test('HashLocation.willDestroy() cleans up hashchange event listener', function() { expect(2); - var oldInit = jQuery.fn.init; + let oldInit = jQuery.fn.init; jQuery.fn.init = function(element) { equal(element, window); @@ -210,7 +210,7 @@ QUnit.test('HashLocation.willDestroy() cleans up hashchange event listener', fun createLocation(); - var guid = guidFor(location); + let guid = guidFor(location); location.willDestroy(); diff --git a/packages/ember-routing/tests/location/history_location_test.js b/packages/ember-routing/tests/location/history_location_test.js index ad36620196b..c518554252f 100644 --- a/packages/ember-routing/tests/location/history_location_test.js +++ b/packages/ember-routing/tests/location/history_location_test.js @@ -2,7 +2,7 @@ import { set } from 'ember-metal/property_set'; import run from 'ember-metal/run_loop'; import HistoryLocation from 'ember-routing/location/history_location'; -var FakeHistory, HistoryTestLocation, location; +let FakeHistory, HistoryTestLocation, location; function createLocation(options) { if (!options) { options = {}; } @@ -12,11 +12,11 @@ function createLocation(options) { function mockBrowserLocation(path) { // This is a neat trick to auto-magically extract the hostname from any // url by letting the browser do the work ;) - var tmp = document.createElement('a'); + let tmp = document.createElement('a'); tmp.href = path; - var protocol = (!tmp.protocol || tmp.protocol === ':') ? 'http' : tmp.protocol; - var pathname = (tmp.pathname.match(/^\//)) ? tmp.pathname : '/' + tmp.pathname; + let protocol = (!tmp.protocol || tmp.protocol === ':') ? 'http' : tmp.protocol; + let pathname = (tmp.pathname.match(/^\//)) ? tmp.pathname : '/' + tmp.pathname; return { hash: tmp.hash, @@ -51,7 +51,7 @@ QUnit.module('Ember.HistoryLocation', { }, teardown() { - run(function() { + run(() => { if (location) { location.destroy(); } }); } diff --git a/packages/ember-routing/tests/location/none_location_test.js b/packages/ember-routing/tests/location/none_location_test.js index 9f17a13863b..e09d50b1cf9 100644 --- a/packages/ember-routing/tests/location/none_location_test.js +++ b/packages/ember-routing/tests/location/none_location_test.js @@ -2,7 +2,7 @@ import { set } from 'ember-metal/property_set'; import run from 'ember-metal/run_loop'; import NoneLocation from 'ember-routing/location/none_location'; -var NoneTestLocation, location; +let NoneTestLocation, location; function createLocation(options) { if (!options) { options = {}; } @@ -15,7 +15,7 @@ QUnit.module('Ember.NoneLocation', { }, teardown() { - run(function() { + run(() => { if (location) { location.destroy(); } }); } diff --git a/packages/ember-routing/tests/location/util_test.js b/packages/ember-routing/tests/location/util_test.js index 6de1b20e2db..f0ebaf3caf6 100644 --- a/packages/ember-routing/tests/location/util_test.js +++ b/packages/ember-routing/tests/location/util_test.js @@ -27,9 +27,9 @@ QUnit.module('Location Utilities'); QUnit.test('replacePath cannot be used to redirect to a different origin', function() { expect(1); - var expectedURL; + let expectedURL; - var location = { + let location = { protocol: 'http:', hostname: 'emberjs.com', port: '1337', @@ -46,7 +46,7 @@ QUnit.test('replacePath cannot be used to redirect to a different origin', funct QUnit.test('getPath() should normalize location.pathname, making sure it always returns a leading slash', function() { expect(2); - var location = mockBrowserLocation({ pathname: 'test' }); + let location = mockBrowserLocation({ pathname: 'test' }); equal(getPath(location), '/test', 'When there is no leading slash, one is added.'); location = mockBrowserLocation({ pathname: '/test' }); @@ -56,14 +56,14 @@ QUnit.test('getPath() should normalize location.pathname, making sure it always QUnit.test('getQuery() should return location.search as-is', function() { expect(1); - var location = mockBrowserLocation({ search: '?foo=bar' }); + let location = mockBrowserLocation({ search: '?foo=bar' }); equal(getQuery(location), '?foo=bar'); }); QUnit.test('getFullPath() should return full pathname including query and hash', function() { expect(1); - var location = mockBrowserLocation({ + let location = mockBrowserLocation({ href: 'http://test.com/about?foo=bar#foo', pathname: '/about', search: '?foo=bar', @@ -121,7 +121,7 @@ QUnit.test("Feature-detecting the history API", function() { true, "returns true for Chrome (not stock browser) on Android 4.0.x" ); - + // Windows Phone UA and History API: https://github.com/Modernizr/Modernizr/issues/1471 equal( supportsHistory( diff --git a/packages/ember-routing/tests/system/controller_for_test.js b/packages/ember-routing/tests/system/controller_for_test.js index ec685079013..aa19f525f8a 100644 --- a/packages/ember-routing/tests/system/controller_for_test.js +++ b/packages/ember-routing/tests/system/controller_for_test.js @@ -11,7 +11,7 @@ import { } from 'ember-routing/system/generate_controller'; import buildOwner from 'container/tests/test-helpers/build-owner'; -var buildInstance = function(namespace) { +function buildInstance(namespace) { let owner = buildOwner(); owner.__registry__.resolver = resolverFor(namespace); @@ -22,27 +22,27 @@ var buildInstance = function(namespace) { owner.register('controller:basic', Controller, { instantiate: false }); return owner; -}; +} function resolverFor(namespace) { return { resolve(fullName) { - var nameParts = fullName.split(':'); - var type = nameParts[0]; - var name = nameParts[1]; + let nameParts = fullName.split(':'); + let type = nameParts[0]; + let name = nameParts[1]; if (name === 'basic') { name = ''; } - var className = classify(name) + classify(type); - var factory = get(namespace, className); + let className = classify(name) + classify(type); + let factory = get(namespace, className); if (factory) { return factory; } } }; } -var appInstance, appController, namespace; +let appInstance, appController, namespace; QUnit.module('Ember.controllerFor', { setup() { @@ -52,7 +52,7 @@ QUnit.module('Ember.controllerFor', { appController = appInstance.lookup('controller:app'); }, teardown() { - run(function () { + run(() => { appInstance.destroy(); namespace.destroy(); }); @@ -60,7 +60,7 @@ QUnit.module('Ember.controllerFor', { }); QUnit.test('controllerFor should lookup for registered controllers', function() { - var controller = controllerFor(appInstance, 'app'); + let controller = controllerFor(appInstance, 'app'); equal(appController, controller, 'should find app controller'); }); @@ -71,7 +71,7 @@ QUnit.module('Ember.generateController', { appInstance = buildInstance(namespace); }, teardown() { - run(function () { + run(() => { appInstance.destroy(); namespace.destroy(); }); @@ -84,14 +84,14 @@ QUnit.test('generateController and generateControllerFactory are properties on t }); QUnit.test('generateController should create Ember.Controller', function() { - var controller = generateController(appInstance, 'home'); + let controller = generateController(appInstance, 'home'); ok(controller instanceof Controller, 'should create controller'); }); QUnit.test('generateController should create App.Controller if provided', function() { - var controller; + let controller; namespace.Controller = Controller.extend(); controller = generateController(appInstance, 'home'); diff --git a/packages/ember-routing/tests/system/dsl_test.js b/packages/ember-routing/tests/system/dsl_test.js index 89ade6025f4..0e4e903cfd4 100644 --- a/packages/ember-routing/tests/system/dsl_test.js +++ b/packages/ember-routing/tests/system/dsl_test.js @@ -1,6 +1,6 @@ import EmberRouter from 'ember-routing/system/router'; -var Router; +let Router; QUnit.module('Ember Router DSL', { setup() { @@ -13,30 +13,30 @@ QUnit.module('Ember Router DSL', { QUnit.test('should fail when using a reserved route name', function() { expectDeprecation('this.resource() is deprecated. Use this.route(\'name\', { resetNamespace: true }, function () {}) instead.'); - var reservedNames = ['array', 'basic', 'object', 'application']; + let reservedNames = ['array', 'basic', 'object', 'application']; expect((reservedNames.length * 2) + 1); - reservedNames.forEach(function(reservedName) { - expectAssertion(function() { + reservedNames.forEach(reservedName => { + expectAssertion(() => { Router = EmberRouter.extend(); Router.map(function() { this.route(reservedName); }); - var router = Router.create(); + let router = Router.create(); router._initRouterJs(); }, '\'' + reservedName + '\' cannot be used as a route name.'); - expectAssertion(function() { + expectAssertion(() => { Router = EmberRouter.extend(); Router.map(function() { this.resource(reservedName); }); - var router = Router.create(); + let router = Router.create(); router._initRouterJs(); }, `'${reservedName}' cannot be used as a route name.`); }); @@ -53,7 +53,7 @@ QUnit.test('should reset namespace if nested with resource', function() { }); }); - var router = Router.create(); + let router = Router.create(); router._initRouterJs(); ok(router.router.recognizer.names['bleep'], 'nested resources do not contain parent name'); @@ -70,7 +70,7 @@ QUnit.test('should retain resource namespace if nested with routes', function() }); }); - var router = Router.create(); + let router = Router.create(); router._initRouterJs(); ok(router.router.recognizer.names['bleep'], 'parent name was used as base of nested routes'); @@ -83,7 +83,7 @@ QUnit.test('should add loading and error routes if _isRouterMapResult is true', this.route('blork'); }); - var router = Router.create({ + let router = Router.create({ _hasModuleBasedResolver() { return true; } }); @@ -99,7 +99,7 @@ QUnit.test('should not add loading and error routes if _isRouterMapResult is fal this.route('blork'); }); - var router = Router.create(); + let router = Router.create(); router._initRouterJs(false); ok(router.router.recognizer.names['blork'], 'main route was created'); diff --git a/packages/ember-routing/tests/system/route_test.js b/packages/ember-routing/tests/system/route_test.js index eb68c1a1ad3..2d7aa395b02 100644 --- a/packages/ember-routing/tests/system/route_test.js +++ b/packages/ember-routing/tests/system/route_test.js @@ -6,7 +6,7 @@ import inject from 'ember-runtime/inject'; import buildOwner from 'container/tests/test-helpers/build-owner'; import { setOwner } from 'container/owner'; -var route, routeOne, routeTwo, lookupHash; +let route, routeOne, routeTwo, lookupHash; function setup() { route = EmberRoute.create(); @@ -24,8 +24,8 @@ QUnit.module('Ember.Route', { QUnit.test('default store utilizes the container to acquire the model factory', function() { expect(4); - var Post = EmberObject.extend(); - var post = {}; + let Post = EmberObject.extend(); + let post = {}; Post.reopenClass({ find(id) { @@ -57,11 +57,11 @@ QUnit.test('\'store\' can be injected by data persistence frameworks', function( let owner = buildOwner(); - var post = { + let post = { id: 1 }; - var Store = EmberObject.extend({ + let Store = EmberObject.extend({ find(type, value) { ok(true, 'injected model was called'); equal(type, 'post', 'correct type was called'); @@ -86,7 +86,7 @@ QUnit.test('assert if \'store.find\' method is not found', function() { runDestroy(route); let owner = buildOwner(); - var Post = EmberObject.extend(); + let Post = EmberObject.extend(); owner.register('route:index', EmberRoute); owner.register('model:post', Post); @@ -149,7 +149,7 @@ QUnit.test('modelFor doesn\'t require the router', function() { QUnit.test('.send just calls an action if the router is absent', function() { expect(7); - var route = EmberRoute.extend({ + let route = EmberRoute.extend({ actions: { returnsTrue(foo, bar) { equal(foo, 1); @@ -172,7 +172,7 @@ QUnit.test('.send just calls an action if the router is absent', function() { QUnit.test('.send just calls an action if the routers internal router property is absent', function() { expect(7); - var route = EmberRoute.extend({ + let route = EmberRoute.extend({ router: { }, actions: { returnsTrue(foo, bar) { @@ -197,7 +197,7 @@ QUnit.test('.send just calls an action if the routers internal router property i QUnit.test('can access `actions` hash via `_actions` [DEPRECATED]', function() { expect(2); - var route = EmberRoute.extend({ + let route = EmberRoute.extend({ actions: { foo: function() { ok(true, 'called foo action'); @@ -249,19 +249,19 @@ QUnit.module('Ember.Route serialize', { }); QUnit.test('returns the models properties if params does not include *_id', function() { - var model = { id: 2, firstName: 'Ned', lastName: 'Ryerson' }; + let model = { id: 2, firstName: 'Ned', lastName: 'Ryerson' }; deepEqual(route.serialize(model, ['firstName', 'lastName']), { firstName: 'Ned', lastName: 'Ryerson' }, 'serialized correctly'); }); QUnit.test('returns model.id if params include *_id', function() { - var model = { id: 2 }; + let model = { id: 2 }; deepEqual(route.serialize(model, ['post_id']), { post_id: 2 }, 'serialized correctly'); }); QUnit.test('returns checks for existence of model.post_id before trying model.id', function() { - var model = { post_id: 3 }; + let model = { post_id: 3 }; deepEqual(route.serialize(model, ['post_id']), { post_id: 3 }, 'serialized correctly'); }); @@ -272,7 +272,7 @@ QUnit.test('returns undefined if model is not set', function() { QUnit.module('Ember.Route interaction', { setup() { - var owner = { + let owner = { lookup(fullName) { return lookupHash[fullName]; } @@ -297,7 +297,7 @@ QUnit.module('Ember.Route interaction', { }); QUnit.test('controllerFor uses route\'s controllerName if specified', function() { - var testController = {}; + let testController = {}; lookupHash['controller:test'] = testController; routeOne.controllerName = 'test'; @@ -316,8 +316,8 @@ QUnit.test('services can be injected into routes', function() { owner.register('service:auth', Service.extend()); - var appRoute = owner.lookup('route:application'); - var authService = owner.lookup('service:auth'); + let appRoute = owner.lookup('route:application'); + let authService = owner.lookup('service:auth'); equal(authService, appRoute.get('authService'), 'service.auth is injected'); }); diff --git a/packages/ember-routing/tests/system/router_test.js b/packages/ember-routing/tests/system/router_test.js index 942ad9ba010..736d9aa5990 100644 --- a/packages/ember-routing/tests/system/router_test.js +++ b/packages/ember-routing/tests/system/router_test.js @@ -7,11 +7,11 @@ import { runDestroy } from 'ember-runtime/tests/utils'; import buildOwner from 'container/tests/test-helpers/build-owner'; import { setOwner } from 'container/owner'; -var owner; +let owner; function createRouter(settings, options = {}) { - var CustomRouter = Router.extend(); - var router = CustomRouter.create(settings); + let CustomRouter = Router.extend(); + let router = CustomRouter.create(settings); if (!options.skipOwner) { setOwner(router, owner); @@ -47,13 +47,13 @@ QUnit.test('can create a router without an owner', function() { }); QUnit.test('should not create a router.js instance upon init', function() { - var router = createRouter(null, { disableSetup: true }); + let router = createRouter(null, { disableSetup: true }); ok(!router.router); }); QUnit.test('should not reify location until setupRouter is called', function() { - var router = createRouter(null, { disableSetup: true }); + let router = createRouter(null, { disableSetup: true }); equal(typeof router.location, 'string', 'location is specified as a string'); router.setupRouter(); @@ -62,8 +62,8 @@ QUnit.test('should not reify location until setupRouter is called', function() { }); QUnit.test('should destroy its location upon destroying the routers owner.', function() { - var router = createRouter(); - var location = router.get('location'); + let router = createRouter(); + let location = router.get('location'); runDestroy(owner); @@ -71,10 +71,10 @@ QUnit.test('should destroy its location upon destroying the routers owner.', fun }); QUnit.test('should instantiate its location with its `rootURL`', function() { - var router = createRouter({ + let router = createRouter({ rootURL: '/rootdir/' }); - var location = router.get('location'); + let location = router.get('location'); equal(location.get('rootURL'), '/rootdir/'); }); @@ -82,9 +82,9 @@ QUnit.test('should instantiate its location with its `rootURL`', function() { QUnit.test('replacePath should be called with the right path', function() { expect(1); - var location = owner.lookup('location:auto'); + let location = owner.lookup('location:auto'); - var browserLocation = { + let browserLocation = { href: 'http://test.com/rootdir/welcome', origin: 'http://test.com', pathname: '/rootdir/welcome', @@ -111,7 +111,7 @@ QUnit.test('Ember.Router._routePath should consume identical prefixes', function expect(8); function routePath(s1, s2, s3) { - var handlerInfos = Array.prototype.slice.call(arguments).map(function(s) { + let handlerInfos = Array.prototype.slice.call(arguments).map(function(s) { return { name: s }; }); handlerInfos.unshift({ name: 'ignored' }); @@ -135,8 +135,8 @@ QUnit.test('Ember.Router._routePath should consume identical prefixes', function QUnit.test('Router should cancel routing setup when the Location class says so via cancelRouterSetup', function() { expect(0); - var router; - var FakeLocation = { + let router; + let FakeLocation = { cancelRouterSetup: true, create() { return this; } }; @@ -157,7 +157,7 @@ QUnit.test('Router should cancel routing setup when the Location class says so v QUnit.test('AutoLocation should replace the url when it\'s not in the preferred format', function() { expect(1); - var location = owner.lookup('location:auto'); + let location = owner.lookup('location:auto'); location.location = { href: 'http://test.com/rootdir/welcome', @@ -183,7 +183,7 @@ QUnit.test('AutoLocation should replace the url when it\'s not in the preferred QUnit.test('Router#handleURL should remove any #hashes before doing URL transition', function() { expect(2); - var router = createRouter({ + let router = createRouter({ _doURLTransition(routerJsMethod, url) { equal(routerJsMethod, 'handleURL'); equal(url, '/foo/bar?time=morphin'); diff --git a/packages/ember-routing/tests/utils_test.js b/packages/ember-routing/tests/utils_test.js index 0e743404741..4fb77ab0f2b 100644 --- a/packages/ember-routing/tests/utils_test.js +++ b/packages/ember-routing/tests/utils_test.js @@ -6,18 +6,18 @@ import { QUnit.module('Routing query parameter utils - normalizeControllerQueryParams'); QUnit.test('returns the cached value if that has been previously set', function(assert) { - var cached = {}; - var params = ['foo']; + let cached = {}; + let params = ['foo']; params._qpMap = cached; - var normalized = normalizeControllerQueryParams(params); + let normalized = normalizeControllerQueryParams(params); equal(cached, normalized, 'cached value returned if previously set'); }); QUnit.test('converts array style into verbose object style', function(assert) { - var paramName = 'foo'; - var params = [paramName]; - var normalized = normalizeControllerQueryParams(params); + let paramName = 'foo'; + let params = [paramName]; + let normalized = normalizeControllerQueryParams(params); ok(normalized[paramName], 'turns the query param name into key'); equal(normalized[paramName].as, null, 'includes a blank alias in \'as\' key'); @@ -25,9 +25,9 @@ QUnit.test('converts array style into verbose object style', function(assert) { }); QUnit.test('converts object stlye [{foo: \'an_alias\'}]', function(assert) { - var paramName = 'foo'; - var params = [{ 'foo': 'an_alias' }]; - var normalized = normalizeControllerQueryParams(params); + let paramName = 'foo'; + let params = [{ 'foo': 'an_alias' }]; + let normalized = normalizeControllerQueryParams(params); ok(normalized[paramName], 'retains the query param name as key'); equal(normalized[paramName].as, 'an_alias', 'includes the provided alias in \'as\' key'); @@ -35,9 +35,9 @@ QUnit.test('converts object stlye [{foo: \'an_alias\'}]', function(assert) { }); QUnit.test('retains maximally verbose object stlye [{foo: {as: \'foo\'}}]', function(assert) { - var paramName = 'foo'; - var params = [{ 'foo': { as: 'an_alias' } }]; - var normalized = normalizeControllerQueryParams(params); + let paramName = 'foo'; + let params = [{ 'foo': { as: 'an_alias' } }]; + let normalized = normalizeControllerQueryParams(params); ok(normalized[paramName], 'retains the query param name as key'); equal(normalized[paramName].as, 'an_alias', 'includes the provided alias in \'as\' key'); diff --git a/packages/ember-runtime/lib/compare.js b/packages/ember-runtime/lib/compare.js index ac668e95935..827adf33b46 100644 --- a/packages/ember-runtime/lib/compare.js +++ b/packages/ember-runtime/lib/compare.js @@ -1,7 +1,7 @@ import { typeOf } from 'ember-runtime/utils'; import Comparable from 'ember-runtime/mixins/comparable'; -var TYPE_ORDER = { +const TYPE_ORDER = { 'undefined': 0, 'null': 1, 'boolean': 2, @@ -33,7 +33,7 @@ var TYPE_ORDER = { // `._________`-. `. `.___ // SSt `------'` function spaceship(a, b) { - var diff = a - b; + let diff = a - b; return (diff > 0) - (diff < 0); } @@ -83,8 +83,8 @@ export default function compare(v, w) { return 0; } - var type1 = typeOf(v); - var type2 = typeOf(w); + let type1 = typeOf(v); + let type2 = typeOf(w); if (Comparable) { if (type1 === 'instance' && Comparable.detect(v) && v.constructor.compare) { @@ -96,7 +96,7 @@ export default function compare(v, w) { } } - var res = spaceship(TYPE_ORDER[type1], TYPE_ORDER[type2]); + let res = spaceship(TYPE_ORDER[type1], TYPE_ORDER[type2]); if (res !== 0) { return res; @@ -112,12 +112,12 @@ export default function compare(v, w) { return spaceship(v.localeCompare(w), 0); case 'array': - var vLen = v.length; - var wLen = w.length; - var len = Math.min(vLen, wLen); + let vLen = v.length; + let wLen = w.length; + let len = Math.min(vLen, wLen); - for (var i = 0; i < len; i++) { - var r = compare(v[i], w[i]); + for (let i = 0; i < len; i++) { + let r = compare(v[i], w[i]); if (r !== 0) { return r; } diff --git a/packages/ember-runtime/lib/computed/computed_macros.js b/packages/ember-runtime/lib/computed/computed_macros.js index a01043cff6b..d7969f492ea 100644 --- a/packages/ember-runtime/lib/computed/computed_macros.js +++ b/packages/ember-runtime/lib/computed/computed_macros.js @@ -13,7 +13,7 @@ import expandProperties from 'ember-metal/expand_properties'; */ function expandPropertiesToArray(predicateName, properties) { - var expandedProperties = []; + let expandedProperties = []; function extractProperty(entry) { expandedProperties.push(entry); @@ -31,13 +31,13 @@ function expandPropertiesToArray(predicateName, properties) { function generateComputedWithPredicate(name, predicate) { return function(...properties) { - var expandedProperties = expandPropertiesToArray(name, properties); + let expandedProperties = expandPropertiesToArray(name, properties); - var computedFunc = computed(function() { - var lastIdx = expandedProperties.length - 1; + let computedFunc = computed(function() { + let lastIdx = expandedProperties.length - 1; - for (var i = 0; i < lastIdx; i++) { - var value = get(this, expandedProperties[i]); + for (let i = 0; i < lastIdx; i++) { + let value = get(this, expandedProperties[i]); if (!predicate(value)) { return value; } @@ -57,11 +57,11 @@ function generateComputedWithPredicate(name, predicate) { Example ```javascript - var ToDoList = Ember.Object.extend({ + let ToDoList = Ember.Object.extend({ isDone: Ember.computed.empty('todos') }); - var todoList = ToDoList.create({ + let todoList = ToDoList.create({ todos: ['Unit Test', 'Documentation', 'Release'] }); @@ -91,11 +91,11 @@ export function empty(dependentKey) { Example ```javascript - var Hamster = Ember.Object.extend({ + let Hamster = Ember.Object.extend({ hasStuff: Ember.computed.notEmpty('backpack') }); - var hamster = Hamster.create({ backpack: ['Food', 'Sleeping Bag', 'Tent'] }); + let hamster = Hamster.create({ backpack: ['Food', 'Sleeping Bag', 'Tent'] }); hamster.get('hasStuff'); // true hamster.get('backpack').clear(); // [] @@ -123,11 +123,11 @@ export function notEmpty(dependentKey) { Example ```javascript - var Hamster = Ember.Object.extend({ + let Hamster = Ember.Object.extend({ isHungry: Ember.computed.none('food') }); - var hamster = Hamster.create(); + let hamster = Hamster.create(); hamster.get('isHungry'); // true hamster.set('food', 'Banana'); @@ -156,11 +156,11 @@ export function none(dependentKey) { Example ```javascript - var User = Ember.Object.extend({ + let User = Ember.Object.extend({ isAnonymous: Ember.computed.not('loggedIn') }); - var user = User.create({loggedIn: false}); + let user = User.create({loggedIn: false}); user.get('isAnonymous'); // true user.set('loggedIn', true); @@ -185,11 +185,11 @@ export function not(dependentKey) { into a boolean value. ```javascript - var Hamster = Ember.Object.extend({ + let Hamster = Ember.Object.extend({ hasBananas: Ember.computed.bool('numBananas') }); - var hamster = Hamster.create(); + let hamster = Hamster.create(); hamster.get('hasBananas'); // false hamster.set('numBananas', 0); @@ -221,11 +221,11 @@ export function bool(dependentKey) { Example ```javascript - var User = Ember.Object.extend({ + let User = Ember.Object.extend({ hasValidEmail: Ember.computed.match('email', /^.+@.+\..+$/) }); - var user = User.create({loggedIn: false}); + let user = User.create({loggedIn: false}); user.get('hasValidEmail'); // false user.set('email', ''); @@ -244,7 +244,7 @@ export function bool(dependentKey) { */ export function match(dependentKey, regexp) { return computed(dependentKey, function() { - var value = get(this, dependentKey); + let value = get(this, dependentKey); return typeof value === 'string' ? regexp.test(value) : false; }); @@ -257,11 +257,11 @@ export function match(dependentKey, regexp) { Example ```javascript - var Hamster = Ember.Object.extend({ + let Hamster = Ember.Object.extend({ napTime: Ember.computed.equal('state', 'sleepy') }); - var hamster = Hamster.create(); + let hamster = Hamster.create(); hamster.get('napTime'); // false hamster.set('state', 'sleepy'); @@ -291,11 +291,11 @@ export function equal(dependentKey, value) { Example ```javascript - var Hamster = Ember.Object.extend({ + let Hamster = Ember.Object.extend({ hasTooManyBananas: Ember.computed.gt('numBananas', 10) }); - var hamster = Hamster.create(); + let hamster = Hamster.create(); hamster.get('hasTooManyBananas'); // false hamster.set('numBananas', 3); @@ -325,11 +325,11 @@ export function gt(dependentKey, value) { Example ```javascript - var Hamster = Ember.Object.extend({ + let Hamster = Ember.Object.extend({ hasTooManyBananas: Ember.computed.gte('numBananas', 10) }); - var hamster = Hamster.create(); + let hamster = Hamster.create(); hamster.get('hasTooManyBananas'); // false hamster.set('numBananas', 3); @@ -359,11 +359,11 @@ export function gte(dependentKey, value) { Example ```javascript - var Hamster = Ember.Object.extend({ + let Hamster = Ember.Object.extend({ needsMoreBananas: Ember.computed.lt('numBananas', 3) }); - var hamster = Hamster.create(); + let hamster = Hamster.create(); hamster.get('needsMoreBananas'); // true hamster.set('numBananas', 3); @@ -393,11 +393,11 @@ export function lt(dependentKey, value) { Example ```javascript - var Hamster = Ember.Object.extend({ + let Hamster = Ember.Object.extend({ needsMoreBananas: Ember.computed.lte('numBananas', 3) }); - var hamster = Hamster.create(); + let hamster = Hamster.create(); hamster.get('needsMoreBananas'); // true hamster.set('numBananas', 5); @@ -432,12 +432,12 @@ export function lte(dependentKey, value) { Example ```javascript - var Hamster = Ember.Object.extend({ + let Hamster = Ember.Object.extend({ readyForCamp: Ember.computed.and('hasTent', 'hasBackpack'), readyForHike: Ember.computed.and('hasWalkingStick', 'hasBackpack') }); - var tomster = Hamster.create(); + let tomster = Hamster.create(); tomster.get('readyForCamp'); // false tomster.set('hasTent', true); @@ -457,7 +457,7 @@ export function lte(dependentKey, value) { a logical `and` on the values of all the original values for properties. @public */ -export var and = generateComputedWithPredicate('and', function(value) { +export let and = generateComputedWithPredicate('and', function(value) { return value; }); @@ -473,12 +473,12 @@ export var and = generateComputedWithPredicate('and', function(value) { Example ```javascript - var Hamster = Ember.Object.extend({ + let Hamster = Ember.Object.extend({ readyForRain: Ember.computed.or('hasJacket', 'hasUmbrella'), readyForBeach: Ember.computed.or('{hasSunscreen,hasUmbrella}') }); - var tomster = Hamster.create(); + let tomster = Hamster.create(); tomster.get('readyForRain'); // undefined tomster.set('hasUmbrella', true); @@ -496,7 +496,7 @@ export var and = generateComputedWithPredicate('and', function(value) { a logical `or` on the values of all the original values for properties. @public */ -export var or = generateComputedWithPredicate('or', function(value) { +export let or = generateComputedWithPredicate('or', function(value) { return !value; }); @@ -506,12 +506,12 @@ export var or = generateComputedWithPredicate('or', function(value) { though they were called on the original property. ```javascript - var Person = Ember.Object.extend({ + let Person = Ember.Object.extend({ name: 'Alex Matchneer', nomen: Ember.computed.alias('name') }); - var alex = Person.create(); + let alex = Person.create(); alex.get('nomen'); // 'Alex Matchneer' alex.get('name'); // 'Alex Matchneer' @@ -538,13 +538,13 @@ export var or = generateComputedWithPredicate('or', function(value) { Example ```javascript - var User = Ember.Object.extend({ + let User = Ember.Object.extend({ firstName: null, lastName: null, nickName: Ember.computed.oneWay('firstName') }); - var teddy = User.create({ + let teddy = User.create({ firstName: 'Teddy', lastName: 'Zeenny' }); @@ -587,13 +587,13 @@ export function oneWay(dependentKey) { Example ```javascript - var User = Ember.Object.extend({ + let User = Ember.Object.extend({ firstName: null, lastName: null, nickName: Ember.computed.readOnly('firstName') }); - var teddy = User.create({ + let teddy = User.create({ firstName: 'Teddy', lastName: 'Zeenny' }); @@ -623,14 +623,14 @@ export function readOnly(dependentKey) { print a deprecation warning. ```javascript - var Hamster = Ember.Object.extend({ + let Hamster = Ember.Object.extend({ bananaCount: Ember.computed.deprecatingAlias('cavendishCount', { id: 'hamster.deprecate-banana', until: '3.0.0' }) }); - var hamster = Hamster.create(); + let hamster = Hamster.create(); hamster.set('bananaCount', 5); // Prints a deprecation warning. hamster.get('cavendishCount'); // 5 diff --git a/packages/ember-runtime/lib/computed/reduce_computed_macros.js b/packages/ember-runtime/lib/computed/reduce_computed_macros.js index 2d12a72e637..97615c983ca 100644 --- a/packages/ember-runtime/lib/computed/reduce_computed_macros.js +++ b/packages/ember-runtime/lib/computed/reduce_computed_macros.js @@ -32,7 +32,7 @@ function reduceMacro(dependentKey, callback, initialValue) { function arrayMacro(dependentKey, callback) { // This is a bit ugly - var propertyName; + let propertyName; if (/@each/.test(dependentKey)) { propertyName = dependentKey.replace(/\.@each.*$/, ''); } else { @@ -41,7 +41,7 @@ function arrayMacro(dependentKey, callback) { } return computed(dependentKey, function() { - var value = get(this, propertyName); + let value = get(this, propertyName); if (isArray(value)) { return emberA(callback.call(this, value)); } else { @@ -51,7 +51,7 @@ function arrayMacro(dependentKey, callback) { } function multiArrayMacro(dependentKeys, callback) { - var args = dependentKeys.map(key => `${key}.[]`); + let args = dependentKeys.map(key => `${key}.[]`); args.push(function() { return emberA(callback.call(this, dependentKeys)); @@ -81,12 +81,12 @@ export function sum(dependentKey) { array is empty. ```javascript - var Person = Ember.Object.extend({ + let Person = Ember.Object.extend({ childAges: Ember.computed.mapBy('children', 'age'), maxChildAge: Ember.computed.max('childAges') }); - var lordByron = Person.create({ children: [] }); + let lordByron = Person.create({ children: [] }); lordByron.get('maxChildAge'); // -Infinity lordByron.get('children').pushObject({ @@ -126,12 +126,12 @@ export function max(dependentKey) { array is empty. ```javascript - var Person = Ember.Object.extend({ + let Person = Ember.Object.extend({ childAges: Ember.computed.mapBy('children', 'age'), minChildAge: Ember.computed.min('childAges') }); - var lordByron = Person.create({ children: [] }); + let lordByron = Person.create({ children: [] }); lordByron.get('minChildAge'); // Infinity lordByron.get('children').pushObject({ @@ -179,13 +179,13 @@ export function min(dependentKey) { Example ```javascript - var Hamster = Ember.Object.extend({ + let Hamster = Ember.Object.extend({ excitingChores: Ember.computed.map('chores', function(chore, index) { return chore.toUpperCase() + '!'; }) }); - var hamster = Hamster.create({ + let hamster = Hamster.create({ chores: ['clean', 'write more unit tests'] }); @@ -209,11 +209,11 @@ export function map(dependentKey, callback) { Returns an array mapped to the specified key. ```javascript - var Person = Ember.Object.extend({ + let Person = Ember.Object.extend({ childAges: Ember.computed.mapBy('children', 'age') }); - var lordByron = Person.create({ children: [] }); + let lordByron = Person.create({ children: [] }); lordByron.get('childAges'); // [] lordByron.get('children').pushObject({ name: 'Augusta Ada Byron', age: 7 }); @@ -258,13 +258,13 @@ export function mapBy(dependentKey, propertyKey) { ``` ```javascript - var Hamster = Ember.Object.extend({ + let Hamster = Ember.Object.extend({ remainingChores: Ember.computed.filter('chores', function(chore, index, array) { return !chore.done; }) }); - var hamster = Hamster.create({ + let hamster = Hamster.create({ chores: [ { name: 'cook', done: true }, { name: 'clean', done: true }, @@ -292,11 +292,11 @@ export function filter(dependentKey, callback) { Filters the array by the property and value ```javascript - var Hamster = Ember.Object.extend({ + let Hamster = Ember.Object.extend({ remainingChores: Ember.computed.filterBy('chores', 'done', false) }); - var hamster = Hamster.create({ + let hamster = Hamster.create({ chores: [ { name: 'cook', done: true }, { name: 'clean', done: true }, @@ -316,16 +316,12 @@ export function filter(dependentKey, callback) { @public */ export function filterBy(dependentKey, propertyKey, value) { - var callback; + let callback; if (arguments.length === 2) { - callback = function(item) { - return get(item, propertyKey); - }; + callback = (item) => get(item, propertyKey); } else { - callback = function(item) { - return get(item, propertyKey) === value; - }; + callback = (item) => get(item, propertyKey) === value; } return filter(`${dependentKey}.@each.${propertyKey}`, callback); @@ -338,11 +334,11 @@ export function filterBy(dependentKey, propertyKey, value) { Example ```javascript - var Hamster = Ember.Object.extend({ + let Hamster = Ember.Object.extend({ uniqueFruits: Ember.computed.uniq('fruits') }); - var hamster = Hamster.create({ + let hamster = Hamster.create({ fruits: [ 'banana', 'grape', @@ -363,10 +359,10 @@ export function filterBy(dependentKey, propertyKey, value) { */ export function uniq(...args) { return multiArrayMacro(args, function(dependentKeys) { - var uniq = emberA(); + let uniq = emberA(); dependentKeys.forEach(dependentKey => { - var value = get(this, dependentKey); + let value = get(this, dependentKey); if (isArray(value)) { value.forEach(item => { if (uniq.indexOf(item) === -1) { @@ -385,10 +381,10 @@ export function uniq(...args) { elements from an array, with uniqueness determined by specific key. Example ```javascript - var Hamster = Ember.Object.extend({ + let Hamster = Ember.Object.extend({ uniqueFruits: Ember.computed.uniqBy('fruits', 'id') }); - var hamster = Hamster.create({ + let hamster = Hamster.create({ fruits: [ { id: 1, 'banana' }, { id: 2, 'grape' }, @@ -408,12 +404,12 @@ export function uniq(...args) { */ export function uniqBy(dependentKey, propertyKey) { return computed(`${dependentKey}.[]`, function() { - var uniq = emberA(); - var seen = new EmptyObject(); - var list = get(this, dependentKey); + let uniq = emberA(); + let seen = new EmptyObject(); + let list = get(this, dependentKey); if (isArray(list)) { list.forEach(item => { - var guid = guidFor(get(item, propertyKey)); + let guid = guidFor(get(item, propertyKey)); if (!(guid in seen)) { seen[guid] = true; uniq.push(item); @@ -434,7 +430,7 @@ export function uniqBy(dependentKey, propertyKey) { unique elements from the dependent array @public */ -export var union = uniq; +export let union = uniq; /** A computed property which returns a new array with all the duplicated @@ -443,7 +439,7 @@ export var union = uniq; Example ```javascript - var obj = Ember.Object.extend({ + let obj = Ember.Object.extend({ friendsInCommon: Ember.computed.intersect('adaFriends', 'charlesFriends') }).create({ adaFriends: ['Charles Babbage', 'John Hobhouse', 'William King', 'Mary Somerville'], @@ -462,17 +458,17 @@ export var union = uniq; */ export function intersect(...args) { return multiArrayMacro(args, function(dependentKeys) { - var arrays = dependentKeys.map(dependentKey => { - var array = get(this, dependentKey); + let arrays = dependentKeys.map(dependentKey => { + let array = get(this, dependentKey); return isArray(array) ? array : []; }); - var results = arrays.pop().filter(candidate => { - for (var i = 0; i < arrays.length; i++) { - var found = false; - var array = arrays[i]; - for (var j = 0; j < array.length; j++) { + let results = arrays.pop().filter(candidate => { + for (let i = 0; i < arrays.length; i++) { + let found = false; + let array = arrays[i]; + for (let j = 0; j < array.length; j++) { if (array[j] === candidate) { found = true; break; @@ -499,12 +495,12 @@ export function intersect(...args) { Example ```javascript - var Hamster = Ember.Object.extend({ + let Hamster = Ember.Object.extend({ likes: ['banana', 'grape', 'kale'], wants: Ember.computed.setDiff('likes', 'fruits') }); - var hamster = Hamster.create({ + let hamster = Hamster.create({ fruits: [ 'grape', 'kale', @@ -529,8 +525,8 @@ export function setDiff(setAProperty, setBProperty) { } return computed(`${setAProperty}.[]`, `${setBProperty}.[]`, function() { - var setA = this.get(setAProperty); - var setB = this.get(setBProperty); + let setA = this.get(setAProperty); + let setB = this.get(setBProperty); if (!isArray(setA)) { return emberA(); } if (!isArray(setB)) { return emberA(setA); } @@ -546,11 +542,11 @@ export function setDiff(setAProperty, setBProperty) { Example ```javascript - var Hamster = Ember.Object.extend({ + let Hamster = Ember.Object.extend({ clothes: Ember.computed.collect('hat', 'shirt') }); - var hamster = Hamster.create(); + let hamster = Hamster.create(); hamster.get('clothes'); // [null, null] hamster.set('hat', 'Camp Hat'); @@ -567,9 +563,9 @@ export function setDiff(setAProperty, setBProperty) { */ export function collect(...dependentKeys) { return multiArrayMacro(dependentKeys, function() { - var properties = getProperties(this, dependentKeys); - var res = emberA(); - for (var key in properties) { + let properties = getProperties(this, dependentKeys); + let res = emberA(); + for (let key in properties) { if (properties.hasOwnProperty(key)) { if (isNone(properties[key])) { res.push(null); @@ -606,7 +602,7 @@ export function collect(...dependentKeys) { Example ```javascript - var ToDoList = Ember.Object.extend({ + let ToDoList = Ember.Object.extend({ // using standard ascending sort todosSorting: ['name'], sortedTodos: Ember.computed.sort('todos', 'todosSorting'), @@ -627,7 +623,7 @@ export function collect(...dependentKeys) { }) }); - var todoList = ToDoList.create({todos: [ + let todoList = ToDoList.create({todos: [ { name: 'Unit Test', priority: 2 }, { name: 'Documentation', priority: 3 }, { name: 'Release', priority: 1 } @@ -686,9 +682,7 @@ function propertySort(itemsKey, sortPropertiesKey) { let activeObservers = activeObserversMap.get(this); if (activeObservers) { - activeObservers.forEach(args => { - removeObserver.apply(null, args); - }); + activeObservers.forEach(args => removeObserver.apply(null, args)); } function sortPropertyDidChange() { diff --git a/packages/ember-runtime/lib/controllers/controller.js b/packages/ember-runtime/lib/controllers/controller.js index 2764a40230f..2b0b2a52a36 100644 --- a/packages/ember-runtime/lib/controllers/controller.js +++ b/packages/ember-runtime/lib/controllers/controller.js @@ -16,7 +16,7 @@ import { deprecateUnderscoreActions } from 'ember-runtime/mixins/action_handler' @uses Ember.ControllerMixin @public */ -var Controller = EmberObject.extend(Mixin); +const Controller = EmberObject.extend(Mixin); deprecateUnderscoreActions(Controller); diff --git a/packages/ember-runtime/lib/copy.js b/packages/ember-runtime/lib/copy.js index f35b4e75bd5..48fb1cb8390 100644 --- a/packages/ember-runtime/lib/copy.js +++ b/packages/ember-runtime/lib/copy.js @@ -3,7 +3,7 @@ import EmberObject from 'ember-runtime/system/object'; import Copyable from 'ember-runtime/mixins/copyable'; function _copy(obj, deep, seen, copies) { - var ret, loc, key; + let ret, loc, key; // primitive data types are immutable, just return them. if (typeof obj !== 'object' || obj === null) { diff --git a/packages/ember-runtime/lib/ext/function.js b/packages/ember-runtime/lib/ext/function.js index 18d70590b73..51338d64ad3 100644 --- a/packages/ember-runtime/lib/ext/function.js +++ b/packages/ember-runtime/lib/ext/function.js @@ -29,7 +29,7 @@ if (ENV.EXTEND_PROTOTYPES.Function) { }.property() // Call this flag to mark the function as a property }); - var president = MyApp.President.create({ + let president = MyApp.President.create({ firstName: 'Barack', lastName: 'Obama' }); @@ -72,7 +72,7 @@ if (ENV.EXTEND_PROTOTYPES.Function) { @public */ FunctionPrototype.property = function () { - var ret = computed(this); + let ret = computed(this); // ComputedProperty.prototype.property expands properties; no need for us to // do so here. return ret.property(...arguments); @@ -114,7 +114,7 @@ if (ENV.EXTEND_PROTOTYPES.Function) { 'Immediate observers must observe internal properties only, ' + 'not properties on other objects.', function checkIsInternalProperty() { - for (var i = 0; i < arguments.length; i++) { + for (let i = 0; i < arguments.length; i++) { if (arguments[i].indexOf('.') !== -1) { return false; } @@ -182,7 +182,7 @@ if (ENV.EXTEND_PROTOTYPES.Function) { @public */ FunctionPrototype.on = function () { - var events = a_slice.call(arguments); + let events = a_slice.call(arguments); this.__ember_listens__ = events; return this; diff --git a/packages/ember-runtime/lib/inject.js b/packages/ember-runtime/lib/inject.js index a99882ee34a..373cb838ec2 100644 --- a/packages/ember-runtime/lib/inject.js +++ b/packages/ember-runtime/lib/inject.js @@ -14,7 +14,7 @@ export default function inject() { } // Dictionary of injection validations by type, added to by `createInjectionHelper` -var typeValidators = {}; +const typeValidators = {}; /** This method allows other Ember modules to register injection helpers for a @@ -47,20 +47,19 @@ export function createInjectionHelper(type, validator) { @param {Object} factory The factory object */ export function validatePropertyInjections(factory) { - var proto = factory.proto(); - var types = []; - var key, desc, validator, i; + let proto = factory.proto(); + let types = []; - for (key in proto) { - desc = proto[key]; + for (let key in proto) { + let desc = proto[key]; if (desc instanceof InjectedProperty && types.indexOf(desc.type) === -1) { types.push(desc.type); } } if (types.length) { - for (i = 0; i < types.length; i++) { - validator = typeValidators[types[i]]; + for (let i = 0; i < types.length; i++) { + let validator = typeValidators[types[i]]; if (typeof validator === 'function') { validator(factory); diff --git a/packages/ember-runtime/lib/mixins/-proxy.js b/packages/ember-runtime/lib/mixins/-proxy.js index 2a0d618cacd..a0b58fde6d6 100644 --- a/packages/ember-runtime/lib/mixins/-proxy.js +++ b/packages/ember-runtime/lib/mixins/-proxy.js @@ -29,13 +29,13 @@ export function isProxy(value) { } function contentPropertyWillChange(content, contentKey) { - var key = contentKey.slice(8); // remove "content." + let key = contentKey.slice(8); // remove "content." if (key in this) { return; } // if shadowed in proxy propertyWillChange(this, key); } function contentPropertyDidChange(content, contentKey) { - var key = contentKey.slice(8); // remove "content." + let key = contentKey.slice(8); // remove "content." if (key in this) { return; } // if shadowed in proxy propertyDidChange(this, key); } @@ -69,19 +69,19 @@ export default Mixin.create({ _debugContainerKey: null, willWatchProperty(key) { - var contentKey = 'content.' + key; + let contentKey = 'content.' + key; _addBeforeObserver(this, contentKey, null, contentPropertyWillChange); addObserver(this, contentKey, null, contentPropertyDidChange); }, didUnwatchProperty(key) { - var contentKey = 'content.' + key; + let contentKey = 'content.' + key; _removeBeforeObserver(this, contentKey, null, contentPropertyWillChange); removeObserver(this, contentKey, null, contentPropertyDidChange); }, unknownProperty(key) { - var content = get(this, 'content'); + let content = get(this, 'content'); if (content) { deprecate( `You attempted to access \`${key}\` from \`${this}\`, but object proxying is deprecated. Please use \`model.${key}\` instead.`, @@ -93,7 +93,7 @@ export default Mixin.create({ }, setUnknownProperty(key, value) { - var m = meta(this); + let m = meta(this); if (m.proto === this) { // if marked as prototype then just defineProperty // rather than delegate @@ -101,7 +101,7 @@ export default Mixin.create({ return value; } - var content = get(this, 'content'); + let content = get(this, 'content'); assert(`Cannot delegate set('${key}', ${value}) to the \'content\' property of object proxy ${this}: its 'content' is undefined.`, content); deprecate( @@ -111,5 +111,4 @@ export default Mixin.create({ ); return set(content, key, value); } - }); diff --git a/packages/ember-runtime/lib/mixins/action_handler.js b/packages/ember-runtime/lib/mixins/action_handler.js index ba538c3e402..6b20309619d 100644 --- a/packages/ember-runtime/lib/mixins/action_handler.js +++ b/packages/ember-runtime/lib/mixins/action_handler.js @@ -18,7 +18,7 @@ import { get } from 'ember-metal/property_get'; @namespace Ember @private */ -var ActionHandler = Mixin.create({ +const ActionHandler = Mixin.create({ mergedProperties: ['actions'], /** @@ -38,7 +38,7 @@ var ActionHandler = Mixin.create({ ```js App.CanDisplayBanner = Ember.Mixin.create({ actions: { - displayBanner: function(msg) { + displayBanner(msg) { // ... } } @@ -46,7 +46,7 @@ var ActionHandler = Mixin.create({ App.WelcomeRoute = Ember.Route.extend(App.CanDisplayBanner, { actions: { - playMusic: function() { + playMusic() { // ... } } @@ -66,7 +66,7 @@ var ActionHandler = Mixin.create({ ```js App.SongRoute = Ember.Route.extend({ actions: { - myAction: function() { + myAction() { this.controllerFor("song"); this.transitionTo("other.route"); ... @@ -84,7 +84,7 @@ var ActionHandler = Mixin.create({ ```js App.DebugRoute = Ember.Mixin.create({ actions: { - debugRouteInformation: function() { + debugRouteInformation() { console.debug("trololo"); } } @@ -92,7 +92,7 @@ var ActionHandler = Mixin.create({ App.AnnoyingDebugRoute = Ember.Route.extend(App.DebugRoute, { actions: { - debugRouteInformation: function() { + debugRouteInformation() { // also call the debugRouteInformation of mixed in App.DebugRoute this._super(...arguments); @@ -125,7 +125,7 @@ var ActionHandler = Mixin.create({ App.AlbumSongRoute = Ember.Route.extend({ actions: { - startPlaying: function() { + startPlaying() { // ... if (actionShouldAlsoBeTriggeredOnParentRoute) { @@ -157,10 +157,10 @@ var ActionHandler = Mixin.create({ ```js App.WelcomeRoute = Ember.Route.extend({ actions: { - playTheme: function() { + playTheme() { this.send('playMusic', 'theme.mp3'); }, - playMusic: function(track) { + playMusic(track) { // ... } } @@ -173,17 +173,16 @@ var ActionHandler = Mixin.create({ @public */ send(actionName, ...args) { - var target; + let target; if (this.actions && this.actions[actionName]) { - var shouldBubble = this.actions[actionName].apply(this, args) === true; + let shouldBubble = this.actions[actionName].apply(this, args) === true; if (!shouldBubble) { return; } } if (target = get(this, 'target')) { assert( - 'The `target` for ' + this + ' (' + target + - ') does not have a `send` method', + 'The `target` for ' + this + ' (' + target + ') does not have a `send` method', typeof target.send === 'function' ); target.send(...arguments); diff --git a/packages/ember-runtime/lib/mixins/array.js b/packages/ember-runtime/lib/mixins/array.js index 43fbbf40189..1b539910f62 100644 --- a/packages/ember-runtime/lib/mixins/array.js +++ b/packages/ember-runtime/lib/mixins/array.js @@ -34,9 +34,9 @@ import { deprecate } from 'ember-metal/debug'; import isEnabled from 'ember-metal/features'; function arrayObserversHelper(obj, target, opts, operation, notify) { - var willChange = (opts && opts.willChange) || 'arrayWillChange'; - var didChange = (opts && opts.didChange) || 'arrayDidChange'; - var hasObservers = get(obj, 'hasArrayObservers'); + let willChange = (opts && opts.willChange) || 'arrayWillChange'; + let didChange = (opts && opts.didChange) || 'arrayDidChange'; + let hasObservers = get(obj, 'hasArrayObservers'); if (hasObservers === notify) { propertyWillChange(obj, 'hasArrayObservers'); @@ -114,7 +114,7 @@ export function isEmberArray(obj) { @since Ember 0.9.0 @public */ -var ArrayMixin = Mixin.create(Enumerable, { +const ArrayMixin = Mixin.create(Enumerable, { [EMBER_ARRAY]: true, @@ -139,7 +139,7 @@ var ArrayMixin = Mixin.create(Enumerable, { yourself. ```javascript - var arr = ['a', 'b', 'c', 'd']; + let arr = ['a', 'b', 'c', 'd']; arr.objectAt(0); // 'a' arr.objectAt(3); // 'd' @@ -165,7 +165,7 @@ var ArrayMixin = Mixin.create(Enumerable, { This returns the objects at the specified indexes, using `objectAt`. ```javascript - var arr = ['a', 'b', 'c', 'd']; + let arr = ['a', 'b', 'c', 'd']; arr.objectsAt([0, 1, 2]); // ['a', 'b', 'c'] arr.objectsAt([2, 3, 4]); // ['c', 'd', undefined] @@ -234,7 +234,7 @@ var ArrayMixin = Mixin.create(Enumerable, { slice. ```javascript - var arr = ['red', 'green', 'blue']; + let arr = ['red', 'green', 'blue']; arr.slice(0); // ['red', 'green', 'blue'] arr.slice(0, 2); // ['red', 'green'] @@ -248,8 +248,8 @@ var ArrayMixin = Mixin.create(Enumerable, { @public */ slice(beginIndex, endIndex) { - var ret = Ember.A(); - var length = get(this, 'length'); + let ret = Ember.A(); + let length = get(this, 'length'); if (isNone(beginIndex)) { beginIndex = 0; @@ -281,7 +281,7 @@ var ArrayMixin = Mixin.create(Enumerable, { the end of the array. Returns -1 if no match is found. ```javascript - var arr = ['a', 'b', 'c', 'd', 'a']; + let arr = ['a', 'b', 'c', 'd', 'a']; arr.indexOf('a'); // 0 arr.indexOf('z'); // -1 @@ -298,8 +298,7 @@ var ArrayMixin = Mixin.create(Enumerable, { @public */ indexOf(object, startAt) { - var len = get(this, 'length'); - var idx; + let len = get(this, 'length'); if (startAt === undefined) { startAt = 0; @@ -309,7 +308,7 @@ var ArrayMixin = Mixin.create(Enumerable, { startAt += len; } - for (idx = startAt; idx < len; idx++) { + for (let idx = startAt; idx < len; idx++) { if (objectAt(this, idx) === object) { return idx; } @@ -325,7 +324,7 @@ var ArrayMixin = Mixin.create(Enumerable, { from the end of the array. Returns -1 if no match is found. ```javascript - var arr = ['a', 'b', 'c', 'd', 'a']; + let arr = ['a', 'b', 'c', 'd', 'a']; arr.lastIndexOf('a'); // 4 arr.lastIndexOf('z'); // -1 @@ -342,8 +341,7 @@ var ArrayMixin = Mixin.create(Enumerable, { @public */ lastIndexOf(object, startAt) { - var len = get(this, 'length'); - var idx; + let len = get(this, 'length'); if (startAt === undefined || startAt >= len) { startAt = len - 1; @@ -353,7 +351,7 @@ var ArrayMixin = Mixin.create(Enumerable, { startAt += len; } - for (idx = startAt; idx >= 0; idx--) { + for (let idx = startAt; idx >= 0; idx--) { if (objectAt(this, idx) === object) { return idx; } @@ -439,7 +437,7 @@ var ArrayMixin = Mixin.create(Enumerable, { @public */ arrayContentWillChange(startIdx, removeAmt, addAmt) { - var removing, lim; + let removing, lim; // if no args are passed assume everything changes if (startIdx === undefined) { @@ -466,7 +464,7 @@ var ArrayMixin = Mixin.create(Enumerable, { removing = []; lim = startIdx + removeAmt; - for (var idx = startIdx; idx < lim; idx++) { + for (let idx = startIdx; idx < lim; idx++) { removing.push(objectAt(this, idx)); } } else { @@ -494,8 +492,6 @@ var ArrayMixin = Mixin.create(Enumerable, { @public */ arrayContentDidChange(startIdx, removeAmt, addAmt) { - var adding, lim; - markObjectAsDirty(metaFor(this)); // if no args are passed assume everything changes @@ -512,11 +508,12 @@ var ArrayMixin = Mixin.create(Enumerable, { } } + let adding; if (startIdx >= 0 && addAmt >= 0 && get(this, 'hasEnumerableObservers')) { adding = []; - lim = startIdx + addAmt; + let lim = startIdx + addAmt; - for (var idx = startIdx; idx < lim; idx++) { + for (let idx = startIdx; idx < lim; idx++) { adding.push(objectAt(this, idx)); } } else { @@ -531,9 +528,9 @@ var ArrayMixin = Mixin.create(Enumerable, { sendEvent(this, '@array:change', [this, startIdx, removeAmt, addAmt]); - var length = get(this, 'length'); - var cachedFirst = cacheFor(this, 'firstObject'); - var cachedLast = cacheFor(this, 'lastObject'); + let length = get(this, 'length'); + let cachedFirst = cacheFor(this, 'firstObject'); + let cachedLast = cacheFor(this, 'lastObject'); if (objectAt(this, 0) !== cachedFirst) { propertyWillChange(this, 'firstObject'); @@ -609,8 +606,7 @@ if (isEnabled('ember-runtime-enumerable-includes')) { @public */ includes(obj, startAt) { - var len = get(this, 'length'); - var idx, currentObj; + let len = get(this, 'length'); if (startAt === undefined) { startAt = 0; @@ -620,8 +616,8 @@ if (isEnabled('ember-runtime-enumerable-includes')) { startAt += len; } - for (idx = startAt; idx < len; idx++) { - currentObj = objectAt(this, idx); + for (let idx = startAt; idx < len; idx++) { + let currentObj = objectAt(this, idx); // SameValueZero comparison (NaN !== NaN) if (obj === currentObj || (obj !== obj && currentObj !== currentObj)) { diff --git a/packages/ember-runtime/lib/mixins/container_proxy.js b/packages/ember-runtime/lib/mixins/container_proxy.js index cdf83fa2acf..9e9cd6689da 100644 --- a/packages/ember-runtime/lib/mixins/container_proxy.js +++ b/packages/ember-runtime/lib/mixins/container_proxy.js @@ -54,17 +54,17 @@ export default Mixin.create({ to all have their own locally scoped singletons. ```javascript - var registry = new Registry(); - var container = registry.container(); + let registry = new Registry(); + let container = registry.container(); registry.register('api:twitter', Twitter); - var twitter = container.lookup('api:twitter'); + let twitter = container.lookup('api:twitter'); twitter instanceof Twitter; // => true // by default the container will return singletons - var twitter2 = container.lookup('api:twitter'); + let twitter2 = container.lookup('api:twitter'); twitter2 instanceof Twitter; // => true twitter === twitter2; //=> true @@ -73,13 +73,13 @@ export default Mixin.create({ If singletons are not wanted an optional flag can be provided at lookup. ```javascript - var registry = new Registry(); - var container = registry.container(); + let registry = new Registry(); + let container = registry.container(); registry.register('api:twitter', Twitter); - var twitter = container.lookup('api:twitter', { singleton: false }); - var twitter2 = container.lookup('api:twitter', { singleton: false }); + let twitter = container.lookup('api:twitter', { singleton: false }); + let twitter2 = container.lookup('api:twitter', { singleton: false }); twitter === twitter2; //=> false ``` diff --git a/packages/ember-runtime/lib/mixins/controller_content_model_alias_deprecation.js b/packages/ember-runtime/lib/mixins/controller_content_model_alias_deprecation.js index 1034067fe30..7d915abde78 100644 --- a/packages/ember-runtime/lib/mixins/controller_content_model_alias_deprecation.js +++ b/packages/ember-runtime/lib/mixins/controller_content_model_alias_deprecation.js @@ -33,7 +33,7 @@ export default Mixin.create({ // there is another Mixin loaded first. this._super(...arguments); - var modelSpecified = !!props.model; + let modelSpecified = !!props.model; if (props.content && !modelSpecified) { props.model = props.content; diff --git a/packages/ember-runtime/lib/mixins/enumerable.js b/packages/ember-runtime/lib/mixins/enumerable.js index cc62215e7c0..666366c6be6 100644 --- a/packages/ember-runtime/lib/mixins/enumerable.js +++ b/packages/ember-runtime/lib/mixins/enumerable.js @@ -37,7 +37,7 @@ function emberA() { return (_emberA || (_emberA = require('ember-runtime/system/native_array').A))(); } -var contexts = []; +const contexts = []; function popCtx() { return contexts.length === 0 ? {} : contexts.pop(); @@ -49,10 +49,10 @@ function pushCtx(ctx) { } function iter(key, value) { - var valueProvided = arguments.length === 2; + let valueProvided = arguments.length === 2; function i(item) { - var cur = get(item, key); + let cur = get(item, key); return valueProvided ? value === cur : !!cur; } @@ -97,7 +97,7 @@ function iter(key, value) { @since Ember 0.9 @private */ -var Enumerable = Mixin.create({ +const Enumerable = Mixin.create({ /** __Required.__ You must implement this method to apply this mixin. @@ -148,10 +148,10 @@ var Enumerable = Mixin.create({ If your enumerable is empty, this method should return `undefined`. ```javascript - var arr = ['a', 'b', 'c']; + let arr = ['a', 'b', 'c']; arr.get('firstObject'); // 'a' - var arr = []; + let arr = []; arr.get('firstObject'); // undefined ``` @@ -166,8 +166,8 @@ var Enumerable = Mixin.create({ } // handle generic enumerables - var context = popCtx(); - var ret = this.nextObject(0, null, context); + let context = popCtx(); + let ret = this.nextObject(0, null, context); pushCtx(context); @@ -180,10 +180,10 @@ var Enumerable = Mixin.create({ If your enumerable is empty, this method should return `undefined`. ```javascript - var arr = ['a', 'b', 'c']; + let arr = ['a', 'b', 'c']; arr.get('lastObject'); // 'c' - var arr = []; + let arr = []; arr.get('lastObject'); // undefined ``` @@ -193,16 +193,16 @@ var Enumerable = Mixin.create({ @public */ lastObject: computed('[]', function() { - var len = get(this, 'length'); + let len = get(this, 'length'); if (len === 0) { return undefined; } - var context = popCtx(); - var idx = 0; - var last = null; - var cur; + let context = popCtx(); + let idx = 0; + let last = null; + let cur; do { last = cur; @@ -220,7 +220,7 @@ var Enumerable = Mixin.create({ is found. You may want to override this with a more efficient version. ```javascript - var arr = ['a', 'b', 'c']; + let arr = ['a', 'b', 'c']; arr.contains('a'); // true arr.contains('z'); // false @@ -240,9 +240,7 @@ var Enumerable = Mixin.create({ ); } - var found = this.find(function(item) { - return item === obj; - }); + let found = this.find(item => item === obj); return found !== undefined; }, @@ -278,16 +276,16 @@ var Enumerable = Mixin.create({ throw new TypeError(); } - var context = popCtx(); - var len = get(this, 'length'); - var last = null; + let context = popCtx(); + let len = get(this, 'length'); + let last = null; if (target === undefined) { target = null; } - for (var idx = 0; idx < len; idx++) { - var next = this.nextObject(idx, last, context); + for (let idx = 0; idx < len; idx++) { + let next = this.nextObject(idx, last, context); callback.call(target, next, idx, this); last = next; } @@ -321,9 +319,7 @@ var Enumerable = Mixin.create({ @public */ setEach(key, value) { - return this.forEach(function(item) { - set(item, key, value); - }); + return this.forEach(item => set(item, key, value)); }, /** @@ -354,11 +350,9 @@ var Enumerable = Mixin.create({ @public */ map(callback, target) { - var ret = emberA(); + let ret = emberA(); - this.forEach(function(x, idx, i) { - ret[idx] = callback.call(target, x, idx, i); - }); + this.forEach((x, idx, i) => ret[idx] = callback.call(target, x, idx, i)); return ret; }, @@ -373,9 +367,7 @@ var Enumerable = Mixin.create({ @public */ mapBy(key) { - return this.map(function(next) { - return get(next, key); - }); + return this.map(next => get(next, key)); }, /** @@ -408,7 +400,7 @@ var Enumerable = Mixin.create({ @public */ filter(callback, target) { - var ret = emberA(); + let ret = emberA(); this.forEach(function(x, idx, i) { if (callback.call(target, x, idx, i)) { @@ -479,15 +471,9 @@ var Enumerable = Mixin.create({ @public */ rejectBy(key, value) { - var exactValue = function(item) { - return get(item, key) === value; - }; - - var hasValue = function(item) { - return !!get(item, key); - }; - - var use = (arguments.length === 2 ? exactValue : hasValue); + let exactValue = item => get(item, key) === value; + let hasValue = item => !!get(item, key); + let use = (arguments.length === 2 ? exactValue : hasValue); return this.reject(use); }, @@ -522,18 +508,18 @@ var Enumerable = Mixin.create({ @public */ find(callback, target) { - var len = get(this, 'length'); + let len = get(this, 'length'); if (target === undefined) { target = null; } - var context = popCtx(); - var found = false; - var last = null; - var next, ret; + let context = popCtx(); + let found = false; + let last = null; + let next, ret; - for (var idx = 0; idx < len && !found; idx++) { + for (let idx = 0; idx < len && !found; idx++) { next = this.nextObject(idx, last, context); if (found = callback.call(target, next, idx, this)) { @@ -658,17 +644,17 @@ var Enumerable = Mixin.create({ @public */ any(callback, target) { - var len = get(this, 'length'); - var context = popCtx(); - var found = false; - var last = null; - var next, idx; + let len = get(this, 'length'); + let context = popCtx(); + let found = false; + let last = null; + let next; if (target === undefined) { target = null; } - for (idx = 0; idx < len && !found; idx++) { + for (let idx = 0; idx < len && !found; idx++) { next = this.nextObject(idx, last, context); found = callback.call(target, next, idx, this); last = next; @@ -734,7 +720,7 @@ var Enumerable = Mixin.create({ throw new TypeError(); } - var ret = initialValue; + let ret = initialValue; this.forEach(function(item, i) { ret = callback(ret, item, i, this, reducerProperty); @@ -755,10 +741,10 @@ var Enumerable = Mixin.create({ @public */ invoke(methodName, ...args) { - var ret = emberA(); + let ret = emberA(); this.forEach(function(x, idx) { - var method = x && x[methodName]; + let method = x && x[methodName]; if ('function' === typeof method) { ret[idx] = args ? method.apply(x, args) : x[methodName](); @@ -777,11 +763,9 @@ var Enumerable = Mixin.create({ @public */ toArray() { - var ret = emberA(); + let ret = emberA(); - this.forEach(function(o, idx) { - ret[idx] = o; - }); + this.forEach((o, idx) => ret[idx] = o); return ret; }, @@ -790,7 +774,7 @@ var Enumerable = Mixin.create({ Returns a copy of the array with all `null` and `undefined` elements removed. ```javascript - var arr = ['a', null, 'c', undefined]; + let arr = ['a', null, 'c', undefined]; arr.compact(); // ['a', 'c'] ``` @@ -799,9 +783,7 @@ var Enumerable = Mixin.create({ @public */ compact() { - return this.filter(function(value) { - return value != null; - }); + return this.filter(value => value != null); }, /** @@ -810,7 +792,7 @@ var Enumerable = Mixin.create({ If the receiver does not contain the value it returns the original enumerable. ```javascript - var arr = ['a', 'b', 'a', 'c']; + let arr = ['a', 'b', 'a', 'c']; arr.without('a'); // ['b', 'c'] ``` @@ -824,9 +806,9 @@ var Enumerable = Mixin.create({ return this; // nothing to do } - var ret = emberA(); + let ret = emberA(); - this.forEach(function(k) { + this.forEach(k => { if (k !== value) { ret[ret.length] = k; } @@ -840,7 +822,7 @@ var Enumerable = Mixin.create({ implementation returns an array regardless of the receiver type. ```javascript - var arr = ['a', 'a', 'b', 'b']; + let arr = ['a', 'a', 'b', 'b']; arr.uniq(); // ['a', 'b'] ``` @@ -851,9 +833,9 @@ var Enumerable = Mixin.create({ @public */ uniq() { - var ret = emberA(); + let ret = emberA(); - this.forEach((k) => { + this.forEach(k => { if (ret.indexOf(k) < 0) { ret.push(k); } @@ -894,9 +876,9 @@ var Enumerable = Mixin.create({ @private */ addEnumerableObserver(target, opts) { - var willChange = (opts && opts.willChange) || 'enumerableWillChange'; - var didChange = (opts && opts.didChange) || 'enumerableDidChange'; - var hasObservers = get(this, 'hasEnumerableObservers'); + let willChange = (opts && opts.willChange) || 'enumerableWillChange'; + let didChange = (opts && opts.didChange) || 'enumerableDidChange'; + let hasObservers = get(this, 'hasEnumerableObservers'); if (!hasObservers) { propertyWillChange(this, 'hasEnumerableObservers'); @@ -922,9 +904,9 @@ var Enumerable = Mixin.create({ @private */ removeEnumerableObserver(target, opts) { - var willChange = (opts && opts.willChange) || 'enumerableWillChange'; - var didChange = (opts && opts.didChange) || 'enumerableDidChange'; - var hasObservers = get(this, 'hasEnumerableObservers'); + let willChange = (opts && opts.willChange) || 'enumerableWillChange'; + let didChange = (opts && opts.didChange) || 'enumerableDidChange'; + let hasObservers = get(this, 'hasEnumerableObservers'); if (hasObservers) { propertyWillChange(this, 'hasEnumerableObservers'); @@ -967,7 +949,7 @@ var Enumerable = Mixin.create({ @private */ enumerableContentWillChange(removing, adding) { - var removeCnt, addCnt, hasDelta; + let removeCnt, addCnt, hasDelta; if ('number' === typeof removing) { removeCnt = removing; @@ -1022,7 +1004,7 @@ var Enumerable = Mixin.create({ @private */ enumerableContentDidChange(removing, adding) { - var removeCnt, addCnt, hasDelta; + let removeCnt, addCnt, hasDelta; if ('number' === typeof removing) { removeCnt = removing; @@ -1074,15 +1056,15 @@ var Enumerable = Mixin.create({ @public */ sortBy() { - var sortKeys = arguments; + let sortKeys = arguments; - return this.toArray().sort(function(a, b) { - for (var i = 0; i < sortKeys.length; i++) { - var key = sortKeys[i]; - var propA = get(a, key); - var propB = get(b, key); + return this.toArray().sort((a, b) => { + for (let i = 0; i < sortKeys.length; i++) { + let key = sortKeys[i]; + let propA = get(a, key); + let propB = get(b, key); // return 1 or -1 else continue to the next sortKey - var compareValue = compare(propA, propB); + let compareValue = compare(propA, propB); if (compareValue) { return compareValue; @@ -1101,7 +1083,7 @@ if (isEnabled('ember-runtime-computed-uniq-by')) { The default implementation returns an array regardless of the receiver type. ```javascript - var arr = [{ value: 'a' }, { value: 'a' }, { value: 'b' }, { value: 'b' }]; + let arr = [{ value: 'a' }, { value: 'a' }, { value: 'b' }, { value: 'b' }]; arr.uniqBy('value'); // [{ value: 'a' }, { value: 'b' }] ``` @@ -1111,11 +1093,11 @@ if (isEnabled('ember-runtime-computed-uniq-by')) { */ uniqBy(key) { - var ret = emberA(); - var seen = new EmptyObject(); + let ret = emberA(); + let seen = new EmptyObject(); this.forEach((item) => { - var guid = guidFor(get(item, key)); + let guid = guidFor(get(item, key)); if (!(guid in seen)) { seen[guid] = true; ret.push(item); @@ -1146,12 +1128,12 @@ if (isEnabled('ember-runtime-enumerable-includes')) { includes(obj) { assert('Enumerable#includes cannot accept a second argument "startAt" as enumerable items are unordered.', arguments.length === 1); - var len = get(this, 'length'); - var idx, next; - var last = null; - var found = false; + let len = get(this, 'length'); + let idx, next; + let last = null; + let found = false; - var context = popCtx(); + let context = popCtx(); for (idx = 0; idx < len && !found; idx++) { next = this.nextObject(idx, last, context); @@ -1172,9 +1154,9 @@ if (isEnabled('ember-runtime-enumerable-includes')) { return this; // nothing to do } - var ret = emberA(); + let ret = emberA(); - this.forEach(function(k) { + this.forEach(k => { // SameValueZero comparison (NaN !== NaN) if (!(k === value || k !== k && value !== value)) { ret[ret.length] = k; diff --git a/packages/ember-runtime/lib/mixins/mutable_array.js b/packages/ember-runtime/lib/mixins/mutable_array.js index 873f7c3ed32..efdba681fec 100644 --- a/packages/ember-runtime/lib/mixins/mutable_array.js +++ b/packages/ember-runtime/lib/mixins/mutable_array.js @@ -11,8 +11,8 @@ // CONSTANTS // -var OUT_OF_RANGE_EXCEPTION = 'Index out of range'; -var EMPTY = []; +const OUT_OF_RANGE_EXCEPTION = 'Index out of range'; +const EMPTY = []; // .......................................................... // HELPERS @@ -72,7 +72,7 @@ export default Mixin.create(EmberArray, MutableEnumerable, { want to reuse an existing array without having to recreate it. ```javascript - var colors = ['red', 'green', 'blue']; + let colors = ['red', 'green', 'blue']; color.length(); // 3 colors.clear(); // [] @@ -84,7 +84,7 @@ export default Mixin.create(EmberArray, MutableEnumerable, { @public */ clear() { - var len = get(this, 'length'); + let len = get(this, 'length'); if (len === 0) { return this; } @@ -98,7 +98,7 @@ export default Mixin.create(EmberArray, MutableEnumerable, { specified index. ```javascript - var colors = ['red', 'green', 'blue']; + let colors = ['red', 'green', 'blue']; colors.insertAt(2, 'yellow'); // ['red', 'green', 'yellow', 'blue'] colors.insertAt(5, 'orange'); // Error: Index out of range @@ -127,7 +127,7 @@ export default Mixin.create(EmberArray, MutableEnumerable, { length this method will throw an `OUT_OF_RANGE_EXCEPTION`. ```javascript - var colors = ['red', 'green', 'blue', 'yellow', 'orange']; + let colors = ['red', 'green', 'blue', 'yellow', 'orange']; colors.removeAt(0); // ['green', 'blue', 'yellow', 'orange'] colors.removeAt(2, 2); // ['green', 'blue'] @@ -162,7 +162,7 @@ export default Mixin.create(EmberArray, MutableEnumerable, { is KVO-compliant. ```javascript - var colors = ['red', 'green']; + let colors = ['red', 'green']; colors.pushObject('black'); // ['red', 'green', 'black'] colors.pushObject(['yellow']); // ['red', 'green', ['yellow']] @@ -183,7 +183,7 @@ export default Mixin.create(EmberArray, MutableEnumerable, { notifying observers of the change until all objects are added. ```javascript - var colors = ['red']; + let colors = ['red']; colors.pushObjects(['yellow', 'orange']); // ['red', 'yellow', 'orange'] ``` @@ -206,7 +206,7 @@ export default Mixin.create(EmberArray, MutableEnumerable, { it is KVO-compliant. ```javascript - var colors = ['red', 'green', 'blue']; + let colors = ['red', 'green', 'blue']; colors.popObject(); // 'blue' console.log(colors); // ['red', 'green'] @@ -217,12 +217,12 @@ export default Mixin.create(EmberArray, MutableEnumerable, { @public */ popObject() { - var len = get(this, 'length'); + let len = get(this, 'length'); if (len === 0) { return null; } - var ret = objectAt(this, len - 1); + let ret = objectAt(this, len - 1); this.removeAt(len - 1, 1); return ret; }, @@ -232,7 +232,7 @@ export default Mixin.create(EmberArray, MutableEnumerable, { like `shift()` but it is KVO-compliant. ```javascript - var colors = ['red', 'green', 'blue']; + let colors = ['red', 'green', 'blue']; colors.shiftObject(); // 'red' console.log(colors); // ['green', 'blue'] @@ -247,7 +247,7 @@ export default Mixin.create(EmberArray, MutableEnumerable, { return null; } - var ret = objectAt(this, 0); + let ret = objectAt(this, 0); this.removeAt(0); return ret; }, @@ -257,7 +257,7 @@ export default Mixin.create(EmberArray, MutableEnumerable, { KVO-compliant. ```javascript - var colors = ['red']; + let colors = ['red']; colors.unshiftObject('yellow'); // ['yellow', 'red'] colors.unshiftObject(['black']); // [['black'], 'yellow', 'red'] @@ -278,7 +278,7 @@ export default Mixin.create(EmberArray, MutableEnumerable, { observers until all objects have been added. ```javascript - var colors = ['red']; + let colors = ['red']; colors.unshiftObjects(['black', 'white']); // ['black', 'white', 'red'] colors.unshiftObjects('yellow'); // Type Error: 'undefined' is not a function @@ -303,12 +303,12 @@ export default Mixin.create(EmberArray, MutableEnumerable, { @public */ reverseObjects() { - var len = get(this, 'length'); + let len = get(this, 'length'); if (len === 0) { return this; } - var objects = this.toArray().reverse(); + let objects = this.toArray().reverse(); this.replace(0, len, objects); return this; }, @@ -318,7 +318,7 @@ export default Mixin.create(EmberArray, MutableEnumerable, { If argument is an empty array receiver will be cleared. ```javascript - var colors = ['red', 'green', 'blue']; + let colors = ['red', 'green', 'blue']; colors.setObjects(['black', 'white']); // ['black', 'white'] colors.setObjects([]); // [] @@ -335,7 +335,7 @@ export default Mixin.create(EmberArray, MutableEnumerable, { return this.clear(); } - var len = get(this, 'length'); + let len = get(this, 'length'); this.replace(0, len, objects); return this; }, @@ -348,7 +348,7 @@ export default Mixin.create(EmberArray, MutableEnumerable, { Remove all occurrences of an object in the array. ```javascript - var cities = ['Chicago', 'Berlin', 'Lima', 'Chicago']; + let cities = ['Chicago', 'Berlin', 'Lima', 'Chicago']; cities.removeObject('Chicago'); // ['Berlin', 'Lima'] cities.removeObject('Lima'); // ['Berlin'] @@ -361,9 +361,9 @@ export default Mixin.create(EmberArray, MutableEnumerable, { @public */ removeObject(obj) { - var loc = get(this, 'length') || 0; + let loc = get(this, 'length') || 0; while (--loc >= 0) { - var curObject = objectAt(this, loc); + let curObject = objectAt(this, loc); if (curObject === obj) { this.removeAt(loc); @@ -377,7 +377,7 @@ export default Mixin.create(EmberArray, MutableEnumerable, { present in the array. ```javascript - var cities = ['Chicago', 'Berlin']; + let cities = ['Chicago', 'Berlin']; cities.addObject('Lima'); // ['Chicago', 'Berlin', 'Lima'] cities.addObject('Berlin'); // ['Chicago', 'Berlin', 'Lima'] @@ -389,7 +389,7 @@ export default Mixin.create(EmberArray, MutableEnumerable, { @public */ addObject(obj) { - var included; + let included; if (isEnabled('ember-runtime-enumerable-includes')) { included = this.includes(obj); diff --git a/packages/ember-runtime/lib/mixins/mutable_enumerable.js b/packages/ember-runtime/lib/mixins/mutable_enumerable.js index 0af1242b12a..62625a06249 100644 --- a/packages/ember-runtime/lib/mixins/mutable_enumerable.js +++ b/packages/ember-runtime/lib/mixins/mutable_enumerable.js @@ -76,7 +76,7 @@ export default Mixin.create(Enumerable, { */ addObjects(objects) { beginPropertyChanges(this); - objects.forEach((obj) => this.addObject(obj)); + objects.forEach(obj => this.addObject(obj)); endPropertyChanges(this); return this; }, @@ -109,7 +109,7 @@ export default Mixin.create(Enumerable, { */ removeObjects(objects) { beginPropertyChanges(this); - for (var i = objects.length - 1; i >= 0; i--) { + for (let i = objects.length - 1; i >= 0; i--) { this.removeObject(objects[i]); } endPropertyChanges(this); diff --git a/packages/ember-runtime/lib/mixins/promise_proxy.js b/packages/ember-runtime/lib/mixins/promise_proxy.js index e7289f0f388..97715f0dbde 100644 --- a/packages/ember-runtime/lib/mixins/promise_proxy.js +++ b/packages/ember-runtime/lib/mixins/promise_proxy.js @@ -16,13 +16,13 @@ function tap(proxy, promise) { isRejected: false }); - return promise.then(function(value) { + return promise.then(value => { setProperties(proxy, { content: value, isFulfilled: true }); return value; - }, function(reason) { + }, reason => { setProperties(proxy, { reason: reason, isRejected: true @@ -35,9 +35,9 @@ function tap(proxy, promise) { A low level mixin making ObjectProxy promise-aware. ```javascript - var ObjectPromiseProxy = Ember.ObjectProxy.extend(Ember.PromiseProxyMixin); + let ObjectPromiseProxy = Ember.ObjectProxy.extend(Ember.PromiseProxyMixin); - var proxy = ObjectPromiseProxy.create({ + let proxy = ObjectPromiseProxy.create({ promise: $.getJSON('/some/remote/data.json') }); @@ -201,7 +201,7 @@ export default Mixin.create({ function promiseAlias(name) { return function () { - var promise = get(this, 'promise'); + let promise = get(this, 'promise'); return promise[name](...arguments); }; } diff --git a/packages/ember-runtime/lib/mixins/registry_proxy.js b/packages/ember-runtime/lib/mixins/registry_proxy.js index 6f80fc355d5..27c20487dd2 100644 --- a/packages/ember-runtime/lib/mixins/registry_proxy.js +++ b/packages/ember-runtime/lib/mixins/registry_proxy.js @@ -34,7 +34,7 @@ export default Mixin.create({ A simple example: ```javascript - var App = Ember.Application.create(); + let App = Ember.Application.create(); App.Orange = Ember.Object.extend(); App.register('fruit:favorite', App.Orange); @@ -47,8 +47,8 @@ export default Mixin.create({ An example of registering a controller with a non-standard name: ```javascript - var App = Ember.Application.create(); - var Session = Ember.Controller.extend(); + let App = Ember.Application.create(); + let Session = Ember.Controller.extend(); App.register('controller:session', Session); @@ -66,7 +66,7 @@ export default Mixin.create({ Some examples modifying that default behavior: ```javascript - var App = Ember.Application.create(); + let App = Ember.Application.create(); App.Person = Ember.Object.extend(); App.Orange = Ember.Object.extend(); @@ -91,8 +91,8 @@ export default Mixin.create({ Unregister a factory. ```javascript - var App = Ember.Application.create(); - var User = Ember.Object.extend(); + let App = Ember.Application.create(); + let User = Ember.Object.extend(); App.register('model:user', User); App.resolveRegistration('model:user').create() instanceof User //=> true @@ -163,8 +163,8 @@ export default Mixin.create({ Allow registering options for all factories of a type. ```javascript - var App = Ember.Application.create(); - var appInstance = App.buildInstance(); + let App = Ember.Application.create(); + let appInstance = App.buildInstance(); // if all of type `connection` must not be singletons appInstance.optionsForType('connection', { singleton: false }); @@ -172,13 +172,13 @@ export default Mixin.create({ appInstance.register('connection:twitter', TwitterConnection); appInstance.register('connection:facebook', FacebookConnection); - var twitter = appInstance.lookup('connection:twitter'); - var twitter2 = appInstance.lookup('connection:twitter'); + let twitter = appInstance.lookup('connection:twitter'); + let twitter2 = appInstance.lookup('connection:twitter'); twitter === twitter2; // => false - var facebook = appInstance.lookup('connection:facebook'); - var facebook2 = appInstance.lookup('connection:facebook'); + let facebook = appInstance.lookup('connection:facebook'); + let facebook2 = appInstance.lookup('connection:facebook'); facebook === facebook2; // => false ``` @@ -211,8 +211,8 @@ export default Mixin.create({ An example of providing a session object to all controllers: ```javascript - var App = Ember.Application.create(); - var Session = Ember.Object.extend({ isAuthenticated: false }); + let App = Ember.Application.create(); + let Session = Ember.Object.extend({ isAuthenticated: false }); // A factory must be registered before it can be injected App.register('session:main', Session); @@ -260,8 +260,8 @@ function registryAlias(name) { } export function buildFakeRegistryWithDeprecations(instance, typeForMessage) { - var fakeRegistry = {}; - var registryProps = { + let fakeRegistry = {}; + let registryProps = { resolve: 'resolveRegistration', register: 'register', unregister: 'unregister', @@ -274,7 +274,7 @@ export function buildFakeRegistryWithDeprecations(instance, typeForMessage) { injection: 'inject' }; - for (var deprecatedProperty in registryProps) { + for (let deprecatedProperty in registryProps) { fakeRegistry[deprecatedProperty] = buildFakeRegistryFunction(instance, typeForMessage, deprecatedProperty, registryProps[deprecatedProperty]); } diff --git a/packages/ember-runtime/lib/mixins/target_action_support.js b/packages/ember-runtime/lib/mixins/target_action_support.js index 8b8b41ec54a..7270670de44 100644 --- a/packages/ember-runtime/lib/mixins/target_action_support.js +++ b/packages/ember-runtime/lib/mixins/target_action_support.js @@ -24,7 +24,7 @@ view-aware defaults for target and actionContext. @extends Ember.Mixin @private */ -var TargetActionSupport = Mixin.create({ +export default Mixin.create({ target: null, action: null, actionContext: null, @@ -34,10 +34,10 @@ var TargetActionSupport = Mixin.create({ return this._targetObject; } - var target = get(this, 'target'); + let target = get(this, 'target'); if (typeof target === 'string') { - var value = get(this, target); + let value = get(this, target); if (value === undefined) { value = get(context.lookup, target); } @@ -48,17 +48,17 @@ var TargetActionSupport = Mixin.create({ } }), - actionContextObject: computed(function() { - var actionContext = get(this, 'actionContext'); + actionContextObject: computed('actionContext', function() { + let actionContext = get(this, 'actionContext'); if (typeof actionContext === 'string') { - var value = get(this, actionContext); + let value = get(this, actionContext); if (value === undefined) { value = get(context.lookup, actionContext); } return value; } else { return actionContext; } - }).property('actionContext'), + }), /** Send an `action` with an `actionContext` to a `target`. The action, actionContext @@ -69,7 +69,7 @@ var TargetActionSupport = Mixin.create({ target: Ember.computed.alias('controller'), action: 'save', actionContext: Ember.computed.alias('context'), - click: function() { + click() { this.triggerAction(); // Sends the `save` action, along with the current context // to the current controller } @@ -81,7 +81,7 @@ var TargetActionSupport = Mixin.create({ ```javascript App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { - click: function() { + click() { this.triggerAction({ action: 'save', target: this.get('controller'), @@ -99,7 +99,7 @@ var TargetActionSupport = Mixin.create({ ```javascript App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { target: Ember.computed.alias('controller'), - click: function() { + click() { this.triggerAction({ action: 'save' }); // Sends the `save` action, along with a reference to `this`, @@ -114,12 +114,12 @@ var TargetActionSupport = Mixin.create({ @private */ triggerAction(opts = {}) { - var action = opts.action || get(this, 'action'); - var target = opts.target || get(this, 'targetObject'); - var actionContext = opts.actionContext; + let action = opts.action || get(this, 'action'); + let target = opts.target || get(this, 'targetObject'); + let actionContext = opts.actionContext; function args(options, actionName) { - var ret = []; + let ret = []; if (actionName) { ret.push(actionName); } return ret.concat(options); @@ -130,7 +130,7 @@ var TargetActionSupport = Mixin.create({ } if (target && action) { - var ret; + let ret; if (target.send) { ret = target.send.apply(target, args(actionContext, action)); @@ -149,5 +149,3 @@ var TargetActionSupport = Mixin.create({ } } }); - -export default TargetActionSupport; diff --git a/packages/ember-runtime/lib/system/array_proxy.js b/packages/ember-runtime/lib/system/array_proxy.js index fa23ff76dbc..f1b78d2ed96 100644 --- a/packages/ember-runtime/lib/system/array_proxy.js +++ b/packages/ember-runtime/lib/system/array_proxy.js @@ -28,8 +28,8 @@ import { @submodule ember-runtime */ -var OUT_OF_RANGE_EXCEPTION = 'Index out of range'; -var EMPTY = []; +const OUT_OF_RANGE_EXCEPTION = 'Index out of range'; +const EMPTY = []; function K() { return this; } @@ -42,8 +42,8 @@ function K() { return this; } A simple example of usage: ```javascript - var pets = ['dog', 'cat', 'fish']; - var ap = Ember.ArrayProxy.create({ content: Ember.A(pets) }); + let pets = ['dog', 'cat', 'fish']; + let ap = Ember.ArrayProxy.create({ content: Ember.A(pets) }); ap.get('firstObject'); // 'dog' ap.set('content', ['amoeba', 'paramecium']); @@ -55,8 +55,8 @@ function K() { return this; } `objectAtContent`: ```javascript - var pets = ['dog', 'cat', 'fish']; - var ap = Ember.ArrayProxy.create({ + let pets = ['dog', 'cat', 'fish']; + let ap = Ember.ArrayProxy.create({ content: Ember.A(pets), objectAtContent: function(idx) { return this.get('content').objectAt(idx).toUpperCase(); @@ -72,7 +72,7 @@ function K() { return this; } @uses Ember.MutableArray @public */ -var ArrayProxy = EmberObject.extend(MutableArray, { +export default EmberObject.extend(MutableArray, { /** The content array. Must be an object that implements `Ember.Array` and/or @@ -141,7 +141,7 @@ var ArrayProxy = EmberObject.extend(MutableArray, { }), _teardownContent() { - var content = get(this, 'content'); + let content = get(this, 'content'); if (content) { removeArrayObserver(content, this, { @@ -184,7 +184,7 @@ var ArrayProxy = EmberObject.extend(MutableArray, { @method _contentDidChange */ _contentDidChange: observer('content', function() { - var content = get(this, 'content'); + let content = get(this, 'content'); assert('Can\'t set ArrayProxy\'s content to itself', content !== this); @@ -192,7 +192,7 @@ var ArrayProxy = EmberObject.extend(MutableArray, { }), _setupContent() { - var content = get(this, 'content'); + let content = get(this, 'content'); if (content) { assert(`ArrayProxy expects an Array or Ember.ArrayProxy, but you passed ${typeof content}`, isArray(content) || content.isDestroyed); @@ -205,8 +205,8 @@ var ArrayProxy = EmberObject.extend(MutableArray, { }, _arrangedContentWillChange: _beforeObserver('arrangedContent', function() { - var arrangedContent = get(this, 'arrangedContent'); - var len = arrangedContent ? get(arrangedContent, 'length') : 0; + let arrangedContent = get(this, 'arrangedContent'); + let len = arrangedContent ? get(arrangedContent, 'length') : 0; this.arrangedContentArrayWillChange(this, 0, len, undefined); this.arrangedContentWillChange(this); @@ -215,8 +215,8 @@ var ArrayProxy = EmberObject.extend(MutableArray, { }), _arrangedContentDidChange: observer('arrangedContent', function() { - var arrangedContent = get(this, 'arrangedContent'); - var len = arrangedContent ? get(arrangedContent, 'length') : 0; + let arrangedContent = get(this, 'arrangedContent'); + let len = arrangedContent ? get(arrangedContent, 'length') : 0; assert('Can\'t set ArrayProxy\'s content to itself', arrangedContent !== this); @@ -227,7 +227,7 @@ var ArrayProxy = EmberObject.extend(MutableArray, { }), _setupArrangedContent() { - var arrangedContent = get(this, 'arrangedContent'); + let arrangedContent = get(this, 'arrangedContent'); if (arrangedContent) { assert(`ArrayProxy expects an Array or Ember.ArrayProxy, but you passed ${typeof arrangedContent}`, @@ -241,7 +241,7 @@ var ArrayProxy = EmberObject.extend(MutableArray, { }, _teardownArrangedContent() { - var arrangedContent = get(this, 'arrangedContent'); + let arrangedContent = get(this, 'arrangedContent'); if (arrangedContent) { removeArrayObserver(arrangedContent, this, { @@ -259,13 +259,13 @@ var ArrayProxy = EmberObject.extend(MutableArray, { }, length: computed(function() { - var arrangedContent = get(this, 'arrangedContent'); + let arrangedContent = get(this, 'arrangedContent'); return arrangedContent ? get(arrangedContent, 'length') : 0; // No dependencies since Enumerable notifies length of change }), _replace(idx, amt, objects) { - var content = get(this, 'content'); + let content = get(this, 'content'); assert('The content property of ' + this.constructor + ' should be set before modifying it', content); if (content) { this.replaceContent(idx, amt, objects); @@ -301,10 +301,9 @@ var ArrayProxy = EmberObject.extend(MutableArray, { removeAt(start, len) { if ('number' === typeof start) { - var content = get(this, 'content'); - var arrangedContent = get(this, 'arrangedContent'); - var indices = []; - var i; + let content = get(this, 'content'); + let arrangedContent = get(this, 'arrangedContent'); + let indices = []; if ((start < 0) || (start >= get(this, 'length'))) { throw new EmberError(OUT_OF_RANGE_EXCEPTION); @@ -315,16 +314,16 @@ var ArrayProxy = EmberObject.extend(MutableArray, { } // Get a list of indices in original content to remove - for (i = start; i < start + len; i++) { + for (let i = start; i < start + len; i++) { // Use arrangedContent here so we avoid confusion with objects transformed by objectAtContent indices.push(content.indexOf(objectAt(arrangedContent, i))); } // Replace in reverse order since indices will change - indices.sort(function(a, b) { return b - a; }); + indices.sort((a, b) => b - a); beginPropertyChanges(); - for (i = 0; i < indices.length; i++) { + for (let i = 0; i < indices.length; i++) { this._replace(indices[i], 1, EMPTY); } endPropertyChanges(); @@ -351,7 +350,7 @@ var ArrayProxy = EmberObject.extend(MutableArray, { return this.clear(); } - var len = get(this, 'length'); + let len = get(this, 'length'); this._replace(0, len, objects); return this; }, @@ -367,7 +366,7 @@ var ArrayProxy = EmberObject.extend(MutableArray, { }, slice() { - var arr = this.toArray(); + let arr = this.toArray(); return arr.slice(...arguments); }, @@ -390,5 +389,3 @@ var ArrayProxy = EmberObject.extend(MutableArray, { this._teardownContent(); } }); - -export default ArrayProxy; diff --git a/packages/ember-runtime/lib/system/each_proxy.js b/packages/ember-runtime/lib/system/each_proxy.js index d95c0324818..58ff3c71511 100644 --- a/packages/ember-runtime/lib/system/each_proxy.js +++ b/packages/ember-runtime/lib/system/each_proxy.js @@ -20,7 +20,7 @@ import { objectAt } from 'ember-runtime/mixins/array'; @class EachProxy @private */ -function EachProxy(content) { +export default function EachProxy(content) { this._content = content; this._keys = undefined; this.__ember_meta__ = null; @@ -129,5 +129,3 @@ function removeObserverForContentKey(content, keyName, proxy, idx, loc) { } } } - -export default EachProxy; diff --git a/packages/ember-runtime/lib/system/lazy_load.js b/packages/ember-runtime/lib/system/lazy_load.js index 79aabdc78f9..604a7286e96 100644 --- a/packages/ember-runtime/lib/system/lazy_load.js +++ b/packages/ember-runtime/lib/system/lazy_load.js @@ -7,9 +7,9 @@ import { ENV, environment } from 'ember-environment'; @submodule ember-runtime */ -var loadHooks = ENV.EMBER_LOAD_HOOKS || {}; -var loaded = {}; -export var _loaded = loaded; +const loadHooks = ENV.EMBER_LOAD_HOOKS || {}; +const loaded = {}; +export let _loaded = loaded; /** Detects when a specific package of Ember (e.g. 'Ember.Application') @@ -31,7 +31,7 @@ export var _loaded = loaded; @private */ export function onLoad(name, callback) { - var object = loaded[name]; + let object = loaded[name]; loadHooks[name] = loadHooks[name] || []; loadHooks[name].push(callback); @@ -56,7 +56,7 @@ export function runLoadHooks(name, object) { let window = environment.window; if (window && typeof CustomEvent === 'function') { - var event = new CustomEvent(name, { detail: object, name: name }); + let event = new CustomEvent(name, { detail: object, name: name }); window.dispatchEvent(event); } diff --git a/packages/ember-runtime/lib/system/namespace.js b/packages/ember-runtime/lib/system/namespace.js index 00fbee32723..eb3b0bf248d 100644 --- a/packages/ember-runtime/lib/system/namespace.js +++ b/packages/ember-runtime/lib/system/namespace.js @@ -45,7 +45,7 @@ export function setSearchDisabled(flag) { @extends Ember.Object @public */ -var Namespace = EmberObject.extend({ +const Namespace = EmberObject.extend({ isNamespace: true, init() { @@ -54,7 +54,7 @@ var Namespace = EmberObject.extend({ }, toString() { - var name = get(this, 'name') || get(this, 'modulePrefix'); + let name = get(this, 'name') || get(this, 'modulePrefix'); if (name) { return name; } findNamespaces(); @@ -66,8 +66,8 @@ var Namespace = EmberObject.extend({ }, destroy() { - var namespaces = Namespace.NAMESPACES; - var toString = this.toString(); + let namespaces = Namespace.NAMESPACES; + let toString = this.toString(); if (toString) { context.lookup[toString] = undefined; @@ -94,19 +94,19 @@ Namespace.reopenClass({ } }); -var NAMESPACES_BY_ID = Namespace.NAMESPACES_BY_ID; +let NAMESPACES_BY_ID = Namespace.NAMESPACES_BY_ID; -var hasOwnProp = ({}).hasOwnProperty; +let hasOwnProp = ({}).hasOwnProperty; function processNamespace(paths, root, seen) { - var idx = paths.length; + let idx = paths.length; NAMESPACES_BY_ID[paths.join('.')] = root; // Loop over all of the keys in the namespace, looking for classes - for (var key in root) { + for (let key in root) { if (!hasOwnProp.call(root, key)) { continue; } - var obj = root[key]; + let obj = root[key]; // If we are processing the `Ember` namespace, for example, the // `paths` will start with `["Ember"]`. Every iteration through @@ -169,7 +169,7 @@ function findNamespaces() { } function superClassString(mixin) { - var superclass = mixin.superclass; + let superclass = mixin.superclass; if (superclass) { if (superclass[NAME_KEY]) { return superclass[NAME_KEY]; @@ -183,14 +183,14 @@ function classToString() { processAllNamespaces(); } - var ret; + let ret; if (this[NAME_KEY]) { ret = this[NAME_KEY]; } else if (this._toString) { ret = this._toString; } else { - var str = superClassString(this); + let str = superClassString(this); if (str) { ret = '(subclass of ' + str + ')'; } else { @@ -203,8 +203,8 @@ function classToString() { } function processAllNamespaces() { - var unprocessedNamespaces = !Namespace.PROCESSED; - var unprocessedMixins = hasUnprocessedMixins(); + let unprocessedNamespaces = !Namespace.PROCESSED; + let unprocessedMixins = hasUnprocessedMixins(); if (unprocessedNamespaces) { findNamespaces(); @@ -212,10 +212,10 @@ function processAllNamespaces() { } if (unprocessedNamespaces || unprocessedMixins) { - var namespaces = Namespace.NAMESPACES; - var namespace; + let namespaces = Namespace.NAMESPACES; + let namespace; - for (var i = 0; i < namespaces.length; i++) { + for (let i = 0; i < namespaces.length; i++) { namespace = namespaces[i]; processNamespace([namespace.toString()], namespace, {}); } @@ -225,7 +225,7 @@ function processAllNamespaces() { } function makeToString(ret) { - return function() { return ret; }; + return () => ret; } Mixin.prototype.toString = classToString; // ES6TODO: altering imported objects. SBB. diff --git a/packages/ember-runtime/lib/system/native_array.js b/packages/ember-runtime/lib/system/native_array.js index f45524f5e44..79d03cdf3ac 100644 --- a/packages/ember-runtime/lib/system/native_array.js +++ b/packages/ember-runtime/lib/system/native_array.js @@ -32,7 +32,7 @@ import copy from 'ember-runtime/copy'; @uses Ember.Copyable @public */ -var NativeArray = Mixin.create(MutableArray, Observable, Copyable, { +let NativeArray = Mixin.create(MutableArray, Observable, Copyable, { // because length is a built-in property we need to know to just get the // original property. @@ -57,7 +57,7 @@ var NativeArray = Mixin.create(MutableArray, Observable, Copyable, { // if we replaced exactly the same number of items, then pass only the // replaced range. Otherwise, pass the full remaining array length // since everything has shifted - var len = objects ? get(objects, 'length') : 0; + let len = objects ? get(objects, 'length') : 0; this.arrayContentWillChange(idx, amt, len); if (len === 0) { @@ -73,7 +73,7 @@ var NativeArray = Mixin.create(MutableArray, Observable, Copyable, { // If you ask for an unknown property, then try to collect the value // from member items. unknownProperty(key, value) { - var ret;// = this.reducedProperty(key, value); + let ret;// = this.reducedProperty(key, value); if (value !== undefined && ret === undefined) { ret = this[key] = value; } @@ -93,7 +93,7 @@ var NativeArray = Mixin.create(MutableArray, Observable, Copyable, { }); // Remove any methods implemented natively so we don't override them -var ignore = ['length']; +const ignore = ['length']; NativeArray.keys().forEach((methodName) => { if (Array.prototype[methodName]) { ignore.push(methodName); @@ -132,13 +132,13 @@ NativeArray = NativeArray.without.apply(NativeArray, ignore); @return {Ember.NativeArray} @public */ -var A; +let A; if (ENV.EXTEND_PROTOTYPES.Array) { NativeArray.apply(Array.prototype); - A = function (arr) { return arr || []; }; + A = arr => arr || []; } else { - A = function (arr) { + A = arr => { if (!arr) { arr = []; } return EmberArray.detect(arr) ? arr : NativeArray.apply(arr); }; diff --git a/packages/ember-runtime/lib/system/object.js b/packages/ember-runtime/lib/system/object.js index 83bf4b39dae..01c2356e404 100644 --- a/packages/ember-runtime/lib/system/object.js +++ b/packages/ember-runtime/lib/system/object.js @@ -17,9 +17,7 @@ import Observable from 'ember-runtime/mixins/observable'; @uses Ember.Observable @public */ -var EmberObject = CoreObject.extend(Observable); -EmberObject.toString = function() { - return 'Ember.Object'; -}; +const EmberObject = CoreObject.extend(Observable); +EmberObject.toString = () => 'Ember.Object'; export default EmberObject; diff --git a/packages/ember-runtime/lib/system/string.js b/packages/ember-runtime/lib/system/string.js index fff6f741c7a..dff32c15294 100644 --- a/packages/ember-runtime/lib/system/string.js +++ b/packages/ember-runtime/lib/system/string.js @@ -13,16 +13,16 @@ import { import Cache from 'ember-metal/cache'; -var STRING_DASHERIZE_REGEXP = (/[ _]/g); +const STRING_DASHERIZE_REGEXP = (/[ _]/g); -var STRING_DASHERIZE_CACHE = new Cache(1000, function(key) { +const STRING_DASHERIZE_CACHE = new Cache(1000, function(key) { return decamelize(key).replace(STRING_DASHERIZE_REGEXP, '-'); }); -var STRING_CAMELIZE_REGEXP_1 = (/(\-|\_|\.|\s)+(.)?/g); -var STRING_CAMELIZE_REGEXP_2 = (/(^|\/)([A-Z])/g); +const STRING_CAMELIZE_REGEXP_1 = (/(\-|\_|\.|\s)+(.)?/g); +const STRING_CAMELIZE_REGEXP_2 = (/(^|\/)([A-Z])/g); -var CAMELIZE_CACHE = new Cache(1000, function(key) { +const CAMELIZE_CACHE = new Cache(1000, function(key) { return key.replace(STRING_CAMELIZE_REGEXP_1, function(match, separator, chr) { return chr ? chr.toUpperCase() : ''; }).replace(STRING_CAMELIZE_REGEXP_2, function(match, separator, chr) { @@ -30,19 +30,19 @@ var CAMELIZE_CACHE = new Cache(1000, function(key) { }); }); -var STRING_CLASSIFY_REGEXP_1 = (/^(\-|_)+(.)?/); -var STRING_CLASSIFY_REGEXP_2 = (/(.)(\-|\_|\.|\s)+(.)?/g); -var STRING_CLASSIFY_REGEXP_3 = (/(^|\/|\.)([a-z])/g); +const STRING_CLASSIFY_REGEXP_1 = (/^(\-|_)+(.)?/); +const STRING_CLASSIFY_REGEXP_2 = (/(.)(\-|\_|\.|\s)+(.)?/g); +const STRING_CLASSIFY_REGEXP_3 = (/(^|\/|\.)([a-z])/g); -var CLASSIFY_CACHE = new Cache(1000, function(str) { - var replace1 = function(match, separator, chr) { +const CLASSIFY_CACHE = new Cache(1000, function(str) { + let replace1 = function(match, separator, chr) { return chr ? ('_' + chr.toUpperCase()) : ''; }; - var replace2 = function(match, initialChar, separator, chr) { + let replace2 = function(match, initialChar, separator, chr) { return initialChar + (chr ? chr.toUpperCase() : ''); }; - var parts = str.split('/'); - for (var i = 0; i < parts.length; i++) { + let parts = str.split('/'); + for (let i = 0; i < parts.length; i++) { parts[i] = parts[i] .replace(STRING_CLASSIFY_REGEXP_1, replace1) .replace(STRING_CLASSIFY_REGEXP_2, replace2); @@ -53,41 +53,41 @@ var CLASSIFY_CACHE = new Cache(1000, function(str) { }); }); -var STRING_UNDERSCORE_REGEXP_1 = (/([a-z\d])([A-Z]+)/g); -var STRING_UNDERSCORE_REGEXP_2 = (/\-|\s+/g); +const STRING_UNDERSCORE_REGEXP_1 = (/([a-z\d])([A-Z]+)/g); +const STRING_UNDERSCORE_REGEXP_2 = (/\-|\s+/g); -var UNDERSCORE_CACHE = new Cache(1000, function(str) { +const UNDERSCORE_CACHE = new Cache(1000, function(str) { return str.replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2'). replace(STRING_UNDERSCORE_REGEXP_2, '_').toLowerCase(); }); -var STRING_CAPITALIZE_REGEXP = (/(^|\/)([a-z])/g); +const STRING_CAPITALIZE_REGEXP = (/(^|\/)([a-z])/g); -var CAPITALIZE_CACHE = new Cache(1000, function(str) { +const CAPITALIZE_CACHE = new Cache(1000, function(str) { return str.replace(STRING_CAPITALIZE_REGEXP, function(match, separator, chr) { return match.toUpperCase(); }); }); -var STRING_DECAMELIZE_REGEXP = (/([a-z\d])([A-Z])/g); +const STRING_DECAMELIZE_REGEXP = (/([a-z\d])([A-Z])/g); -var DECAMELIZE_CACHE = new Cache(1000, function(str) { +const DECAMELIZE_CACHE = new Cache(1000, function(str) { return str.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase(); }); function _fmt(str, formats) { - var cachedFormats = formats; + let cachedFormats = formats; if (!isArray(cachedFormats) || arguments.length > 2) { cachedFormats = new Array(arguments.length - 1); - for (var i = 1; i < arguments.length; i++) { + for (let i = 1; i < arguments.length; i++) { cachedFormats[i - 1] = arguments[i]; } } // first, replace any ORDERED replacements. - var idx = 0; // the current index for non-numerical replacements + let idx = 0; // the current index for non-numerical replacements return str.replace(/%@([0-9]+)?/g, function(s, argIndex) { argIndex = (argIndex) ? parseInt(argIndex, 10) - 1 : idx++; s = cachedFormats[argIndex]; diff --git a/packages/ember-runtime/lib/utils.js b/packages/ember-runtime/lib/utils.js index b975ad16d6f..f4ddafea5dc 100644 --- a/packages/ember-runtime/lib/utils.js +++ b/packages/ember-runtime/lib/utils.js @@ -4,7 +4,7 @@ import EmberObject from 'ember-runtime/system/object'; // ........................................ // TYPING & ARRAY MESSAGING // -var TYPE_MAP = { +const TYPE_MAP = { '[object Boolean]': 'boolean', '[object Number]': 'number', '[object String]': 'string', @@ -15,7 +15,7 @@ var TYPE_MAP = { '[object Object]': 'object' }; -var toString = Object.prototype.toString; +const { toString } = Object.prototype; /** Returns true if the passed object is an array or Array-like. @@ -108,7 +108,7 @@ export function isArray(obj) { export function typeOf(item) { if (item === null) { return 'null'; } if (item === undefined) { return 'undefined'; } - var ret = TYPE_MAP[toString.call(item)] || 'object'; + let ret = TYPE_MAP[toString.call(item)] || 'object'; if (ret === 'function') { if (EmberObject.detect(item)) { diff --git a/packages/ember-runtime/tests/computed/computed_macros_test.js b/packages/ember-runtime/tests/computed/computed_macros_test.js index c879155ebca..39d2b4e014e 100644 --- a/packages/ember-runtime/tests/computed/computed_macros_test.js +++ b/packages/ember-runtime/tests/computed/computed_macros_test.js @@ -26,7 +26,7 @@ import { A as emberA } from 'ember-runtime/system/native_array'; QUnit.module('CP macros'); testBoth('Ember.computed.empty', function (get, set) { - var obj = EmberObject.extend({ + let obj = EmberObject.extend({ bestLannister: null, lannisters: null, @@ -47,7 +47,7 @@ testBoth('Ember.computed.empty', function (get, set) { }); testBoth('Ember.computed.notEmpty', function(get, set) { - var obj = EmberObject.extend({ + let obj = EmberObject.extend({ bestLannister: null, lannisters: null, @@ -68,7 +68,7 @@ testBoth('Ember.computed.notEmpty', function(get, set) { }); testBoth('computed.not', function(get, set) { - var obj = { foo: true }; + let obj = { foo: true }; defineProperty(obj, 'notFoo', not('foo')); equal(get(obj, 'notFoo'), false); @@ -78,7 +78,7 @@ testBoth('computed.not', function(get, set) { }); testBoth('computed.empty', function(get, set) { - var obj = { foo: [], bar: undefined, baz: null, quz: '' }; + let obj = { foo: [], bar: undefined, baz: null, quz: '' }; defineProperty(obj, 'fooEmpty', empty('foo')); defineProperty(obj, 'barEmpty', empty('bar')); defineProperty(obj, 'bazEmpty', empty('baz')); @@ -95,7 +95,7 @@ testBoth('computed.empty', function(get, set) { }); testBoth('computed.bool', function(get, set) { - var obj = { foo() {}, bar: 'asdf', baz: null, quz: false }; + let obj = { foo() {}, bar: 'asdf', baz: null, quz: false }; defineProperty(obj, 'fooBool', bool('foo')); defineProperty(obj, 'barBool', bool('bar')); defineProperty(obj, 'bazBool', bool('baz')); @@ -107,7 +107,7 @@ testBoth('computed.bool', function(get, set) { }); testBoth('computed.alias', function(get, set) { - var obj = { bar: 'asdf', baz: null, quz: false }; + let obj = { bar: 'asdf', baz: null, quz: false }; defineProperty(obj, 'bay', computed(function(key) { return 'apple'; })); @@ -136,8 +136,8 @@ testBoth('computed.alias', function(get, set) { }); testBoth('computed.alias set', function(get, set) { - var obj = {}; - var constantValue = 'always `a`'; + let obj = {}; + let constantValue = 'always `a`'; defineProperty(obj, 'original', computed({ get: function(key) { return constantValue; }, @@ -155,7 +155,7 @@ testBoth('computed.alias set', function(get, set) { }); testBoth('computed.match', function(get, set) { - var obj = { name: 'Paul' }; + let obj = { name: 'Paul' }; defineProperty(obj, 'isPaul', match('name', /Paul/)); equal(get(obj, 'isPaul'), true, 'is Paul'); @@ -166,7 +166,7 @@ testBoth('computed.match', function(get, set) { }); testBoth('computed.notEmpty', function(get, set) { - var obj = { items: [1] }; + let obj = { items: [1] }; defineProperty(obj, 'hasItems', notEmpty('items')); equal(get(obj, 'hasItems'), true, 'is not empty'); @@ -177,7 +177,7 @@ testBoth('computed.notEmpty', function(get, set) { }); testBoth('computed.equal', function(get, set) { - var obj = { name: 'Paul' }; + let obj = { name: 'Paul' }; defineProperty(obj, 'isPaul', computedEqual('name', 'Paul')); equal(get(obj, 'isPaul'), true, 'is Paul'); @@ -188,7 +188,7 @@ testBoth('computed.equal', function(get, set) { }); testBoth('computed.gt', function(get, set) { - var obj = { number: 2 }; + let obj = { number: 2 }; defineProperty(obj, 'isGreaterThenOne', gt('number', 1)); equal(get(obj, 'isGreaterThenOne'), true, 'is gt'); @@ -203,7 +203,7 @@ testBoth('computed.gt', function(get, set) { }); testBoth('computed.gte', function(get, set) { - var obj = { number: 2 }; + let obj = { number: 2 }; defineProperty(obj, 'isGreaterOrEqualThenOne', gte('number', 1)); equal(get(obj, 'isGreaterOrEqualThenOne'), true, 'is gte'); @@ -218,7 +218,7 @@ testBoth('computed.gte', function(get, set) { }); testBoth('computed.lt', function(get, set) { - var obj = { number: 0 }; + let obj = { number: 0 }; defineProperty(obj, 'isLesserThenOne', lt('number', 1)); equal(get(obj, 'isLesserThenOne'), true, 'is lt'); @@ -233,7 +233,7 @@ testBoth('computed.lt', function(get, set) { }); testBoth('computed.lte', function(get, set) { - var obj = { number: 0 }; + let obj = { number: 0 }; defineProperty(obj, 'isLesserOrEqualThenOne', lte('number', 1)); equal(get(obj, 'isLesserOrEqualThenOne'), true, 'is lte'); @@ -248,7 +248,7 @@ testBoth('computed.lte', function(get, set) { }); testBoth('computed.and two properties', function(get, set) { - var obj = { one: true, two: true }; + let obj = { one: true, two: true }; defineProperty(obj, 'oneAndTwo', and('one', 'two')); equal(get(obj, 'oneAndTwo'), true, 'one and two'); @@ -269,7 +269,7 @@ testBoth('computed.and two properties', function(get, set) { }); testBoth('computed.and three properties', function(get, set) { - var obj = { one: true, two: true, three: true }; + let obj = { one: true, two: true, three: true }; defineProperty(obj, 'oneTwoThree', and('one', 'two', 'three')); equal(get(obj, 'oneTwoThree'), true, 'one and two and three'); @@ -286,7 +286,7 @@ testBoth('computed.and three properties', function(get, set) { }); testBoth('computed.and expand properties', function(get, set) { - var obj = { one: true, two: true, three: true }; + let obj = { one: true, two: true, three: true }; defineProperty(obj, 'oneTwoThree', and('{one,two,three}')); equal(get(obj, 'oneTwoThree'), true, 'one and two and three'); @@ -303,7 +303,7 @@ testBoth('computed.and expand properties', function(get, set) { }); testBoth('computed.or two properties', function(get, set) { - var obj = { one: true, two: true }; + let obj = { one: true, two: true }; defineProperty(obj, 'oneOrTwo', or('one', 'two')); equal(get(obj, 'oneOrTwo'), true, 'one or two'); @@ -330,7 +330,7 @@ testBoth('computed.or two properties', function(get, set) { }); testBoth('computed.or three properties', function(get, set) { - var obj = { one: true, two: true, three: true }; + let obj = { one: true, two: true, three: true }; defineProperty(obj, 'oneTwoThree', or('one', 'two', 'three')); equal(get(obj, 'oneTwoThree'), true, 'one or two or three'); @@ -361,7 +361,7 @@ testBoth('computed.or three properties', function(get, set) { }); testBoth('computed.or expand properties', function(get, set) { - var obj = { one: true, two: true, three: true }; + let obj = { one: true, two: true, three: true }; defineProperty(obj, 'oneTwoThree', or('{one,two,three}')); equal(get(obj, 'oneTwoThree'), true, 'one or two or three'); @@ -392,7 +392,7 @@ testBoth('computed.or expand properties', function(get, set) { }); testBoth('computed.or and computed.and warn about dependent keys with spaces', function(get, set) { - var obj = { one: true, two: true }; + let obj = { one: true, two: true }; expectAssertion(function() { defineProperty(obj, 'oneOrTwo', or('one', 'two three')); }, /Dependent keys passed to Ember\.computed\.or\(\) can't have spaces\./); @@ -403,7 +403,7 @@ testBoth('computed.or and computed.and warn about dependent keys with spaces', f }); testBoth('computed.oneWay', function(get, set) { - var obj = { + let obj = { firstName: 'Teddy', lastName: 'Zeenny' }; @@ -427,7 +427,7 @@ testBoth('computed.oneWay', function(get, set) { }); testBoth('computed.readOnly', function(get, set) { - var obj = { + let obj = { firstName: 'Teddy', lastName: 'Zeenny' }; @@ -453,7 +453,7 @@ testBoth('computed.readOnly', function(get, set) { }); testBoth('computed.deprecatingAlias', function(get, set) { - var obj = { bar: 'asdf', baz: null, quz: false }; + let obj = { bar: 'asdf', baz: null, quz: false }; defineProperty(obj, 'bay', computed(function(key) { return 'apple'; })); diff --git a/packages/ember-runtime/tests/computed/reduce_computed_macros_test.js b/packages/ember-runtime/tests/computed/reduce_computed_macros_test.js index 243e10faec8..14af521fdb6 100644 --- a/packages/ember-runtime/tests/computed/reduce_computed_macros_test.js +++ b/packages/ember-runtime/tests/computed/reduce_computed_macros_test.js @@ -29,7 +29,7 @@ import { isArray } from 'ember-runtime/utils'; import { testBoth } from 'ember-metal/tests/props_helper'; import { A as emberA } from 'ember-runtime/system/native_array'; -var obj; +let obj; QUnit.module('map', { setup() { obj = EmberObject.extend({ @@ -74,7 +74,7 @@ QUnit.test('it maps simple properties', function() { }); QUnit.test('it maps simple unshifted properties', function() { - var array = emberA(); + let array = emberA(); obj = EmberObject.extend({ mapped: map('array', (item) => item.toUpperCase()) @@ -108,7 +108,7 @@ QUnit.test('it has the correct `this`', function() { }); QUnit.test('it passes the index to the callback', function() { - var array = ['a', 'b', 'c']; + let array = ['a', 'b', 'c']; obj = EmberObject.extend({ mapped: map('array', (item, index) => index) @@ -151,8 +151,8 @@ QUnit.test('it maps objects', function() { }); QUnit.test('it maps unshifted objects with property observers', function() { - var array = emberA(); - var cObj = { v: 'c' }; + let array = emberA(); + let cObj = { v: 'c' }; obj = EmberObject.extend({ mapped: map('array.@each.v', (item) => get(item, 'v').toUpperCase()) @@ -207,7 +207,7 @@ QUnit.test('it maps properties', function() { }); QUnit.test('it is observable', function() { - var calls = 0; + let calls = 0; deepEqual(obj.get('mapped'), [1, 3, 2, 1]); @@ -278,13 +278,13 @@ QUnit.test('it passes the array to the callback', function() { }); QUnit.test('it caches properly', function() { - var array = obj.get('array'); + let array = obj.get('array'); - var filtered = obj.get('filtered'); + let filtered = obj.get('filtered'); ok(filtered === obj.get('filtered')); array.addObject(11); - var newFiltered = obj.get('filtered'); + let newFiltered = obj.get('filtered'); ok(filtered !== newFiltered); @@ -292,7 +292,7 @@ QUnit.test('it caches properly', function() { }); QUnit.test('it updates as the array is modified', function() { - var array = obj.get('array'); + let array = obj.get('array'); deepEqual(obj.get('filtered'), [2, 4, 6, 8], 'precond - filtered array is initially correct'); @@ -309,7 +309,7 @@ QUnit.test('it updates as the array is modified', function() { }); QUnit.test('the dependent array can be cleared one at a time', function() { - var array = get(obj, 'array'); + let array = get(obj, 'array'); deepEqual(obj.get('filtered'), [2, 4, 6, 8], 'precond - filtered array is initially correct'); @@ -461,8 +461,8 @@ QUnit.test('properties values can be replaced', function() { }); QUnit.test('does not include duplicates', function() { - var array = obj.get('array'); - var array2 = obj.get('array2'); + let array = obj.get('array'); + let array2 = obj.get('array2'); deepEqual(obj.get('union').sort((x, y) => x - y), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], name + ' does not include duplicates'); @@ -484,7 +484,7 @@ QUnit.test('properties values can be replaced', function() { }); QUnit.test('has set-union semantics', function() { - var array = obj.get('array'); + let array = obj.get('array'); deepEqual(obj.get('union').sort((x, y) => x - y), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], name + ' is initially correct'); @@ -561,7 +561,7 @@ if (isEnabled('ember-runtime-computed-uniq-by')) { }); QUnit.test('it returns an empty array when computed on a non-array', function() { - var MyObject = EmberObject.extend({ + let MyObject = EmberObject.extend({ list: null, uniq: uniqBy('list', 'name') }); @@ -593,8 +593,8 @@ QUnit.test('intersect is readOnly', function() { }); QUnit.test('it has set-intersection semantics', function() { - var array2 = obj.get('array2'); - var array3 = obj.get('array3'); + let array2 = obj.get('array2'); + let array3 = obj.get('array3'); deepEqual(obj.get('intersection').sort((x, y) => x - y), [3, 5], 'intersection is initially correct'); @@ -662,8 +662,8 @@ QUnit.test('it throws an error if given fewer or more than two dependent propert QUnit.test('it has set-diff semantics', function() { - var array1 = obj.get('array'); - var array2 = obj.get('array2'); + let array1 = obj.get('array'); + let array2 = obj.get('array2'); deepEqual(obj.get('diff').sort((x, y) => x - y), [1, 2, 6, 7], 'set-diff is initially correct'); @@ -732,7 +732,7 @@ function commonSortTests() { }); QUnit.test('adding to the dependent array updates the sorted array', function() { - var items = obj.get('items'); + let items = obj.get('items'); deepEqual(obj.get('sortedItems').mapBy('fname'), [ 'Cersei', @@ -775,19 +775,19 @@ function commonSortTests() { QUnit.test('distinct items may be sort-equal, although their relative order will not be guaranteed', function() { // We recreate jaime and "Cersei" here only for test stability: we want // their guid-ordering to be deterministic - var jaimeInDisguise = { + let jaimeInDisguise = { fname: 'Cersei', lname: 'Lannister', age: 34 }; - var jaime = { + let jaime = { fname: 'Jaime', lname: 'Lannister', age: 34 }; - var items = obj.get('items'); + let items = obj.get('items'); items.replace(0, 1, jaime); items.replace(1, 1, jaimeInDisguise); @@ -819,18 +819,18 @@ function commonSortTests() { }); QUnit.test('guid sort-order fallback with a search proxy is not confused by non-search ObjectProxys', function() { - var tyrion = { + let tyrion = { fname: 'Tyrion', lname: 'Lannister' }; - var tyrionInDisguise = ObjectProxy.create({ + let tyrionInDisguise = ObjectProxy.create({ fname: 'Yollo', lname: '', content: tyrion }); - var items = obj.get('items'); + let items = obj.get('items'); items.pushObject(tyrion); @@ -883,7 +883,7 @@ QUnit.test('sort is readOnly', function() { commonSortTests(); QUnit.test('updating sort properties detaches observers for old sort properties', function() { - var objectToRemove = obj.get('items')[3]; + let objectToRemove = obj.get('items')[3]; deepEqual(obj.get('sortedItems').mapBy('fname'), [ 'Cersei', @@ -937,7 +937,7 @@ QUnit.test('updating sort properties updates the sorted array', function() { }); QUnit.test('updating sort properties invalidates the sorted array', function() { - var sortProps = obj.get('itemSorting'); + let sortProps = obj.get('itemSorting'); deepEqual(obj.get('sortedItems').mapBy('fname'), [ 'Cersei', @@ -1012,7 +1012,7 @@ QUnit.test('sort direction defaults to ascending (with sort property change)', f }); QUnit.test('updating an item\'s sort properties updates the sorted array', function() { - var tyrionInDisguise = obj.get('items')[1]; + let tyrionInDisguise = obj.get('items')[1]; deepEqual(obj.get('sortedItems').mapBy('fname'), [ 'Cersei', @@ -1032,7 +1032,7 @@ QUnit.test('updating an item\'s sort properties updates the sorted array', funct }); QUnit.test('updating several of an item\'s sort properties updated the sorted array', function() { - var sansaInDisguise = obj.get('items')[1]; + let sansaInDisguise = obj.get('items')[1]; deepEqual(obj.get('sortedItems').mapBy('fname'), [ 'Cersei', @@ -1055,17 +1055,17 @@ QUnit.test('updating several of an item\'s sort properties updated the sorted ar }); QUnit.test('updating an item\'s sort properties does not error when binary search does a self compare (#3273)', function() { - var jaime = { + let jaime = { name: 'Jaime', status: 1 }; - var cersei = { + let cersei = { name: 'Cersei', status: 2 }; - var obj = EmberObject.extend({ + let obj = EmberObject.extend({ sortProps: ['status'], sortedPeople: sort('people', 'sortProps') }).create({ @@ -1093,13 +1093,13 @@ QUnit.test('updating an item\'s sort properties does not error when binary searc }); QUnit.test('array observers do not leak', function() { - var daria = { name: 'Daria' }; - var jane = { name: 'Jane' }; + let daria = { name: 'Daria' }; + let jane = { name: 'Jane' }; - var sisters = [jane, daria]; + let sisters = [jane, daria]; - var sortProps = emberA(['name']); - var jaime = EmberObject.extend({ + let sortProps = emberA(['name']); + let jaime = EmberObject.extend({ sortedPeople: sort('sisters', 'sortProps'), sortProps }).create({ @@ -1120,19 +1120,19 @@ QUnit.test('array observers do not leak', function() { }); QUnit.test('property paths in sort properties update the sorted array', function () { - var jaime = { + let jaime = { relatedObj: { status: 1, firstName: 'Jaime', lastName: 'Lannister' } }; - var cersei = { + let cersei = { relatedObj: { status: 2, firstName: 'Cersei', lastName: 'Lannister' } }; - var sansa = EmberObject.create({ + let sansa = EmberObject.create({ relatedObj: { status: 3, firstName: 'Sansa', lastName: 'Stark' } }); - var obj = EmberObject.extend({ + let obj = EmberObject.extend({ sortProps: ['relatedObj.status'], sortedPeople: sort('people', 'sortProps') }).create({ @@ -1182,8 +1182,8 @@ QUnit.test('if the dependentKey is neither an array nor object, it will return a }); function sortByLnameFname(a, b) { - var lna = get(a, 'lname'); - var lnb = get(b, 'lname'); + let lna = get(a, 'lname'); + let lnb = get(b, 'lname'); if (lna !== lnb) { return lna > lnb ? 1 : -1; @@ -1193,8 +1193,8 @@ function sortByLnameFname(a, b) { } function sortByFnameAsc(a, b) { - var fna = get(a, 'fname'); - var fnb = get(b, 'fname'); + let fna = get(a, 'fname'); + let fnb = get(b, 'fname'); if (fna === fnb) { return 0; @@ -1221,7 +1221,7 @@ QUnit.module('sort - sort function', { }); QUnit.test('sort has correct `this`', function() { - var obj = EmberObject.extend({ + let obj = EmberObject.extend({ sortedItems: sort('items.@each.fname', function(a, b) { equal(this, obj, 'expected the object to be `this`'); return this.sortByLastName(a, b); @@ -1250,9 +1250,9 @@ QUnit.test('sort (with function) is readOnly', function() { commonSortTests(); QUnit.test('changing item properties specified via @each triggers a resort of the modified item', function() { - var items = get(obj, 'items'); + let items = get(obj, 'items'); - var tyrionInDisguise = items[1]; + let tyrionInDisguise = items[1]; deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); @@ -1262,8 +1262,8 @@ QUnit.test('changing item properties specified via @each triggers a resort of th }); QUnit.test('changing item properties not specified via @each does not trigger a resort', function() { - var items = obj.get('items'); - var cersei = items[1]; + let items = obj.get('items'); + let cersei = items[1]; deepEqual(obj.get('sortedItems').mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], 'precond - array is initially sorted'); @@ -1302,7 +1302,7 @@ QUnit.test('sorts correctly as only one property changes', function() { deepEqual(obj.get('sortedItems').mapBy('name'), ['A', 'B', 'C', 'D'], 'final'); }); -var klass; +let klass; QUnit.module('sort - concurrency', { setup() { klass = EmberObject.extend({ @@ -1326,7 +1326,7 @@ QUnit.module('sort - concurrency', { }); QUnit.test('sorts correctly after mutation to the sort properties', function() { - var sorted = obj.get('sortedItems'); + let sorted = obj.get('sortedItems'); deepEqual(sorted.mapBy('name'), ['A', 'B', 'C', 'D'], 'initial'); set(obj.get('items')[1], 'count', 5); @@ -1347,7 +1347,7 @@ QUnit.test('sort correctly after mutation to the sort', function() { }); QUnit.test('sort correctly on multiple instances of the same class', function() { - var obj2 = klass.create({ + let obj2 = klass.create({ items: emberA([ { name: 'W', count: 23, thing: 4 }, { name: 'X', count: 24, thing: 3 }, @@ -1381,7 +1381,7 @@ QUnit.test('sort correctly on multiple instances of the same class', function() QUnit.test('sort correctly when multiple sorts are chained on the same instance of a class', function() { - var obj2 = klass.extend({ + let obj2 = klass.extend({ items: computed('sibling.sortedItems.[]', function() { return this.get('sibling.sortedItems'); }), @@ -1446,7 +1446,7 @@ QUnit.test('max is readOnly', function() { QUnit.test('max tracks the max number as objects are added', function() { equal(obj.get('max'), 3, 'precond - max is initially correct'); - var items = obj.get('items'); + let items = obj.get('items'); items.pushObject(5); @@ -1501,7 +1501,7 @@ QUnit.test('min tracks the min number as objects are added', function() { }); QUnit.test('min recomputes when the current min is removed', function() { - var items = obj.get('items'); + let items = obj.get('items'); equal(obj.get('min'), 1, 'precond - min is initially correct'); @@ -1539,7 +1539,7 @@ QUnit.module('Ember.arrayComputed - mixed sugar', { }); QUnit.test('filtering and sorting can be combined', function() { - var items = obj.get('items'); + let items = obj.get('items'); deepEqual(obj.get('sortedLannisters').mapBy('fname'), ['Cersei', 'Jaime'], 'precond - array is initially filtered and sorted'); @@ -1551,7 +1551,7 @@ QUnit.test('filtering and sorting can be combined', function() { }); QUnit.test('filtering, sorting and reduce (max) can be combined', function() { - var items = obj.get('items'); + let items = obj.get('items'); equal(16, obj.get('oldestStarkAge'), 'precond - end of chain is initially correct'); @@ -1569,14 +1569,14 @@ function todo(name, priority) { } function priorityComparator(todoA, todoB) { - var pa = parseInt(get(todoA, 'priority'), 10); - var pb = parseInt(get(todoB, 'priority'), 10); + let pa = parseInt(get(todoA, 'priority'), 10); + let pb = parseInt(get(todoB, 'priority'), 10); return pa - pb; } function evenPriorities(todo) { - var p = parseInt(get(todo, 'priority'), 10); + let p = parseInt(get(todo, 'priority'), 10); return p % 2 === 0; } @@ -1613,7 +1613,7 @@ QUnit.test('it can filter and sort when both depend on the same item property', deepEqual(obj.get('filtered').mapBy('name'), ['A', 'C', 'E', 'D'], 'filtered updated correctly'); }); -var userFnCalls; +let userFnCalls; QUnit.module('Chaining array and reduced CPs', { setup() { userFnCalls = 0; @@ -1638,7 +1638,7 @@ QUnit.module('Chaining array and reduced CPs', { QUnit.test('it computes interdependent array computed properties', function() { equal(obj.get('max'), 3, 'sanity - it properly computes the maximum value'); - var calls = 0; + let calls = 0; addObserver(obj, 'max', () => calls++); @@ -1696,7 +1696,7 @@ QUnit.test('updates when array is modified', function() { QUnit.module('collect'); testBoth('works', function(get, set) { - var obj = { one: 'foo', two: 'bar', three: null }; + let obj = { one: 'foo', two: 'bar', three: null }; defineProperty(obj, 'all', collect('one', 'two', 'three', 'four')); deepEqual(get(obj, 'all'), ['foo', 'bar', null, null], 'have all of them'); @@ -1705,7 +1705,7 @@ testBoth('works', function(get, set) { deepEqual(get(obj, 'all'), ['foo', 'bar', null, true], 'have all of them'); - var a = []; + let a = []; set(obj, 'one', 0); set(obj, 'three', a); diff --git a/packages/ember-runtime/tests/controllers/controller_test.js b/packages/ember-runtime/tests/controllers/controller_test.js index 41cf17dc4a9..24a6699b755 100644 --- a/packages/ember-runtime/tests/controllers/controller_test.js +++ b/packages/ember-runtime/tests/controllers/controller_test.js @@ -13,7 +13,7 @@ QUnit.module('Controller event handling'); QUnit.test('can access `actions` hash via `_actions` [DEPRECATED]', function() { expect(2); - var controller = Controller.extend({ + let controller = Controller.extend({ actions: { foo: function() { ok(true, 'called foo action'); @@ -28,20 +28,20 @@ QUnit.test('can access `actions` hash via `_actions` [DEPRECATED]', function() { QUnit.test('Action can be handled by a function on actions object', function() { expect(1); - var TestController = Controller.extend({ + let TestController = Controller.extend({ actions: { poke() { ok(true, 'poked'); } } }); - var controller = TestController.create(); + let controller = TestController.create(); controller.send('poke'); }); QUnit.test('A handled action can be bubbled to the target for continued processing', function() { expect(2); - var TestController = Controller.extend({ + let TestController = Controller.extend({ actions: { poke() { ok(true, 'poked 1'); @@ -50,7 +50,7 @@ QUnit.test('A handled action can be bubbled to the target for continued processi } }); - var controller = TestController.create({ + let controller = TestController.create({ target: Controller.extend({ actions: { poke() { @@ -65,7 +65,7 @@ QUnit.test('A handled action can be bubbled to the target for continued processi QUnit.test('Action can be handled by a superclass\' actions object', function() { expect(4); - var SuperController = Controller.extend({ + let SuperController = Controller.extend({ actions: { foo() { ok(true, 'foo'); @@ -76,7 +76,7 @@ QUnit.test('Action can be handled by a superclass\' actions object', function() } }); - var BarControllerMixin = Mixin.create({ + let BarControllerMixin = Mixin.create({ actions: { bar(msg) { equal(msg, 'HELLO'); @@ -85,7 +85,7 @@ QUnit.test('Action can be handled by a superclass\' actions object', function() } }); - var IndexController = SuperController.extend(BarControllerMixin, { + let IndexController = SuperController.extend(BarControllerMixin, { actions: { baz() { ok(true, 'baz'); @@ -93,7 +93,7 @@ QUnit.test('Action can be handled by a superclass\' actions object', function() } }); - var controller = IndexController.create({}); + let controller = IndexController.create({}); controller.send('foo'); controller.send('bar', 'HELLO'); controller.send('baz'); @@ -105,7 +105,7 @@ QUnit.module('Controller Content -> Model Alias'); QUnit.test('`model` is aliased as `content`', function() { expect(1); - var controller = Controller.extend({ + let controller = Controller.extend({ model: 'foo-bar' }).create(); @@ -114,7 +114,7 @@ QUnit.test('`model` is aliased as `content`', function() { QUnit.test('`content` is moved to `model` when `model` is unset', function() { expect(2); - var controller; + let controller; ignoreDeprecation(function() { controller = Controller.extend({ @@ -128,7 +128,7 @@ QUnit.test('`content` is moved to `model` when `model` is unset', function() { QUnit.test('specifying `content` (without `model` specified) results in deprecation', function() { expect(1); - var controller; + let controller; expectDeprecation(function() { controller = Controller.extend({ @@ -141,7 +141,7 @@ QUnit.test('specifying `content` (with `model` specified) does not result in dep expect(3); expectNoDeprecation(); - var controller = Controller.extend({ + let controller = Controller.extend({ content: 'foo-bar', model: 'blammo' }).create(); @@ -157,7 +157,7 @@ if (!EmberDev.runningProdBuild) { expectAssertion(function() { let owner = buildOwner(); - var AnObject = Object.extend({ + let AnObject = Object.extend({ foo: inject.controller('bar') }); @@ -177,8 +177,8 @@ QUnit.test('controllers can be injected into controllers', function() { owner.register('controller:posts', Controller.extend()); - var postController = owner.lookup('controller:post'); - var postsController = owner.lookup('controller:posts'); + let postController = owner.lookup('controller:post'); + let postsController = owner.lookup('controller:posts'); equal(postsController, postController.get('postsController'), 'controller.posts is injected'); }); @@ -192,8 +192,8 @@ QUnit.test('services can be injected into controllers', function() { owner.register('service:auth', Service.extend()); - var appController = owner.lookup('controller:application'); - var authService = owner.lookup('service:auth'); + let appController = owner.lookup('controller:application'); + let authService = owner.lookup('service:auth'); equal(authService, appController.get('authService'), 'service.auth is injected'); }); diff --git a/packages/ember-runtime/tests/core/compare_test.js b/packages/ember-runtime/tests/core/compare_test.js index 0f8a6bc4200..a1694066d0e 100644 --- a/packages/ember-runtime/tests/core/compare_test.js +++ b/packages/ember-runtime/tests/core/compare_test.js @@ -3,8 +3,8 @@ import EmberObject from 'ember-runtime/system/object'; import compare from 'ember-runtime/compare'; import Comparable from 'ember-runtime/mixins/comparable'; -var data = []; -var Comp = EmberObject.extend(Comparable); +let data = []; +let Comp = EmberObject.extend(Comparable); Comp.reopenClass({ compare(obj) { @@ -34,7 +34,7 @@ QUnit.module('Ember.compare()', { }); QUnit.test('ordering should work', function() { - var suspect, comparable, failureMessage, + let suspect, comparable, failureMessage, suspectIndex, comparableIndex; for (suspectIndex = 0; suspectIndex < data.length; suspectIndex++) { @@ -55,15 +55,15 @@ QUnit.test('ordering should work', function() { }); QUnit.test('comparables should return values in the range of -1, 0, 1', function() { - var negOne = Comp.create({ + let negOne = Comp.create({ val: -1 }); - var zero = Comp.create({ + let zero = Comp.create({ val: 0 }); - var one = Comp.create({ + let one = Comp.create({ val: 1 }); diff --git a/packages/ember-runtime/tests/core/copy_test.js b/packages/ember-runtime/tests/core/copy_test.js index 8165511ceb8..849e5ce5645 100644 --- a/packages/ember-runtime/tests/core/copy_test.js +++ b/packages/ember-runtime/tests/core/copy_test.js @@ -3,20 +3,20 @@ import copy from 'ember-runtime/copy'; QUnit.module('Ember Copy Method'); QUnit.test('Ember.copy null', function() { - var obj = { field: null }; + let obj = { field: null }; equal(copy(obj, true).field, null, 'null should still be null'); }); QUnit.test('Ember.copy date', function() { - var date = new Date(2014, 7, 22); - var dateCopy = copy(date); + let date = new Date(2014, 7, 22); + let dateCopy = copy(date); equal(date.getTime(), dateCopy.getTime(), 'dates should be equivalent'); }); QUnit.test('Ember.copy null prototype object', function() { - var obj = Object.create(null); + let obj = Object.create(null); obj.foo = 'bar'; @@ -24,8 +24,8 @@ QUnit.test('Ember.copy null prototype object', function() { }); QUnit.test('Ember.copy Array', function() { - var array = [1, null, new Date(2015, 9, 9), 'four']; - var arrayCopy = copy(array); + let array = [1, null, new Date(2015, 9, 9), 'four']; + let arrayCopy = copy(array); deepEqual(array, arrayCopy, 'array content cloned successfully in new array'); }); diff --git a/packages/ember-runtime/tests/core/isEqual_test.js b/packages/ember-runtime/tests/core/isEqual_test.js index bafd1e4235a..dfdf447c161 100644 --- a/packages/ember-runtime/tests/core/isEqual_test.js +++ b/packages/ember-runtime/tests/core/isEqual_test.js @@ -33,6 +33,6 @@ QUnit.test('array should be equal', function() { QUnit.test('first object implements isEqual should use it', function() { ok(isEqual({ isEqual() { return true; } }, null), 'should return true always'); - var obj = { isEqual() { return false; } }; + let obj = { isEqual() { return false; } }; equal(isEqual(obj, obj), false, 'should return false because isEqual returns false'); }); diff --git a/packages/ember-runtime/tests/core/is_array_test.js b/packages/ember-runtime/tests/core/is_array_test.js index cd703735cdd..66fd5d2ea01 100644 --- a/packages/ember-runtime/tests/core/is_array_test.js +++ b/packages/ember-runtime/tests/core/is_array_test.js @@ -4,17 +4,17 @@ import ArrayProxy from 'ember-runtime/system/array_proxy'; QUnit.module('Ember Type Checking'); -var global = this; +const global = this; QUnit.test('Ember.isArray', function() { - var numarray = [1, 2, 3]; - var number = 23; - var strarray = ['Hello', 'Hi']; - var string = 'Hello'; - var object = {}; - var length = { length: 12 }; - var fn = function() {}; - var arrayProxy = ArrayProxy.create({ content: emberA() }); + let numarray = [1, 2, 3]; + let number = 23; + let strarray = ['Hello', 'Hi']; + let string = 'Hello'; + let object = {}; + let length = { length: 12 }; + let fn = function() {}; + let arrayProxy = ArrayProxy.create({ content: emberA() }); equal(isArray(numarray), true, '[1,2,3]'); equal(isArray(number), false, '23'); diff --git a/packages/ember-runtime/tests/core/is_empty_test.js b/packages/ember-runtime/tests/core/is_empty_test.js index e7e906101bf..32c28cef697 100644 --- a/packages/ember-runtime/tests/core/is_empty_test.js +++ b/packages/ember-runtime/tests/core/is_empty_test.js @@ -5,7 +5,7 @@ import { A as emberA } from 'ember-runtime/system/native_array'; QUnit.module('Ember.isEmpty'); QUnit.test('Ember.isEmpty', function() { - var arrayProxy = ArrayProxy.create({ content: emberA() }); + let arrayProxy = ArrayProxy.create({ content: emberA() }); equal(true, isEmpty(arrayProxy), 'for an ArrayProxy that has empty content'); }); diff --git a/packages/ember-runtime/tests/core/type_of_test.js b/packages/ember-runtime/tests/core/type_of_test.js index 89e3782fb54..79da4df0aa4 100644 --- a/packages/ember-runtime/tests/core/type_of_test.js +++ b/packages/ember-runtime/tests/core/type_of_test.js @@ -4,17 +4,17 @@ import EmberObject from 'ember-runtime/system/object'; QUnit.module('Ember Type Checking'); QUnit.test('Ember.typeOf', function() { - var MockedDate = function() { }; + let MockedDate = function() { }; MockedDate.prototype = new Date(); - var mockedDate = new MockedDate(); - var date = new Date(); - var error = new Error('boum'); - var object = { a: 'b' }; - var a = null; - var arr = [1, 2, 3]; - var obj = {}; - var instance = EmberObject.create({ method() {} }); + let mockedDate = new MockedDate(); + let date = new Date(); + let error = new Error('boum'); + let object = { a: 'b' }; + let a = null; + let arr = [1, 2, 3]; + let obj = {}; + let instance = EmberObject.create({ method() {} }); equal(typeOf(), 'undefined', 'undefined'); equal(typeOf(null), 'null', 'null'); diff --git a/packages/ember-runtime/tests/ext/function_test.js b/packages/ember-runtime/tests/ext/function_test.js index 6a0b6782113..1b09fd6e054 100644 --- a/packages/ember-runtime/tests/ext/function_test.js +++ b/packages/ember-runtime/tests/ext/function_test.js @@ -12,7 +12,7 @@ testBoth('global observer helper takes multiple params', function(get, set) { return; } - var MyMixin = Mixin.create({ + let MyMixin = Mixin.create({ count: 0, @@ -22,7 +22,7 @@ testBoth('global observer helper takes multiple params', function(get, set) { }); - var obj = mixin({}, MyMixin); + let obj = mixin({}, MyMixin); equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); set(obj, 'bar', 'BAZ'); @@ -38,7 +38,7 @@ testBoth('sets up an event listener, and can trigger the function on multiple ev return; } - var MyMixin = Mixin.create({ + let MyMixin = Mixin.create({ count: 0, @@ -48,7 +48,7 @@ testBoth('sets up an event listener, and can trigger the function on multiple ev }); - var obj = mixin({}, Evented, MyMixin); + let obj = mixin({}, Evented, MyMixin); equal(get(obj, 'count'), 0, 'should not invoke listener immediately'); obj.trigger('bar'); @@ -62,7 +62,7 @@ testBoth('can be chained with observes', function(get, set) { return; } - var MyMixin = Mixin.create({ + let MyMixin = Mixin.create({ count: 0, bay: 'bay', @@ -71,7 +71,7 @@ testBoth('can be chained with observes', function(get, set) { }.observes('bay').on('bar') }); - var obj = mixin({}, Evented, MyMixin); + let obj = mixin({}, Evented, MyMixin); equal(get(obj, 'count'), 0, 'should not invoke listener immediately'); set(obj, 'bay', 'BAY'); @@ -87,7 +87,7 @@ testBoth('sets up a ComputedProperty', function(get, set) { return; } - var MyClass = EmberObject.extend({ + let MyClass = EmberObject.extend({ firstName: null, lastName: null, fullName: function() { @@ -95,7 +95,7 @@ testBoth('sets up a ComputedProperty', function(get, set) { }.property('firstName', 'lastName') }); - var obj = MyClass.create({ firstName: 'Fred', lastName: 'Flinstone' }); + let obj = MyClass.create({ firstName: 'Fred', lastName: 'Flinstone' }); equal(get(obj, 'fullName'), 'Fred Flinstone', 'should return the computed value'); set(obj, 'firstName', 'Wilma'); diff --git a/packages/ember-runtime/tests/ext/mixin_test.js b/packages/ember-runtime/tests/ext/mixin_test.js index a2d1775a1fc..86b076c76d2 100644 --- a/packages/ember-runtime/tests/ext/mixin_test.js +++ b/packages/ember-runtime/tests/ext/mixin_test.js @@ -7,13 +7,13 @@ import run from 'ember-metal/run_loop'; QUnit.module('system/mixin/binding_test'); QUnit.test('Defining a property ending in Binding should setup binding when applied', function() { - var MyMixin = Mixin.create({ + let MyMixin = Mixin.create({ fooBinding: 'bar.baz' }); - var obj = { bar: { baz: 'BIFF' } }; + let obj = { bar: { baz: 'BIFF' } }; - run(function() { + run(() => { let deprecationMessage = '`Ember.Binding` is deprecated. Consider' + ' using an `alias` computed property instead.'; @@ -27,15 +27,13 @@ QUnit.test('Defining a property ending in Binding should setup binding when appl }); QUnit.test('Defining a property ending in Binding should apply to prototype children', function() { - var MyMixin, obj, obj2; - - run(function() { - MyMixin = Mixin.create({ + let MyMixin = run(() => { + return Mixin.create({ fooBinding: 'bar.baz' }); }); - obj = { bar: { baz: 'BIFF' } }; + let obj = { bar: { baz: 'BIFF' } }; run(function() { let deprecationMessage = '`Ember.Binding` is deprecated. Consider' + @@ -47,11 +45,8 @@ QUnit.test('Defining a property ending in Binding should apply to prototype chil }); - obj2 = Object.create(obj); - run(function() { - set(get(obj2, 'bar'), 'baz', 'BARG'); - }); - + let obj2 = Object.create(obj); + run(() => set(get(obj2, 'bar'), 'baz', 'BARG')); ok(get(obj2, 'fooBinding') instanceof Binding, 'should be a binding object'); equal(get(obj2, 'foo'), 'BARG', 'binding should be created and synced'); diff --git a/packages/ember-runtime/tests/inject_test.js b/packages/ember-runtime/tests/inject_test.js index ea25190c37a..79750683376 100644 --- a/packages/ember-runtime/tests/inject_test.js +++ b/packages/ember-runtime/tests/inject_test.js @@ -11,7 +11,7 @@ import buildOwner from 'container/tests/test-helpers/build-owner'; QUnit.module('inject'); QUnit.test('calling `inject` directly should error', function() { - expectAssertion(function() { + expectAssertion(() => { inject('foo'); }, /Injected properties must be created through helpers/); }); @@ -28,7 +28,7 @@ if (!EmberDev.runningProdBuild) { let owner = buildOwner(); - var AnObject = Object.extend({ + let AnObject = Object.extend({ bar: inject.foo(), baz: inject.foo() }); @@ -39,20 +39,20 @@ if (!EmberDev.runningProdBuild) { QUnit.test('attempting to inject a nonexistent container key should error', function() { let owner = buildOwner(); - var AnObject = Object.extend({ + let AnObject = Object.extend({ foo: new InjectedProperty('bar', 'baz') }); owner.register('foo:main', AnObject); - throws(function() { + throws(() => { owner.lookup('foo:main'); }, /Attempting to inject an unknown injection: 'bar:baz'/); }); } QUnit.test('factories should return a list of lazy injection full names', function() { - var AnObject = Object.extend({ + let AnObject = Object.extend({ foo: new InjectedProperty('foo', 'bar'), bar: new InjectedProperty('quux') }); diff --git a/packages/ember-runtime/tests/legacy_1x/mixins/observable/chained_test.js b/packages/ember-runtime/tests/legacy_1x/mixins/observable/chained_test.js index 63948eb23f7..c25d8a67174 100644 --- a/packages/ember-runtime/tests/legacy_1x/mixins/observable/chained_test.js +++ b/packages/ember-runtime/tests/legacy_1x/mixins/observable/chained_test.js @@ -19,38 +19,38 @@ import { A as emberA } from 'ember-runtime/system/native_array'; QUnit.module('Ember.Observable - Observing with @each'); QUnit.test('chained observers on enumerable properties are triggered when the observed property of any item changes', function() { - var family = EmberObject.create({ momma: null }); - var momma = EmberObject.create({ children: [] }); + let family = EmberObject.create({ momma: null }); + let momma = EmberObject.create({ children: [] }); - var child1 = EmberObject.create({ name: 'Bartholomew' }); - var child2 = EmberObject.create({ name: 'Agnes' }); - var child3 = EmberObject.create({ name: 'Dan' }); - var child4 = EmberObject.create({ name: 'Nancy' }); + let child1 = EmberObject.create({ name: 'Bartholomew' }); + let child2 = EmberObject.create({ name: 'Agnes' }); + let child3 = EmberObject.create({ name: 'Dan' }); + let child4 = EmberObject.create({ name: 'Nancy' }); set(family, 'momma', momma); set(momma, 'children', emberA([child1, child2, child3])); - var observerFiredCount = 0; + let observerFiredCount = 0; addObserver(family, 'momma.children.@each.name', this, function() { observerFiredCount++; }); observerFiredCount = 0; - run(function() { get(momma, 'children').setEach('name', 'Juan'); }); + run(() => get(momma, 'children').setEach('name', 'Juan')); equal(observerFiredCount, 3, 'observer fired after changing child names'); observerFiredCount = 0; - run(function() { get(momma, 'children').pushObject(child4); }); + run(() => get(momma, 'children').pushObject(child4)); equal(observerFiredCount, 1, 'observer fired after adding a new item'); observerFiredCount = 0; - run(function() { set(child4, 'name', 'Herbert'); }); + run(() => set(child4, 'name', 'Herbert')); equal(observerFiredCount, 1, 'observer fired after changing property on new object'); set(momma, 'children', []); observerFiredCount = 0; - run(function() { set(child1, 'name', 'Hanna'); }); + run(() => set(child1, 'name', 'Hanna')); equal(observerFiredCount, 0, 'observer did not fire after removing changing property on a removed object'); }); diff --git a/packages/ember-runtime/tests/legacy_1x/mixins/observable/propertyChanges_test.js b/packages/ember-runtime/tests/legacy_1x/mixins/observable/propertyChanges_test.js index e8b874b2861..4618f55a736 100644 --- a/packages/ember-runtime/tests/legacy_1x/mixins/observable/propertyChanges_test.js +++ b/packages/ember-runtime/tests/legacy_1x/mixins/observable/propertyChanges_test.js @@ -22,10 +22,10 @@ import Observable from 'ember-runtime/mixins/observable'; import {computed} from 'ember-metal/computed'; import {observer} from 'ember-metal/mixin'; -var ObservableObject = EmberObject.extend(Observable); +const ObservableObject = EmberObject.extend(Observable); -var revMatches = false; -var ObjectA; +let revMatches = false; +let ObjectA; QUnit.module('object.propertyChanges', { setup() { @@ -117,7 +117,7 @@ QUnit.test('should notify that the property of an object has changed', function( }); QUnit.test('should invalidate function property cache when notifyPropertyChange is called', function() { - var a = ObservableObject.extend({ + let a = ObservableObject.extend({ b: computed({ get() { return this._b; }, set(key, value) { diff --git a/packages/ember-runtime/tests/legacy_1x/system/binding_test.js b/packages/ember-runtime/tests/legacy_1x/system/binding_test.js index 3bc64b5bb48..12a0425546c 100644 --- a/packages/ember-runtime/tests/legacy_1x/system/binding_test.js +++ b/packages/ember-runtime/tests/legacy_1x/system/binding_test.js @@ -45,7 +45,7 @@ import EmberObject from 'ember-runtime/system/object'; // ======================================================================== let TestNamespace, fromObject, toObject, binding, Bon1, bon2, root; // global variables -let originalLookup = context.lookup; +const originalLookup = context.lookup; let lookup; QUnit.module('basic object binding', { @@ -53,7 +53,7 @@ QUnit.module('basic object binding', { fromObject = EmberObject.create({ value: 'start' }); toObject = EmberObject.create({ value: 'end' }); root = { fromObject: fromObject, toObject: toObject }; - run(function () { + run(() => { let deprecationMessage = '`Ember.Binding` is deprecated. Consider' + ' using an `alias` computed property instead.'; @@ -69,7 +69,7 @@ QUnit.test('binding should have synced on connect', function() { }); QUnit.test('fromObject change should propagate to toObject only after flush', function() { - run(function () { + run(() => { set(fromObject, 'value', 'change'); equal(get(toObject, 'value'), 'start'); }); @@ -77,7 +77,7 @@ QUnit.test('fromObject change should propagate to toObject only after flush', fu }); QUnit.test('toObject change should propagate to fromObject only after flush', function() { - run(function () { + run(() => { set(toObject, 'value', 'change'); equal(get(fromObject, 'value'), 'start'); }); @@ -104,7 +104,7 @@ QUnit.test('deferred observing during bindings', function() { callCount: 0 }); - var root = { fromObject: fromObject, toObject: toObject }; + let root = { fromObject: fromObject, toObject: toObject }; run(function () { let deprecationMessage = '`Ember.Binding` is deprecated. Consider' + ' using an `alias` computed property instead.'; @@ -134,7 +134,7 @@ QUnit.test('binding disconnection actually works', function() { equal(get(toObject, 'value'), 'start'); }); -var first, second, third, binding1, binding2; // global variables +let first, second, third, binding1, binding2; // global variables // .......................................................... // chained binding @@ -224,11 +224,11 @@ QUnit.module('Custom Binding', { QUnit.test('two bindings to the same value should sync in the order they are initialized', function() { run.begin(); - var a = EmberObject.create({ + let a = EmberObject.create({ foo: 'bar' }); - var b = EmberObject.extend({ + let b = EmberObject.extend({ C: EmberObject.extend({ foo: 'bee', fooBinding: 'owner.foo' @@ -267,7 +267,7 @@ QUnit.module('propertyNameBinding with longhand', { context.lookup = lookup = {}; lookup['TestNamespace'] = TestNamespace = {}; - run(function () { + run(() => { TestNamespace.fromObject = EmberObject.create({ value: 'originalValue' }); @@ -292,29 +292,21 @@ QUnit.module('propertyNameBinding with longhand', { }); QUnit.test('works with full path', function() { - run(function () { - set(TestNamespace.fromObject, 'value', 'updatedValue'); - }); + run(() => set(TestNamespace.fromObject, 'value', 'updatedValue')); equal(get(TestNamespace.toObject, 'value'), 'updatedValue'); - run(function () { - set(TestNamespace.fromObject, 'value', 'newerValue'); - }); + run(() => set(TestNamespace.fromObject, 'value', 'newerValue')); equal(get(TestNamespace.toObject, 'value'), 'newerValue'); }); QUnit.test('works with local path', function() { - run(function () { - set(TestNamespace.toObject, 'localValue', 'updatedValue'); - }); + run(() => set(TestNamespace.toObject, 'localValue', 'updatedValue')); equal(get(TestNamespace.toObject, 'relative'), 'updatedValue'); - run(function () { - set(TestNamespace.toObject, 'localValue', 'newerValue'); - }); + run(() => set(TestNamespace.toObject, 'localValue', 'newerValue')); equal(get(TestNamespace.toObject, 'relative'), 'newerValue'); }); diff --git a/packages/ember-runtime/tests/legacy_1x/system/object/base_test.js b/packages/ember-runtime/tests/legacy_1x/system/object/base_test.js index fa829a1a737..023c2d623aa 100644 --- a/packages/ember-runtime/tests/legacy_1x/system/object/base_test.js +++ b/packages/ember-runtime/tests/legacy_1x/system/object/base_test.js @@ -24,7 +24,7 @@ import EmberObject from 'ember-runtime/system/object'; // EmberObject Base Tests // ======================================================================== -var obj, obj1, don; // global variables +let obj, obj1, don; // global variables QUnit.module('A new EmberObject instance', { diff --git a/packages/ember-runtime/tests/legacy_1x/system/object/bindings_test.js b/packages/ember-runtime/tests/legacy_1x/system/object/bindings_test.js index d6abe7c1e99..5fc3bd67712 100644 --- a/packages/ember-runtime/tests/legacy_1x/system/object/bindings_test.js +++ b/packages/ember-runtime/tests/legacy_1x/system/object/bindings_test.js @@ -25,8 +25,7 @@ let originalLookup = context.lookup; let testObject, fromObject, extraObject, TestObject; let TestNamespace, lookup; -var bindModuleOpts = { - +QUnit.module('bind() method', { setup() { context.lookup = lookup = {}; @@ -55,13 +54,10 @@ var bindModuleOpts = { testObject = fromObject = extraObject = null; context.lookup = originalLookup; } - -}; - -QUnit.module('bind() method', bindModuleOpts); +}); QUnit.test('bind(TestNamespace.fromObject.bar) should follow absolute path', function() { - run(function() { + run(() => { let deprecationMessage = '`Ember.Binding` is deprecated. Since you' + ' are binding to a global consider using a service instead.'; @@ -78,7 +74,7 @@ QUnit.test('bind(TestNamespace.fromObject.bar) should follow absolute path', fun }); QUnit.test('bind(.bar) should bind to relative path', function() { - run(function() { + run(() => { let deprecationMessage = '`Ember.Binding` is deprecated. Consider' + ' using an `alias` computed property instead.'; @@ -94,8 +90,7 @@ QUnit.test('bind(.bar) should bind to relative path', function() { equal('changedValue', get(testObject, 'foo'), 'testObject.foo'); }); -var fooBindingModuleOpts = { - +QUnit.module('fooBinding method', { setup() { context.lookup = lookup = {}; @@ -125,14 +120,10 @@ var fooBindingModuleOpts = { TestObject = fromObject = extraObject = null; // delete TestNamespace; } - -}; - -QUnit.module('fooBinding method', fooBindingModuleOpts); - +}); QUnit.test('fooBinding: TestNamespace.fromObject.bar should follow absolute path', function() { - run(function() { + run(() => { let deprecationMessage = '`Ember.Binding` is deprecated. Since you' + ' are binding to a global consider using a service instead.'; @@ -151,7 +142,7 @@ QUnit.test('fooBinding: TestNamespace.fromObject.bar should follow absolute path }); QUnit.test('fooBinding: .bar should bind to relative path', function() { - run(function() { + run(() => { let deprecationMessage = '`Ember.Binding` is deprecated. Consider' + ' using an `alias` computed property instead.'; @@ -170,7 +161,7 @@ QUnit.test('fooBinding: .bar should bind to relative path', function() { }); QUnit.test('fooBinding: should disconnect bindings when destroyed', function () { - run(function() { + run(() => { let deprecationMessage = '`Ember.Binding` is deprecated. Since you' + ' are binding to a global consider using a service instead.'; @@ -186,13 +177,9 @@ QUnit.test('fooBinding: should disconnect bindings when destroyed', function () equal(get(testObject, 'foo'), 'BAZ', 'binding should have synced'); - run(() => { - testObject.destroy(); - }); + run(() => testObject.destroy()); - run(function() { - set(TestNamespace.fromObject, 'bar', 'BIFF'); - }); + run(() => set(TestNamespace.fromObject, 'bar', 'BIFF')); ok(get(testObject, 'foo') !== 'bar', 'binding should not have synced'); }); diff --git a/packages/ember-runtime/tests/legacy_1x/system/object/concatenated_test.js b/packages/ember-runtime/tests/legacy_1x/system/object/concatenated_test.js index 1b34d91a726..a5d42c570ee 100644 --- a/packages/ember-runtime/tests/legacy_1x/system/object/concatenated_test.js +++ b/packages/ember-runtime/tests/legacy_1x/system/object/concatenated_test.js @@ -15,7 +15,7 @@ import EmberObject from 'ember-runtime/system/object'; function K() { return this; } -var klass; +let klass; QUnit.module('EmberObject Concatenated Properties', { setup() { @@ -28,24 +28,24 @@ QUnit.module('EmberObject Concatenated Properties', { }); QUnit.test('concatenates instances', function() { - var obj = klass.create({ + let obj = klass.create({ values: ['d', 'e', 'f'] }); - var values = get(obj, 'values'); - var expected = ['a', 'b', 'c', 'd', 'e', 'f']; + let values = get(obj, 'values'); + let expected = ['a', 'b', 'c', 'd', 'e', 'f']; deepEqual(values, expected, `should concatenate values property (expected: ${expected}, got: ${values})`); }); QUnit.test('concatenates subclasses', function() { - var subKlass = klass.extend({ + let subKlass = klass.extend({ values: ['d', 'e', 'f'] }); - var obj = subKlass.create(); + let obj = subKlass.create(); - var values = get(obj, 'values'); - var expected = ['a', 'b', 'c', 'd', 'e', 'f']; + let values = get(obj, 'values'); + let expected = ['a', 'b', 'c', 'd', 'e', 'f']; deepEqual(values, expected, `should concatenate values property (expected: ${expected}, got: ${values})`); }); @@ -54,51 +54,48 @@ QUnit.test('concatenates reopen', function() { klass.reopen({ values: ['d', 'e', 'f'] }); - var obj = klass.create(); + let obj = klass.create(); - var values = get(obj, 'values'); - var expected = ['a', 'b', 'c', 'd', 'e', 'f']; + let values = get(obj, 'values'); + let expected = ['a', 'b', 'c', 'd', 'e', 'f']; deepEqual(values, expected, `should concatenate values property (expected: ${expected}, got: ${values})`); }); QUnit.test('concatenates mixin', function() { - var mixin = { + let mixin = { values: ['d', 'e'] }; - var subKlass = klass.extend(mixin, { + let subKlass = klass.extend(mixin, { values: ['f'] }); - var obj = subKlass.create(); + let obj = subKlass.create(); - var values = get(obj, 'values'); - var expected = ['a', 'b', 'c', 'd', 'e', 'f']; + let values = get(obj, 'values'); + let expected = ['a', 'b', 'c', 'd', 'e', 'f']; deepEqual(values, expected, `should concatenate values property (expected: ${expected}, got: ${values})`); }); QUnit.test('concatenates reopen, subclass, and instance', function() { klass.reopen({ values: ['d'] }); - var subKlass = klass.extend({ values: ['e'] }); - var obj = subKlass.create({ values: ['f'] }); + let subKlass = klass.extend({ values: ['e'] }); + let obj = subKlass.create({ values: ['f'] }); - var values = get(obj, 'values'); - var expected = ['a', 'b', 'c', 'd', 'e', 'f']; + let values = get(obj, 'values'); + let expected = ['a', 'b', 'c', 'd', 'e', 'f']; deepEqual(values, expected, `should concatenate values property (expected: ${expected}, got: ${values})`); }); QUnit.test('concatenates subclasses when the values are functions', function() { - var subKlass = klass.extend({ + let subKlass = klass.extend({ functions: K }); - var obj = subKlass.create(); + let obj = subKlass.create(); - var values = get(obj, 'functions'); - var expected = [K, K]; + let values = get(obj, 'functions'); + let expected = [K, K]; deepEqual(values, expected, `should concatenate functions property (expected: ${expected}, got: ${values})`); }); - - - diff --git a/packages/ember-runtime/tests/legacy_1x/system/run_loop_test.js b/packages/ember-runtime/tests/legacy_1x/system/run_loop_test.js index 4c752b7dc80..2599a62efd7 100644 --- a/packages/ember-runtime/tests/legacy_1x/system/run_loop_test.js +++ b/packages/ember-runtime/tests/legacy_1x/system/run_loop_test.js @@ -18,7 +18,7 @@ import EmberObject from 'ember-runtime/system/object'; broken anyway. I don't think it ever even worked. */ -var MyApp, binding1, binding2; +let MyApp, binding1, binding2; QUnit.module('System:run_loop() - chained binding', { setup() { @@ -43,7 +43,7 @@ QUnit.module('System:run_loop() - chained binding', { }); QUnit.test('Should propagate bindings after the RunLoop completes (using Ember.RunLoop)', function() { - run(function () { + run(() => { let deprecationMessage = '`Ember.Binding` is deprecated. Consider' + ' using an `alias` computed property instead.'; @@ -60,7 +60,7 @@ QUnit.test('Should propagate bindings after the RunLoop completes (using Ember.R }, deprecationMessage); }); - run(function () { + run(() => { // Based on the above binding if you change the output of MyApp.first // object it should change the all the variable of // MyApp.first,MyApp.second and MyApp.third object @@ -81,7 +81,7 @@ QUnit.test('Should propagate bindings after the RunLoop completes (using Ember.R }); QUnit.test('Should propagate bindings after the RunLoop completes', function() { - run(function () { + run(() => { let deprecationMessage = '`Ember.Binding` is deprecated. Consider' + ' using an `alias` computed property instead.'; @@ -98,7 +98,7 @@ QUnit.test('Should propagate bindings after the RunLoop completes', function() { }, deprecationMessage); }); - run(function () { + run(() => { //Based on the above binding if you change the output of MyApp.first object it should //change the all the variable of MyApp.first,MyApp.second and MyApp.third object MyApp.first.set('output', 'change'); diff --git a/packages/ember-runtime/tests/mixins/array_test.js b/packages/ember-runtime/tests/mixins/array_test.js index fdd6d08175a..394501dd071 100644 --- a/packages/ember-runtime/tests/mixins/array_test.js +++ b/packages/ember-runtime/tests/mixins/array_test.js @@ -17,8 +17,7 @@ import { A as emberA } from 'ember-runtime/system/native_array'; Implement a basic fake mutable array. This validates that any non-native enumerable can impl this API. */ -var TestArray = EmberObject.extend(EmberArray, { - +const TestArray = EmberObject.extend(EmberArray, { _content: null, init(ary = []) { @@ -29,7 +28,7 @@ var TestArray = EmberObject.extend(EmberArray, { // arrays can be modified even if they don't implement MutableArray. The // MutableArray is just a standard API for mutation but not required. addObject(obj) { - var idx = this._content.length; + let idx = this._content.length; this.arrayContentWillChange(idx, 0, 1); this._content.push(obj); this.arrayContentDidChange(idx, 0, 1); @@ -72,15 +71,15 @@ ArrayTests.extend({ }).run(); QUnit.test('the return value of slice has Ember.Array applied', function() { - var x = EmberObject.extend(EmberArray).create({ + let x = EmberObject.extend(EmberArray).create({ length: 0 }); - var y = x.slice(1); + let y = x.slice(1); equal(EmberArray.detect(y), true, 'mixin should be applied'); }); QUnit.test('slice supports negative index arguments', function() { - var testArray = new TestArray([1, 2, 3, 4]); + let testArray = new TestArray([1, 2, 3, 4]); deepEqual(testArray.slice(-2), [3, 4], 'slice(-2)'); deepEqual(testArray.slice(-2, -1), [3], 'slice(-2, -1'); @@ -100,14 +99,13 @@ QUnit.test('slice supports negative index arguments', function() { // CONTENT DID CHANGE // -var DummyArray = EmberObject.extend(EmberArray, { +const DummyArray = EmberObject.extend(EmberArray, { nextObject() {}, length: 0, objectAt(idx) { return 'ITEM-' + idx; } }); -var obj, observer; - +let obj, observer; // .......................................................... // NOTIFY ARRAY OBSERVERS @@ -314,7 +312,7 @@ QUnit.test('removing enumerable observer should disable', function() { // @each // -var ary; +let ary; QUnit.module('EmberArray.@each support', { setup() { @@ -332,9 +330,9 @@ QUnit.module('EmberArray.@each support', { }); QUnit.test('adding an object should notify (@each.isDone)', function() { - var called = 0; + let called = 0; - var observerObject = EmberObject.create({ + let observerObject = EmberObject.create({ wasCalled() { called++; } @@ -351,9 +349,9 @@ QUnit.test('adding an object should notify (@each.isDone)', function() { }); QUnit.test('using @each to observe arrays that does not return objects raise error', function() { - var called = 0; + let called = 0; - var observerObject = EmberObject.create({ + let observerObject = EmberObject.create({ wasCalled() { called++; } @@ -367,7 +365,7 @@ QUnit.test('using @each to observe arrays that does not return objects raise err addObserver(ary, '@each.isDone', observerObject, 'wasCalled'); - expectAssertion(function() { + expectAssertion(() => { ary.addObject(EmberObject.create({ desc: 'foo', isDone: false @@ -383,13 +381,13 @@ QUnit.test('modifying the array should also indicate the isDone prop itself has // EachArray materialized but just want to know when the property has // changed. - var each = get(ary, '@each'); - var count = 0; + let each = get(ary, '@each'); + let count = 0; - addObserver(each, 'isDone', function() { count++; }); + addObserver(each, 'isDone', () => count++); count = 0; - var item = objectAt(ary, 2); + let item = objectAt(ary, 2); set(item, 'isDone', !get(item, 'isDone')); equal(count, 1, '@each.isDone should have notified'); }); @@ -401,7 +399,7 @@ QUnit.test('`objectAt` returns correct object', function() { }); testBoth('should be clear caches for computed properties that have dependent keys on arrays that are changed after object initialization', function(get, set) { - var obj = EmberObject.extend({ + let obj = EmberObject.extend({ init() { this._super(...arguments); set(this, 'resources', emberA()); @@ -420,18 +418,16 @@ testBoth('should be clear caches for computed properties that have dependent key }); testBoth('observers that contain @each in the path should fire only once the first time they are accessed', function(get, set) { - var count = 0; + let count = 0; - var obj = EmberObject.extend({ + let obj = EmberObject.extend({ init() { this._super(...arguments); // Observer does not fire on init set(this, 'resources', emberA()); }, - commonDidChange: emberObserver('resources.@each.common', function() { - count++; - }) + commonDidChange: emberObserver('resources.@each.common', () => count++) }).create(); // Observer fires second time when new object is added diff --git a/packages/ember-runtime/tests/mixins/comparable_test.js b/packages/ember-runtime/tests/mixins/comparable_test.js index 1b18c1b66b6..5cb2039236d 100644 --- a/packages/ember-runtime/tests/mixins/comparable_test.js +++ b/packages/ember-runtime/tests/mixins/comparable_test.js @@ -3,7 +3,7 @@ import EmberObject from 'ember-runtime/system/object'; import compare from 'ember-runtime/compare'; import Comparable from 'ember-runtime/mixins/comparable'; -var Rectangle = EmberObject.extend(Comparable, { +const Rectangle = EmberObject.extend(Comparable, { length: 0, width: 0, @@ -17,18 +17,13 @@ var Rectangle = EmberObject.extend(Comparable, { }); -var r1, r2; +let r1, r2; QUnit.module('Comparable', { - setup() { r1 = Rectangle.create({ length: 6, width: 12 }); r2 = Rectangle.create({ length: 6, width: 13 }); - }, - - teardown() { } - }); QUnit.test('should be comparable and return the correct result', function() { diff --git a/packages/ember-runtime/tests/mixins/copyable_test.js b/packages/ember-runtime/tests/mixins/copyable_test.js index 97c0f788606..be4b79b10bd 100644 --- a/packages/ember-runtime/tests/mixins/copyable_test.js +++ b/packages/ember-runtime/tests/mixins/copyable_test.js @@ -11,7 +11,7 @@ QUnit.module('Ember.Copyable.frozenCopy'); QUnit.test('should be deprecated', function() { expectDeprecation('`frozenCopy` is deprecated, use `Object.freeze` instead.'); - var Obj = EmberObject.extend(Freezable, Copyable, { + let Obj = EmberObject.extend(Freezable, Copyable, { copy() { return Obj.create(); } @@ -20,8 +20,7 @@ QUnit.test('should be deprecated', function() { Obj.create().frozenCopy(); }); -var CopyableObject = EmberObject.extend(Copyable, { - +const CopyableObject = EmberObject.extend(Copyable, { id: null, init() { @@ -30,7 +29,7 @@ var CopyableObject = EmberObject.extend(Copyable, { }, copy() { - var ret = new CopyableObject(); + let ret = new CopyableObject(); set(ret, 'id', get(this, 'id')); return ret; } diff --git a/packages/ember-runtime/tests/mixins/enumerable_test.js b/packages/ember-runtime/tests/mixins/enumerable_test.js index 37618f9a356..1bae861c124 100644 --- a/packages/ember-runtime/tests/mixins/enumerable_test.js +++ b/packages/ember-runtime/tests/mixins/enumerable_test.js @@ -10,13 +10,11 @@ import isEnabled from 'ember-metal/features'; function K() { return this; } - /* Implement a basic fake enumerable. This validates that any non-native enumerable can impl this API. */ -var TestEnumerable = EmberObject.extend(Enumerable, { - +const TestEnumerable = EmberObject.extend(Enumerable, { _content: null, init(ary = []) { @@ -48,7 +46,6 @@ var TestEnumerable = EmberObject.extend(Enumerable, { EnumerableTests.extend({ - name: 'Basic Enumerable', newObject(ary) { @@ -70,31 +67,31 @@ EnumerableTests.extend({ QUnit.module('Ember.Enumerable'); QUnit.test('should apply Ember.Array to return value of map', function() { - var x = EmberObject.extend(Enumerable).create(); - var y = x.map(K); + let x = EmberObject.extend(Enumerable).create(); + let y = x.map(K); equal(EmberArray.detect(y), true, 'should have mixin applied'); }); QUnit.test('should apply Ember.Array to return value of filter', function() { - var x = EmberObject.extend(Enumerable).create(); - var y = x.filter(K); + let x = EmberObject.extend(Enumerable).create(); + let y = x.filter(K); equal(EmberArray.detect(y), true, 'should have mixin applied'); }); QUnit.test('should apply Ember.Array to return value of invoke', function() { - var x = EmberObject.extend(Enumerable).create(); - var y = x.invoke(K); + let x = EmberObject.extend(Enumerable).create(); + let y = x.invoke(K); equal(EmberArray.detect(y), true, 'should have mixin applied'); }); QUnit.test('should apply Ember.Array to return value of toArray', function() { - var x = EmberObject.extend(Enumerable).create(); - var y = x.toArray(K); + let x = EmberObject.extend(Enumerable).create(); + let y = x.toArray(K); equal(EmberArray.detect(y), true, 'should have mixin applied'); }); QUnit.test('should apply Ember.Array to return value of without', function() { - var X = EmberObject.extend(Enumerable, { + let X = EmberObject.extend(Enumerable, { contains() { return true; } @@ -108,59 +105,57 @@ QUnit.test('should apply Ember.Array to return value of without', function() { }); } - var x = X.create(); - var y = x.without(K); + let x = X.create(); + let y = x.without(K); equal(EmberArray.detect(y), true, 'should have mixin applied'); }); QUnit.test('should apply Ember.Array to return value of uniq', function() { - var x = EmberObject.extend(Enumerable).create(); - var y = x.uniq(K); + let x = EmberObject.extend(Enumerable).create(); + let y = x.uniq(K); equal(EmberArray.detect(y), true, 'should have mixin applied'); }); QUnit.test('any', function() { - var kittens = emberA([{ + let kittens = emberA([{ color: 'white' }, { color: 'black' }, { color: 'white' }]); - var foundWhite = kittens.any(function(kitten) { return kitten.color === 'white'; }); - var foundWhite2 = kittens.isAny('color', 'white'); + let foundWhite = kittens.any(kitten => kitten.color === 'white'); + let foundWhite2 = kittens.isAny('color', 'white'); equal(foundWhite, true); equal(foundWhite2, true); }); QUnit.test('any with NaN', function() { - var numbers = emberA([1, 2, NaN, 4]); + let numbers = emberA([1, 2, NaN, 4]); - var hasNaN = numbers.any(function(n) { - return isNaN(n); - }); + let hasNaN = numbers.any(n => isNaN(n)); equal(hasNaN, true, 'works when matching NaN'); }); QUnit.test('every', function() { - var allColorsKittens = emberA([{ + let allColorsKittens = emberA([{ color: 'white' }, { color: 'black' }, { color: 'white' }]); - var allWhiteKittens = emberA([{ + let allWhiteKittens = emberA([{ color: 'white' }, { color: 'white' }, { color: 'white' }]); - var allWhite = false; - var whiteKittenPredicate = function(kitten) { return kitten.color === 'white'; }; + let allWhite = false; + let whiteKittenPredicate = function(kitten) { return kitten.color === 'white'; }; allWhite = allColorsKittens.every(whiteKittenPredicate); equal(allWhite, false); @@ -177,7 +172,7 @@ QUnit.test('every', function() { if (isEnabled('ember-runtime-enumerable-includes')) { QUnit.test('should throw an error passing a second argument to includes', function() { - var x = EmberObject.extend(Enumerable).create(); + let x = EmberObject.extend(Enumerable).create(); equal(x.includes('any'), false); expectAssertion(() => { @@ -190,12 +185,12 @@ if (isEnabled('ember-runtime-enumerable-includes')) { // CONTENT DID CHANGE // -var DummyEnum = EmberObject.extend(Enumerable, { +let DummyEnum = EmberObject.extend(Enumerable, { nextObject() {}, length: 0 }); -var obj, observer; +let obj, observer; // .......................................................... // NOTIFY ENUMERABLE PROPERTY @@ -204,7 +199,7 @@ var obj, observer; QUnit.module('mixins/enumerable/enumerableContentDidChange'); QUnit.test('should notify observers of []', function() { - var obj = EmberObject.extend(Enumerable, { + let obj = EmberObject.extend(Enumerable, { nextObject() {}, // avoid exceptions enumerablePropertyDidChange: emberObserver('[]', function() { @@ -252,8 +247,8 @@ QUnit.test('should notify observers when call with no params', function() { // API variation that included items only QUnit.test('should not notify when passed arrays of same length', function() { - var added = ['foo']; - var removed = ['bar']; + let added = ['foo']; + let removed = ['bar']; obj.enumerableContentWillChange(removed, added); equal(obj._after, 0); @@ -263,8 +258,8 @@ QUnit.test('should not notify when passed arrays of same length', function() { }); QUnit.test('should notify when passed arrays of different length', function() { - var added = ['foo']; - var removed = ['bar', 'baz']; + let added = ['foo']; + let removed = ['bar', 'baz']; obj.enumerableContentWillChange(removed, added); equal(obj._after, 0); @@ -290,7 +285,6 @@ QUnit.test('should notify when passed old index API with delta', function() { equal(obj._after, 1); }); - // .......................................................... // NOTIFY ENUMERABLE OBSERVER // @@ -332,8 +326,8 @@ QUnit.test('should notify enumerable observers when called with no params', func // API variation that included items only QUnit.test('should notify when called with same length items', function() { - var added = ['foo']; - var removed = ['bar']; + let added = ['foo']; + let removed = ['bar']; obj.enumerableContentWillChange(removed, added); deepEqual(observer._before, [obj, removed, added]); @@ -343,8 +337,8 @@ QUnit.test('should notify when called with same length items', function() { }); QUnit.test('should notify when called with diff length items', function() { - var added = ['foo', 'baz']; - var removed = ['bar']; + let added = ['foo', 'baz']; + let removed = ['bar']; obj.enumerableContentWillChange(removed, added); deepEqual(observer._before, [obj, removed, added]); diff --git a/packages/ember-runtime/tests/mixins/mutable_array_test.js b/packages/ember-runtime/tests/mixins/mutable_array_test.js index 973330b2172..2cf64ed1ef7 100644 --- a/packages/ember-runtime/tests/mixins/mutable_array_test.js +++ b/packages/ember-runtime/tests/mixins/mutable_array_test.js @@ -8,7 +8,7 @@ import { A as emberA } from 'ember-runtime/system/native_array'; Implement a basic fake mutable array. This validates that any non-native enumerable can impl this API. */ -var TestMutableArray = EmberObject.extend(MutableArray, { +const TestMutableArray = EmberObject.extend(MutableArray, { _content: null, @@ -17,9 +17,9 @@ var TestMutableArray = EmberObject.extend(MutableArray, { }, replace(idx, amt, objects) { - var args = objects ? objects.slice() : []; - var removeAmt = amt; - var addAmt = args.length; + let args = objects ? objects.slice() : []; + let removeAmt = amt; + let addAmt = args.length; this.arrayContentWillChange(idx, removeAmt, addAmt); diff --git a/packages/ember-runtime/tests/mixins/mutable_enumerable_test.js b/packages/ember-runtime/tests/mixins/mutable_enumerable_test.js index bd603bc9988..75e924d4ba4 100644 --- a/packages/ember-runtime/tests/mixins/mutable_enumerable_test.js +++ b/packages/ember-runtime/tests/mixins/mutable_enumerable_test.js @@ -8,8 +8,7 @@ import { get } from 'ember-metal/property_get'; Implement a basic fake mutable array. This validates that any non-native enumerable can impl this API. */ -var TestMutableEnumerable = EmberObject.extend(MutableEnumerable, { - +const TestMutableEnumerable = EmberObject.extend(MutableEnumerable, { _content: null, addObject(obj) { @@ -23,7 +22,7 @@ var TestMutableEnumerable = EmberObject.extend(MutableEnumerable, { }, removeObject(obj) { - var idx = this._content.indexOf(obj); + let idx = this._content.indexOf(obj); if (idx < 0) { return this; } @@ -53,7 +52,6 @@ var TestMutableEnumerable = EmberObject.extend(MutableEnumerable, { MutableEnumerableTests.extend({ - name: 'Basic Mutable Array', newObject(ary) { @@ -69,5 +67,4 @@ MutableEnumerableTests.extend({ toArray(obj) { return obj.slice(); } - }).run(); diff --git a/packages/ember-runtime/tests/mixins/observable_test.js b/packages/ember-runtime/tests/mixins/observable_test.js index 6e98780fdf1..dc3910b6440 100644 --- a/packages/ember-runtime/tests/mixins/observable_test.js +++ b/packages/ember-runtime/tests/mixins/observable_test.js @@ -6,31 +6,31 @@ import { testBoth } from 'ember-metal/tests/props_helper'; QUnit.module('mixins/observable'); QUnit.test('should be able to use getProperties to get a POJO of provided keys', function() { - var obj = EmberObject.create({ + let obj = EmberObject.create({ firstName: 'Steve', lastName: 'Jobs', companyName: 'Apple, Inc.' }); - var pojo = obj.getProperties('firstName', 'lastName'); + let pojo = obj.getProperties('firstName', 'lastName'); equal('Steve', pojo.firstName); equal('Jobs', pojo.lastName); }); QUnit.test('should be able to use getProperties with array parameter to get a POJO of provided keys', function() { - var obj = EmberObject.create({ + let obj = EmberObject.create({ firstName: 'Steve', lastName: 'Jobs', companyName: 'Apple, Inc.' }); - var pojo = obj.getProperties(['firstName', 'lastName']); + let pojo = obj.getProperties(['firstName', 'lastName']); equal('Steve', pojo.firstName); equal('Jobs', pojo.lastName); }); QUnit.test('should be able to use setProperties to set multiple properties at once', function() { - var obj = EmberObject.create({ + let obj = EmberObject.create({ firstName: 'Steve', lastName: 'Jobs', companyName: 'Apple, Inc.' @@ -42,8 +42,8 @@ QUnit.test('should be able to use setProperties to set multiple properties at on }); testBoth('calling setProperties completes safely despite exceptions', function(get, set) { - var exc = new Error('Something unexpected happened!'); - var obj = EmberObject.extend({ + let exc = new Error('Something unexpected happened!'); + let obj = EmberObject.extend({ companyName: computed({ get() { return 'Apple, Inc.'; }, set(key, value) { throw exc; } @@ -53,9 +53,9 @@ testBoth('calling setProperties completes safely despite exceptions', function(g lastName: 'Jobs' }); - var firstNameChangedCount = 0; + let firstNameChangedCount = 0; - addObserver(obj, 'firstName', function() { firstNameChangedCount++; }); + addObserver(obj, 'firstName', () => firstNameChangedCount++); try { obj.setProperties({ @@ -73,7 +73,7 @@ testBoth('calling setProperties completes safely despite exceptions', function(g }); testBoth('should be able to retrieve cached values of computed properties without invoking the computed property', function(get) { - var obj = EmberObject.extend({ + let obj = EmberObject.extend({ foo: computed(function() { return 'foo'; }) @@ -91,7 +91,7 @@ testBoth('should be able to retrieve cached values of computed properties withou }); QUnit.test('incrementProperty should work even if value is number in string', function() { - var obj = EmberObject.create({ + let obj = EmberObject.create({ age: '24' }); obj.incrementProperty('age'); diff --git a/packages/ember-runtime/tests/mixins/promise_proxy_test.js b/packages/ember-runtime/tests/mixins/promise_proxy_test.js index 13cf8edc4a6..050edf784b8 100644 --- a/packages/ember-runtime/tests/mixins/promise_proxy_test.js +++ b/packages/ember-runtime/tests/mixins/promise_proxy_test.js @@ -8,7 +8,7 @@ import { } from 'ember-runtime/ext/rsvp'; import * as RSVP from 'rsvp'; -var ObjectPromiseProxy; +let ObjectPromiseProxy; QUnit.test('present on ember namespace', function() { ok(PromiseProxyMixin, 'expected PromiseProxyMixin to exist'); @@ -21,7 +21,7 @@ QUnit.module('Ember.PromiseProxy - ObjectProxy', { }); QUnit.test('no promise, invoking then should raise', function() { - var proxy = ObjectPromiseProxy.create(); + let proxy = ObjectPromiseProxy.create(); throws(function() { proxy.then(function() { return this; }, function() { return this; }); @@ -29,25 +29,22 @@ QUnit.test('no promise, invoking then should raise', function() { }); QUnit.test('fulfillment', function() { - var value = { + let value = { firstName: 'stef', lastName: 'penner' }; - var deferred = RSVP.defer(); + let deferred = RSVP.defer(); - var proxy = ObjectPromiseProxy.create({ + let proxy = ObjectPromiseProxy.create({ promise: deferred.promise }); - var didFulfillCount = 0; - var didRejectCount = 0; + let didFulfillCount = 0; + let didRejectCount = 0; - proxy.then(function() { - didFulfillCount++; - }, function() { - didRejectCount++; - }); + proxy.then(() => didFulfillCount++, + () => didRejectCount++); equal(get(proxy, 'content'), undefined, 'expects the proxy to have no content'); equal(get(proxy, 'reason'), undefined, 'expects the proxy to have no reason'); @@ -92,20 +89,17 @@ QUnit.test('fulfillment', function() { }); QUnit.test('rejection', function() { - var reason = new Error('failure'); - var deferred = RSVP.defer(); - var proxy = ObjectPromiseProxy.create({ + let reason = new Error('failure'); + let deferred = RSVP.defer(); + let proxy = ObjectPromiseProxy.create({ promise: deferred.promise }); - var didFulfillCount = 0; - var didRejectCount = 0; + let didFulfillCount = 0; + let didRejectCount = 0; - proxy.then(function() { - didFulfillCount++; - }, function() { - didRejectCount++; - }); + proxy.then(() => didFulfillCount++, + () => didRejectCount++); equal(get(proxy, 'content'), undefined, 'expects the proxy to have no content'); equal(get(proxy, 'reason'), undefined, 'expects the proxy to have no reason'); @@ -153,10 +147,10 @@ QUnit.test('unhandled rejects still propagate to RSVP.on(\'error\', ...) ', func RSVP.on('error', onerror); RSVP.off('error', onerrorDefault); - var expectedReason = new Error('failure'); - var deferred = RSVP.defer(); + let expectedReason = new Error('failure'); + let deferred = RSVP.defer(); - var proxy = ObjectPromiseProxy.create({ + let proxy = ObjectPromiseProxy.create({ promise: deferred.promise }); @@ -189,17 +183,17 @@ QUnit.test('should work with promise inheritance', function() { PromiseSubclass.prototype.constructor = PromiseSubclass; PromiseSubclass.cast = RSVP.Promise.cast; - var proxy = ObjectPromiseProxy.create({ - promise: new PromiseSubclass(function() { }) + let proxy = ObjectPromiseProxy.create({ + promise: new PromiseSubclass(() => { }) }); ok(proxy.then() instanceof PromiseSubclass, 'promise proxy respected inheritance'); }); QUnit.test('should reset isFulfilled and isRejected when promise is reset', function() { - var deferred = EmberRSVP.defer(); + let deferred = EmberRSVP.defer(); - var proxy = ObjectPromiseProxy.create({ + let proxy = ObjectPromiseProxy.create({ promise: deferred.promise }); @@ -215,7 +209,7 @@ QUnit.test('should reset isFulfilled and isRejected when promise is reset', func equal(get(proxy, 'isRejected'), false, 'expects the proxy to indicate that it is not rejected'); equal(get(proxy, 'isFulfilled'), true, 'expects the proxy to indicate that it is fulfilled'); - var anotherDeferred = EmberRSVP.defer(); + let anotherDeferred = EmberRSVP.defer(); proxy.set('promise', anotherDeferred.promise); equal(get(proxy, 'isPending'), true, 'expects the proxy to indicate that it is loading'); @@ -232,30 +226,26 @@ QUnit.test('should reset isFulfilled and isRejected when promise is reset', func }); QUnit.test('should have content when isFulfilled is set', function() { - var deferred = EmberRSVP.defer(); + let deferred = EmberRSVP.defer(); - var proxy = ObjectPromiseProxy.create({ + let proxy = ObjectPromiseProxy.create({ promise: deferred.promise }); - proxy.addObserver('isFulfilled', function() { - equal(get(proxy, 'content'), true); - }); + proxy.addObserver('isFulfilled', () => equal(get(proxy, 'content'), true)); run(deferred, 'resolve', true); }); QUnit.test('should have reason when isRejected is set', function() { - var error = new Error('Y U REJECT?!?'); - var deferred = EmberRSVP.defer(); + let error = new Error('Y U REJECT?!?'); + let deferred = EmberRSVP.defer(); - var proxy = ObjectPromiseProxy.create({ + let proxy = ObjectPromiseProxy.create({ promise: deferred.promise }); - proxy.addObserver('isRejected', function() { - equal(get(proxy, 'reason'), error); - }); + proxy.addObserver('isRejected', () => equal(get(proxy, 'reason'), error)); try { run(deferred, 'reject', error); diff --git a/packages/ember-runtime/tests/mixins/target_action_support_test.js b/packages/ember-runtime/tests/mixins/target_action_support_test.js index 03e426c3b47..f4ca3d10f73 100644 --- a/packages/ember-runtime/tests/mixins/target_action_support_test.js +++ b/packages/ember-runtime/tests/mixins/target_action_support_test.js @@ -17,7 +17,7 @@ QUnit.module('TargetActionSupport', { QUnit.test('it should return false if no target or action are specified', function() { expect(1); - var obj = EmberObject.extend(TargetActionSupport).create(); + let obj = EmberObject.extend(TargetActionSupport).create(); ok(false === obj.triggerAction(), 'no target or action was specified'); }); @@ -25,7 +25,7 @@ QUnit.test('it should return false if no target or action are specified', functi QUnit.test('it should support actions specified as strings', function() { expect(2); - var obj = EmberObject.extend(TargetActionSupport).create({ + let obj = EmberObject.extend(TargetActionSupport).create({ target: EmberObject.create({ anEvent() { ok(true, 'anEvent method was called'); @@ -41,7 +41,7 @@ QUnit.test('it should support actions specified as strings', function() { QUnit.test('it should invoke the send() method on objects that implement it', function() { expect(3); - var obj = EmberObject.extend(TargetActionSupport).create({ + let obj = EmberObject.extend(TargetActionSupport).create({ target: EmberObject.create({ send(evt, context) { equal(evt, 'anEvent', 'send() method was invoked with correct event name'); @@ -58,7 +58,7 @@ QUnit.test('it should invoke the send() method on objects that implement it', fu QUnit.test('it should find targets specified using a property path', function() { expect(2); - var Test = {}; + let Test = {}; lookup.Test = Test; Test.targetObj = EmberObject.create({ @@ -67,7 +67,7 @@ QUnit.test('it should find targets specified using a property path', function() } }); - var myObj = EmberObject.extend(TargetActionSupport).create({ + let myObj = EmberObject.extend(TargetActionSupport).create({ target: 'Test.targetObj', action: 'anEvent' }); @@ -77,7 +77,7 @@ QUnit.test('it should find targets specified using a property path', function() QUnit.test('it should use an actionContext object specified as a property on the object', function() { expect(2); - var obj = EmberObject.extend(TargetActionSupport).create({ + let obj = EmberObject.extend(TargetActionSupport).create({ action: 'anEvent', actionContext: {}, target: EmberObject.create({ @@ -92,11 +92,11 @@ QUnit.test('it should use an actionContext object specified as a property on the QUnit.test('it should find an actionContext specified as a property path', function() { expect(2); - var Test = {}; + let Test = {}; lookup.Test = Test; Test.aContext = {}; - var obj = EmberObject.extend(TargetActionSupport).create({ + let obj = EmberObject.extend(TargetActionSupport).create({ action: 'anEvent', actionContext: 'Test.aContext', target: EmberObject.create({ @@ -111,12 +111,12 @@ QUnit.test('it should find an actionContext specified as a property path', funct QUnit.test('it should use the target specified in the argument', function() { expect(2); - var targetObj = EmberObject.create({ + let targetObj = EmberObject.create({ anEvent() { ok(true, 'anEvent method was called'); } }); - var obj = EmberObject.extend(TargetActionSupport).create({ + let obj = EmberObject.extend(TargetActionSupport).create({ action: 'anEvent' }); @@ -126,7 +126,7 @@ QUnit.test('it should use the target specified in the argument', function() { QUnit.test('it should use the action specified in the argument', function() { expect(2); - var obj = EmberObject.extend(TargetActionSupport).create({ + let obj = EmberObject.extend(TargetActionSupport).create({ target: EmberObject.create({ anEvent() { ok(true, 'anEvent method was called'); @@ -138,8 +138,8 @@ QUnit.test('it should use the action specified in the argument', function() { QUnit.test('it should use the actionContext specified in the argument', function() { expect(2); - var context = {}; - var obj = EmberObject.extend(TargetActionSupport).create({ + let context = {}; + let obj = EmberObject.extend(TargetActionSupport).create({ target: EmberObject.create({ anEvent(ctx) { ok(context === ctx, 'anEvent method was called with the expected context'); @@ -153,9 +153,9 @@ QUnit.test('it should use the actionContext specified in the argument', function QUnit.test('it should allow multiple arguments from actionContext', function() { expect(3); - var param1 = 'someParam'; - var param2 = 'someOtherParam'; - var obj = EmberObject.extend(TargetActionSupport).create({ + let param1 = 'someParam'; + let param2 = 'someOtherParam'; + let obj = EmberObject.extend(TargetActionSupport).create({ target: EmberObject.create({ anEvent(first, second) { ok(first === param1, 'anEvent method was called with the expected first argument'); @@ -170,7 +170,7 @@ QUnit.test('it should allow multiple arguments from actionContext', function() { QUnit.test('it should use a null value specified in the actionContext argument', function() { expect(2); - var obj = EmberObject.extend(TargetActionSupport).create({ + let obj = EmberObject.extend(TargetActionSupport).create({ target: EmberObject.create({ anEvent(ctx) { ok(null === ctx, 'anEvent method was called with the expected context (null)'); diff --git a/packages/ember-runtime/tests/suites/array.js b/packages/ember-runtime/tests/suites/array.js index 55478eaaaf6..b28458253fb 100644 --- a/packages/ember-runtime/tests/suites/array.js +++ b/packages/ember-runtime/tests/suites/array.js @@ -12,8 +12,7 @@ import { } from 'ember-runtime/mixins/array'; import isEnabled from 'ember-metal/features'; -var ObserverClass = EnumerableTestsObserverClass.extend({ - +const ObserverClass = EnumerableTestsObserverClass.extend({ observeArray(obj) { addArrayObserver(obj, this); return this; @@ -33,13 +32,10 @@ var ObserverClass = EnumerableTestsObserverClass.extend({ equal(this._after, null, 'should only call once'); this._after = Array.prototype.slice.call(arguments); } - }); -var ArrayTests = EnumerableTests.extend({ - +const ArrayTests = EnumerableTests.extend({ observerClass: ObserverClass - }); ArrayTests.ObserverClass = ObserverClass; diff --git a/packages/ember-runtime/tests/suites/array/includes.js b/packages/ember-runtime/tests/suites/array/includes.js index f47eb1c4fad..fa984962e00 100644 --- a/packages/ember-runtime/tests/suites/array/includes.js +++ b/packages/ember-runtime/tests/suites/array/includes.js @@ -1,36 +1,36 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('includes'); suite.test('includes returns correct value if startAt is positive', function() { - var data = this.newFixture(3); - var obj = this.newObject(data); + let data = this.newFixture(3); + let obj = this.newObject(data); equal(obj.includes(data[1], 1), true, 'should return true if included'); equal(obj.includes(data[0], 1), false, 'should return false if not included'); }); suite.test('includes returns correct value if startAt is negative', function() { - var data = this.newFixture(3); - var obj = this.newObject(data); + let data = this.newFixture(3); + let obj = this.newObject(data); equal(obj.includes(data[1], -2), true, 'should return true if included'); equal(obj.includes(data[0], -2), false, 'should return false if not included'); }); suite.test('includes returns true if startAt + length is still negative', function() { - var data = this.newFixture(1); - var obj = this.newObject(data); + let data = this.newFixture(1); + let obj = this.newObject(data); equal(obj.includes(data[0], -2), true, 'should return true if included'); equal(obj.includes(this.newFixture(1), -2), false, 'should return false if not included'); }); suite.test('includes returns false if startAt out of bounds', function() { - var data = this.newFixture(1); - var obj = this.newObject(data); + let data = this.newFixture(1); + let obj = this.newObject(data); equal(obj.includes(data[0], 2), false, 'should return false if startAt >= length'); equal(obj.includes(this.newFixture(1), 2), false, 'should return false if startAt >= length'); diff --git a/packages/ember-runtime/tests/suites/array/indexOf.js b/packages/ember-runtime/tests/suites/array/indexOf.js index 5a0be94a420..8540841cdd2 100644 --- a/packages/ember-runtime/tests/suites/array/indexOf.js +++ b/packages/ember-runtime/tests/suites/array/indexOf.js @@ -1,23 +1,22 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('indexOf'); suite.test('should return index of object', function() { - var expected = this.newFixture(3); - var obj = this.newObject(expected); - var len = 3; - var idx; + let expected = this.newFixture(3); + let obj = this.newObject(expected); + let len = 3; - for (idx = 0;idx < len;idx++) { + for (let idx = 0; idx < len; idx++) { equal(obj.indexOf(expected[idx]), idx, `obj.indexOf(${expected[idx]}) should match idx`); } }); suite.test('should return -1 when requesting object not in index', function() { - var obj = this.newObject(this.newFixture(3)); - var foo = {}; + let obj = this.newObject(this.newFixture(3)); + let foo = {}; equal(obj.indexOf(foo), -1, 'obj.indexOf(foo) should be < 0'); }); diff --git a/packages/ember-runtime/tests/suites/array/lastIndexOf.js b/packages/ember-runtime/tests/suites/array/lastIndexOf.js index 1f80434c2ad..74eb3a79ac7 100644 --- a/packages/ember-runtime/tests/suites/array/lastIndexOf.js +++ b/packages/ember-runtime/tests/suites/array/lastIndexOf.js @@ -1,59 +1,56 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('lastIndexOf'); suite.test('should return index of object\'s last occurrence', function() { - var expected = this.newFixture(3); - var obj = this.newObject(expected); - var len = 3; - var idx; + let expected = this.newFixture(3); + let obj = this.newObject(expected); + let len = 3; - for (idx = 0;idx < len;idx++) { + for (let idx = 0; idx < len; idx++) { equal(obj.lastIndexOf(expected[idx]), idx, `obj.lastIndexOf(${expected[idx]}) should match idx`); } }); suite.test('should return index of object\'s last occurrence even startAt search location is equal to length', function() { - var expected = this.newFixture(3); - var obj = this.newObject(expected); - var len = 3; - var idx; + let expected = this.newFixture(3); + let obj = this.newObject(expected); + let len = 3; - for (idx = 0;idx < len;idx++) { + for (let idx = 0; idx < len; idx++) { equal(obj.lastIndexOf(expected[idx], len), idx, `obj.lastIndexOfs(${expected[idx]}) should match idx`); } }); suite.test('should return index of object\'s last occurrence even startAt search location is greater than length', function() { - var expected = this.newFixture(3); - var obj = this.newObject(expected); - var len = 3; - var idx; + let expected = this.newFixture(3); + let obj = this.newObject(expected); + let len = 3; - for (idx = 0;idx < len;idx++) { + for (let idx = 0; idx < len; idx++) { equal(obj.lastIndexOf(expected[idx], len + 1), idx, `obj.lastIndexOf(${expected[idx]}) should match idx`); } }); suite.test('should return -1 when no match is found', function() { - var obj = this.newObject(this.newFixture(3)); - var foo = {}; + let obj = this.newObject(this.newFixture(3)); + let foo = {}; equal(obj.lastIndexOf(foo), -1, 'obj.lastIndexOf(foo) should be -1'); }); suite.test('should return -1 when no match is found even startAt search location is equal to length', function() { - var obj = this.newObject(this.newFixture(3)); - var foo = {}; + let obj = this.newObject(this.newFixture(3)); + let foo = {}; equal(obj.lastIndexOf(foo, obj.length), -1, 'obj.lastIndexOf(foo) should be -1'); }); suite.test('should return -1 when no match is found even startAt search location is greater than length', function() { - var obj = this.newObject(this.newFixture(3)); - var foo = {}; + let obj = this.newObject(this.newFixture(3)); + let foo = {}; equal(obj.lastIndexOf(foo, obj.length + 1), -1, 'obj.lastIndexOf(foo) should be -1'); }); diff --git a/packages/ember-runtime/tests/suites/array/objectAt.js b/packages/ember-runtime/tests/suites/array/objectAt.js index e9cea5bcbae..ede66472da6 100644 --- a/packages/ember-runtime/tests/suites/array/objectAt.js +++ b/packages/ember-runtime/tests/suites/array/objectAt.js @@ -1,23 +1,22 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; import { objectAt } from 'ember-runtime/mixins/array'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('objectAt'); suite.test('should return object at specified index', function() { - var expected = this.newFixture(3); - var obj = this.newObject(expected); - var len = expected.length; - var idx; + let expected = this.newFixture(3); + let obj = this.newObject(expected); + let len = expected.length; - for (idx = 0;idx < len;idx++) { + for (let idx = 0; idx < len; idx++) { equal(objectAt(obj, idx), expected[idx], `obj.objectAt(${idx}) should match`); } }); suite.test('should return undefined when requesting objects beyond index', function() { - var obj; + let obj; obj = this.newObject(this.newFixture(3)); equal(objectAt(obj, 5), undefined, 'should return undefined for obj.objectAt(5) when len = 3'); diff --git a/packages/ember-runtime/tests/suites/copyable.js b/packages/ember-runtime/tests/suites/copyable.js index 6bad177124f..f34c3850983 100644 --- a/packages/ember-runtime/tests/suites/copyable.js +++ b/packages/ember-runtime/tests/suites/copyable.js @@ -1,6 +1,6 @@ import { Suite } from 'ember-runtime/tests/suites/suite'; -var CopyableTests = Suite.extend({ +const CopyableTests = Suite.extend({ /* __Required.__ You must implement this method to apply this mixin. diff --git a/packages/ember-runtime/tests/suites/copyable/copy.js b/packages/ember-runtime/tests/suites/copyable/copy.js index b1b29c88e80..87f5b191495 100644 --- a/packages/ember-runtime/tests/suites/copyable/copy.js +++ b/packages/ember-runtime/tests/suites/copyable/copy.js @@ -1,12 +1,12 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('copy'); suite.test('should return an equivalent copy', function() { - var obj = this.newObject(); - var copy = obj.copy(); + let obj = this.newObject(); + let copy = obj.copy(); ok(this.isEqual(obj, copy), 'old object and new object should be equivalent'); }); diff --git a/packages/ember-runtime/tests/suites/copyable/frozenCopy.js b/packages/ember-runtime/tests/suites/copyable/frozenCopy.js index 5c911d89db0..16b81521677 100644 --- a/packages/ember-runtime/tests/suites/copyable/frozenCopy.js +++ b/packages/ember-runtime/tests/suites/copyable/frozenCopy.js @@ -2,12 +2,12 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; import {Freezable} from 'ember-runtime/mixins/freezable'; import {get} from 'ember-metal/property_get'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('frozenCopy'); suite.test('frozen objects should return same instance', function() { - var obj, copy; + let obj, copy; obj = this.newObject(); if (get(this, 'shouldBeFreezable')) { diff --git a/packages/ember-runtime/tests/suites/enumerable.js b/packages/ember-runtime/tests/suites/enumerable.js index c44b1fafc8b..09fa15ab4d1 100644 --- a/packages/ember-runtime/tests/suites/enumerable.js +++ b/packages/ember-runtime/tests/suites/enumerable.js @@ -6,8 +6,7 @@ import {get} from 'ember-metal/property_get'; import { _addBeforeObserver } from 'ember-metal/observer'; import isEnabled from 'ember-metal/features'; -var ObserverClass = EmberObject.extend({ - +const ObserverClass = EmberObject.extend({ _keysBefore: null, _keys: null, _values: null, @@ -21,7 +20,6 @@ var ObserverClass = EmberObject.extend({ this.reset(); }, - propertyWillChange(target, key) { if (this._keysBefore[key] === undefined) { this._keysBefore[key] = 0; } this._keysBefore[key]++; @@ -53,8 +51,8 @@ var ObserverClass = EmberObject.extend({ observeBefore(obj) { - var keys = Array.prototype.slice.call(arguments, 1); - var loc = keys.length; + let keys = Array.prototype.slice.call(arguments, 1); + let loc = keys.length; while (--loc>=0) { _addBeforeObserver(obj, keys[loc], this, 'propertyWillChange'); } @@ -73,8 +71,8 @@ var ObserverClass = EmberObject.extend({ */ observe(obj) { if (obj.addObserver) { - var keys = Array.prototype.slice.call(arguments, 1); - var loc = keys.length; + let keys = Array.prototype.slice.call(arguments, 1); + let loc = keys.length; while (--loc >= 0) { obj.addObserver(keys[loc], this, 'propertyDidChange'); @@ -155,11 +153,9 @@ var ObserverClass = EmberObject.extend({ equal(this._after, null, 'should only call once'); this._after = Array.prototype.slice.call(arguments); } - }); - -var EnumerableTests = Suite.extend({ +const EnumerableTests = Suite.extend({ /* __Required.__ You must implement this method to apply this mixin. @@ -184,7 +180,7 @@ var EnumerableTests = Suite.extend({ @returns {Array} array of strings */ newFixture(cnt) { - var ret = []; + let ret = []; while (--cnt >= 0) { ret.push(generateGuid()); } @@ -202,8 +198,8 @@ var EnumerableTests = Suite.extend({ @returns {Array} array of objects */ newObjectsFixture(cnt) { - var ret = []; - var item; + let ret = []; + let item; while (--cnt >= 0) { item = {}; guidFor(item); @@ -258,7 +254,6 @@ var EnumerableTests = Suite.extend({ */ run() {}, - /* Creates a new observer object for testing. You can add this object as an observer on an array and it will record results anytime it is invoked. @@ -266,7 +261,7 @@ var EnumerableTests = Suite.extend({ validate the results. */ newObserver(obj) { - var ret = get(this, 'observerClass').create(); + let ret = get(this, 'observerClass').create(); if (arguments.length > 0) { ret.observeBefore.apply(ret, arguments); } diff --git a/packages/ember-runtime/tests/suites/enumerable/any.js b/packages/ember-runtime/tests/suites/enumerable/any.js index f7d377e7c9b..d56a37af843 100644 --- a/packages/ember-runtime/tests/suites/enumerable/any.js +++ b/packages/ember-runtime/tests/suites/enumerable/any.js @@ -1,7 +1,7 @@ import { SuiteModuleBuilder } from 'ember-runtime/tests/suites/suite'; import { A as emberA } from 'ember-runtime/system/native_array'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); // .......................................................... // any() @@ -10,10 +10,10 @@ var suite = SuiteModuleBuilder.create(); suite.module('any'); suite.test('any should should invoke callback on each item as long as you return false', function() { - var obj = this.newObject(); - var ary = this.toArray(obj); - var found = []; - var result; + let obj = this.newObject(); + let ary = this.toArray(obj); + let found = []; + let result; result = obj.any(function(i) { found.push(i); @@ -24,12 +24,12 @@ suite.test('any should should invoke callback on each item as long as you return }); suite.test('any should stop invoking when you return true', function() { - var obj = this.newObject(); - var ary = this.toArray(obj); - var cnt = ary.length - 2; - var exp = cnt; - var found = []; - var result; + let obj = this.newObject(); + let ary = this.toArray(obj); + let cnt = ary.length - 2; + let exp = cnt; + let found = []; + let result; result = obj.any(function(i) { found.push(i); @@ -40,32 +40,28 @@ suite.test('any should stop invoking when you return true', function() { deepEqual(found, ary.slice(0, -2), 'items passed during any() should match'); }); - suite.test('any should return true if any object matches the callback', function() { - var obj = emberA([0, 1, 2]); - var result; + let obj = emberA([0, 1, 2]); + let result; - result = obj.any(function(i) { return !!i; }); + result = obj.any(i => !!i); equal(result, true, 'return value of obj.any'); }); - suite.test('any should return false if no object matches the callback', function() { - var obj = emberA([0, null, false]); - var result; + let obj = emberA([0, null, false]); + let result; - result = obj.any(function(i) { return !!i; }); + result = obj.any(i => !!i); equal(result, false, 'return value of obj.any'); }); - suite.test('any should produce correct results even if the matching element is undefined', function() { - var obj = emberA([undefined]); - var result; + let obj = emberA([undefined]); + let result; - result = obj.any(function(i) { return true; }); + result = obj.any(i => true); equal(result, true, 'return value of obj.any'); }); - export default suite; diff --git a/packages/ember-runtime/tests/suites/enumerable/compact.js b/packages/ember-runtime/tests/suites/enumerable/compact.js index 52344e0793b..5c49d496fe3 100644 --- a/packages/ember-runtime/tests/suites/enumerable/compact.js +++ b/packages/ember-runtime/tests/suites/enumerable/compact.js @@ -1,12 +1,12 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('compact'); suite.test('removes null and undefined values from enumerable', function() { - var obj = this.newObject([null, 1, false, '', undefined, 0, null]); - var ary = obj.compact(); + let obj = this.newObject([null, 1, false, '', undefined, 0, null]); + let ary = obj.compact(); deepEqual(ary, [1, false, '', 0]); }); diff --git a/packages/ember-runtime/tests/suites/enumerable/contains.js b/packages/ember-runtime/tests/suites/enumerable/contains.js index 295c4cfd1b0..e243db613fe 100644 --- a/packages/ember-runtime/tests/suites/enumerable/contains.js +++ b/packages/ember-runtime/tests/suites/enumerable/contains.js @@ -1,13 +1,13 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; import isEnabled from 'ember-metal/features'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('contains'); suite.test('contains returns true if item is in enumerable', function() { - var data = this.newFixture(3); - var obj = this.newObject(data); + let data = this.newFixture(3); + let obj = this.newObject(data); if (isEnabled('ember-runtime-enumerable-includes')) { expectDeprecation('`Enumerable#contains` is deprecated, use `Enumerable#includes` instead.'); @@ -16,8 +16,8 @@ suite.test('contains returns true if item is in enumerable', function() { }); suite.test('contains returns false if item is not in enumerable', function() { - var data = this.newFixture(1); - var obj = this.newObject(this.newFixture(3)); + let data = this.newFixture(1); + let obj = this.newObject(this.newFixture(3)); if (isEnabled('ember-runtime-enumerable-includes')) { expectDeprecation('`Enumerable#contains` is deprecated, use `Enumerable#includes` instead.'); diff --git a/packages/ember-runtime/tests/suites/enumerable/every.js b/packages/ember-runtime/tests/suites/enumerable/every.js index cf3e2e4396a..2c0494be789 100644 --- a/packages/ember-runtime/tests/suites/enumerable/every.js +++ b/packages/ember-runtime/tests/suites/enumerable/every.js @@ -1,7 +1,7 @@ import EmberObject from 'ember-runtime/system/object'; import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); // .......................................................... // every() @@ -10,10 +10,10 @@ var suite = SuiteModuleBuilder.create(); suite.module('every'); suite.test('every should should invoke callback on each item as long as you return true', function() { - var obj = this.newObject(); - var ary = this.toArray(obj); - var found = []; - var result; + let obj = this.newObject(); + let ary = this.toArray(obj); + let found = []; + let result; result = obj.every(function(i) { found.push(i); @@ -24,12 +24,12 @@ suite.test('every should should invoke callback on each item as long as you retu }); suite.test('every should stop invoking when you return false', function() { - var obj = this.newObject(); - var ary = this.toArray(obj); - var cnt = ary.length - 2; - var exp = cnt; - var found = []; - var result; + let obj = this.newObject(); + let ary = this.toArray(obj); + let cnt = ary.length - 2; + let exp = cnt; + let found = []; + let result; result = obj.every(function(i) { found.push(i); @@ -47,7 +47,7 @@ suite.test('every should stop invoking when you return false', function() { suite.module('isEvery'); suite.test('should return true of every property matches', function() { - var obj = this.newObject([ + let obj = this.newObject([ { foo: 'foo', bar: 'BAZ' }, EmberObject.create({ foo: 'foo', bar: 'bar' }) ]); @@ -57,7 +57,7 @@ suite.test('should return true of every property matches', function() { }); suite.test('should return true of every property is true', function() { - var obj = this.newObject([ + let obj = this.newObject([ { foo: 'foo', bar: true }, EmberObject.create({ foo: 'bar', bar: false }) ]); @@ -68,7 +68,7 @@ suite.test('should return true of every property is true', function() { }); suite.test('should return true if every property matches null', function() { - var obj = this.newObject([ + let obj = this.newObject([ { foo: null, bar: 'BAZ' }, EmberObject.create({ foo: null, bar: null }) ]); @@ -78,7 +78,7 @@ suite.test('should return true if every property matches null', function() { }); suite.test('should return true if every property is undefined', function() { - var obj = this.newObject([ + let obj = this.newObject([ { foo: undefined, bar: 'BAZ' }, EmberObject.create({ bar: undefined }) ]); diff --git a/packages/ember-runtime/tests/suites/enumerable/filter.js b/packages/ember-runtime/tests/suites/enumerable/filter.js index bf266b2eef2..0744580b342 100644 --- a/packages/ember-runtime/tests/suites/enumerable/filter.js +++ b/packages/ember-runtime/tests/suites/enumerable/filter.js @@ -1,7 +1,7 @@ import EmberObject from 'ember-runtime/system/object'; import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); // .......................................................... // filter() @@ -10,11 +10,11 @@ var suite = SuiteModuleBuilder.create(); suite.module('filter'); suite.test('filter should invoke on each item', function() { - var obj = this.newObject(); - var ary = this.toArray(obj); - var cnt = ary.length - 2; - var found = []; - var result; + let obj = this.newObject(); + let ary = this.toArray(obj); + let cnt = ary.length - 2; + let found = []; + let result; // return true on all but the last two result = obj.filter(function(i) { @@ -32,7 +32,7 @@ suite.test('filter should invoke on each item', function() { suite.module('filterBy'); suite.test('should filter based on object', function() { - var obj, ary; + let obj, ary; ary = [ { foo: 'foo', bar: 'BAZ' }, @@ -46,7 +46,7 @@ suite.test('should filter based on object', function() { }); suite.test('should include in result if property is true', function() { - var obj, ary; + let obj, ary; ary = [ { foo: 'foo', bar: true }, @@ -61,7 +61,7 @@ suite.test('should include in result if property is true', function() { }); suite.test('should filter on second argument if provided', function() { - var obj, ary; + let obj, ary; ary = [ { name: 'obj1', foo: 3 }, @@ -76,7 +76,7 @@ suite.test('should filter on second argument if provided', function() { }); suite.test('should correctly filter null second argument', function() { - var obj, ary; + let obj, ary; ary = [ { name: 'obj1', foo: 3 }, @@ -91,7 +91,7 @@ suite.test('should correctly filter null second argument', function() { }); suite.test('should not return all objects on undefined second argument', function() { - var obj, ary; + let obj, ary; ary = [ { name: 'obj1', foo: 3 }, @@ -104,7 +104,7 @@ suite.test('should not return all objects on undefined second argument', functio }); suite.test('should correctly filter explicit undefined second argument', function() { - var obj, ary; + let obj, ary; ary = [ { name: 'obj1', foo: 3 }, @@ -121,7 +121,7 @@ suite.test('should correctly filter explicit undefined second argument', functio }); suite.test('should not match undefined properties without second argument', function() { - var obj, ary; + let obj, ary; ary = [ { name: 'obj1', foo: 3 }, diff --git a/packages/ember-runtime/tests/suites/enumerable/find.js b/packages/ember-runtime/tests/suites/enumerable/find.js index 0033a4a2622..639cdbd2a5a 100644 --- a/packages/ember-runtime/tests/suites/enumerable/find.js +++ b/packages/ember-runtime/tests/suites/enumerable/find.js @@ -1,7 +1,7 @@ import EmberObject from 'ember-runtime/system/object'; import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); // .......................................................... // find() // @@ -9,10 +9,10 @@ var suite = SuiteModuleBuilder.create(); suite.module('find'); suite.test('find should invoke callback on each item as long as you return false', function() { - var obj = this.newObject(); - var ary = this.toArray(obj); - var found = []; - var result; + let obj = this.newObject(); + let ary = this.toArray(obj); + let found = []; + let result; result = obj.find(function(i) { found.push(i); @@ -23,12 +23,12 @@ suite.test('find should invoke callback on each item as long as you return false }); suite.test('every should stop invoking when you return true', function() { - var obj = this.newObject(); - var ary = this.toArray(obj); - var cnt = ary.length - 2; - var exp = cnt; - var found = []; - var result; + let obj = this.newObject(); + let ary = this.toArray(obj); + let cnt = ary.length - 2; + let exp = cnt; + let found = []; + let result; result = obj.find(function(i) { found.push(i); @@ -46,7 +46,7 @@ suite.test('every should stop invoking when you return true', function() { suite.module('findBy'); suite.test('should return first object of property matches', function() { - var ary, obj; + let ary, obj; ary = [ { foo: 'foo', bar: 'BAZ' }, @@ -60,7 +60,7 @@ suite.test('should return first object of property matches', function() { }); suite.test('should return first object with truthy prop', function() { - var ary, obj; + let ary, obj; ary = [ { foo: 'foo', bar: false }, @@ -75,7 +75,7 @@ suite.test('should return first object with truthy prop', function() { }); suite.test('should return first null property match', function() { - var ary, obj; + let ary, obj; ary = [ { foo: null, bar: 'BAZ' }, @@ -89,7 +89,7 @@ suite.test('should return first null property match', function() { }); suite.test('should return first undefined property match', function() { - var ary, obj; + let ary, obj; ary = [ { foo: undefined, bar: 'BAZ' }, diff --git a/packages/ember-runtime/tests/suites/enumerable/firstObject.js b/packages/ember-runtime/tests/suites/enumerable/firstObject.js index 822d4be1aed..b3034f83324 100644 --- a/packages/ember-runtime/tests/suites/enumerable/firstObject.js +++ b/packages/ember-runtime/tests/suites/enumerable/firstObject.js @@ -2,26 +2,26 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; import {get} from 'ember-metal/property_get'; import {set} from 'ember-metal/property_set'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('firstObject'); suite.test('returns first item in enumerable', function() { - var obj = this.newObject(); + let obj = this.newObject(); equal(get(obj, 'firstObject'), this.toArray(obj)[0]); }); suite.test('returns undefined if enumerable is empty', function() { - var obj = this.newObject([]); + let obj = this.newObject([]); equal(get(obj, 'firstObject'), undefined); }); suite.test('can not be set', function() { - var obj = this.newObject([]); + let obj = this.newObject([]); equal(get(obj, 'firstObject'), this.toArray(obj)[0]); - throws(function() { + throws(() => { set(obj, 'firstObject', 'foo!'); }, /Cannot set read-only property "firstObject" on object/); }); diff --git a/packages/ember-runtime/tests/suites/enumerable/forEach.js b/packages/ember-runtime/tests/suites/enumerable/forEach.js index 0f8b026313a..90666257577 100644 --- a/packages/ember-runtime/tests/suites/enumerable/forEach.js +++ b/packages/ember-runtime/tests/suites/enumerable/forEach.js @@ -2,16 +2,16 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; import {get} from 'ember-metal/property_get'; import {guidFor} from 'ember-metal/utils'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('forEach'); suite.test('forEach should iterate over list', function() { - var obj = this.newObject(); - var ary = this.toArray(obj); - var found = []; + let obj = this.newObject(); + let ary = this.toArray(obj); + let found = []; - obj.forEach(function(i) { found.push(i); }); + obj.forEach(i => found.push(i)); deepEqual(found, ary, 'items passed during forEach should match'); }); @@ -22,26 +22,26 @@ suite.test('forEach should iterate over list after mutation', function() { return; } - var obj = this.newObject(); - var ary = this.toArray(obj); - var found = []; + let obj = this.newObject(); + let ary = this.toArray(obj); + let found = []; - obj.forEach(function(i) { found.push(i); }); + obj.forEach(i => found.push(i)); deepEqual(found, ary, 'items passed during forEach should match'); this.mutate(obj); ary = this.toArray(obj); found = []; - obj.forEach(function(i) { found.push(i); }); + obj.forEach(i => found.push(i)); deepEqual(found, ary, 'items passed during forEach should match'); }); suite.test('2nd target parameter', function() { - var obj = this.newObject(); - var target = this; + let obj = this.newObject(); + let target = this; - obj.forEach(function() { + obj.forEach(() => { // ES6TODO: When transpiled we will end up with "use strict" which disables automatically binding to the global context. // Therefore, the following test can never pass in strict mode unless we modify the `map` function implementation to // use `Ember.lookup` if target is not specified. @@ -49,19 +49,18 @@ suite.test('2nd target parameter', function() { // equal(guidFor(this), guidFor(global), 'should pass the global object as this if no context'); }); - obj.forEach(function() { + obj.forEach(() => { equal(guidFor(this), guidFor(target), 'should pass target as this if context'); }, target); }); suite.test('callback params', function() { - var obj = this.newObject(); - var ary = this.toArray(obj); - var loc = 0; + let obj = this.newObject(); + let ary = this.toArray(obj); + let loc = 0; - - obj.forEach(function(item, idx, enumerable) { + obj.forEach((item, idx, enumerable) => { equal(item, ary[loc], 'item param'); equal(idx, loc, 'idx param'); equal(guidFor(enumerable), guidFor(obj), 'enumerable param'); diff --git a/packages/ember-runtime/tests/suites/enumerable/includes.js b/packages/ember-runtime/tests/suites/enumerable/includes.js index ef0e4ac0dc7..a2551ff651f 100644 --- a/packages/ember-runtime/tests/suites/enumerable/includes.js +++ b/packages/ember-runtime/tests/suites/enumerable/includes.js @@ -1,12 +1,12 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('includes'); suite.test('includes returns true if item is in enumerable', function() { - var data = this.newFixture(1); - var obj = this.newObject([...data, NaN, undefined, null]); + let data = this.newFixture(1); + let obj = this.newObject([...data, NaN, undefined, null]); equal(obj.includes(data[0]), true, 'should return true if included'); equal(obj.includes(NaN), true, 'should return true if NaN included'); @@ -15,8 +15,8 @@ suite.test('includes returns true if item is in enumerable', function() { }); suite.test('includes returns false if item is not in enumerable', function() { - var data = this.newFixture(1); - var obj = this.newObject([...this.newFixture(3), null]); + let data = this.newFixture(1); + let obj = this.newObject([...this.newFixture(3), null]); equal(obj.includes(data[0]), false, 'should return false if not included'); equal(obj.includes(undefined), false, 'should return false if undefined not included but null is included'); diff --git a/packages/ember-runtime/tests/suites/enumerable/invoke.js b/packages/ember-runtime/tests/suites/enumerable/invoke.js index d7d71237e4b..56728d890fc 100644 --- a/packages/ember-runtime/tests/suites/enumerable/invoke.js +++ b/packages/ember-runtime/tests/suites/enumerable/invoke.js @@ -1,12 +1,12 @@ import EmberObject from 'ember-runtime/system/object'; import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('invoke'); suite.test('invoke should call on each object that implements', function() { - var cnt, ary, obj; + let cnt, ary, obj; function F(amt) { cnt += amt === undefined ? 1 : amt; diff --git a/packages/ember-runtime/tests/suites/enumerable/is_any.js b/packages/ember-runtime/tests/suites/enumerable/is_any.js index d7f80f32930..646085bb105 100644 --- a/packages/ember-runtime/tests/suites/enumerable/is_any.js +++ b/packages/ember-runtime/tests/suites/enumerable/is_any.js @@ -1,7 +1,7 @@ import EmberObject from 'ember-runtime/system/object'; import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); // .......................................................... // isAny() @@ -10,7 +10,7 @@ var suite = SuiteModuleBuilder.create(); suite.module('isAny'); suite.test('should return true of any property matches', function() { - var obj = this.newObject([ + let obj = this.newObject([ { foo: 'foo', bar: 'BAZ' }, EmberObject.create({ foo: 'foo', bar: 'bar' }) ]); @@ -21,7 +21,7 @@ suite.test('should return true of any property matches', function() { }); suite.test('should return true of any property is true', function() { - var obj = this.newObject([ + let obj = this.newObject([ { foo: 'foo', bar: true }, EmberObject.create({ foo: 'bar', bar: false }) ]); @@ -33,7 +33,7 @@ suite.test('should return true of any property is true', function() { }); suite.test('should return true if any property matches null', function() { - var obj = this.newObject([ + let obj = this.newObject([ { foo: null, bar: 'bar' }, EmberObject.create({ foo: 'foo', bar: null }) ]); @@ -43,7 +43,7 @@ suite.test('should return true if any property matches null', function() { }); suite.test('should return true if any property is undefined', function() { - var obj = this.newObject([ + let obj = this.newObject([ { foo: undefined, bar: 'bar' }, EmberObject.create({ foo: 'foo' }) ]); @@ -53,7 +53,7 @@ suite.test('should return true if any property is undefined', function() { }); suite.test('should not match undefined properties without second argument', function() { - var obj = this.newObject([ + let obj = this.newObject([ { foo: undefined }, EmberObject.create({ }) ]); diff --git a/packages/ember-runtime/tests/suites/enumerable/lastObject.js b/packages/ember-runtime/tests/suites/enumerable/lastObject.js index db1efa98620..b230a2bb85d 100644 --- a/packages/ember-runtime/tests/suites/enumerable/lastObject.js +++ b/packages/ember-runtime/tests/suites/enumerable/lastObject.js @@ -2,26 +2,26 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; import {get} from 'ember-metal/property_get'; import {set} from 'ember-metal/property_set'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('lastObject'); suite.test('returns last item in enumerable', function() { - var obj = this.newObject(); - var ary = this.toArray(obj); + let obj = this.newObject(); + let ary = this.toArray(obj); equal(get(obj, 'lastObject'), ary[ary.length - 1]); }); suite.test('returns undefined if enumerable is empty', function() { - var obj = this.newObject([]); + let obj = this.newObject([]); equal(get(obj, 'lastObject'), undefined); }); suite.test('can not be set', function() { - var obj = this.newObject(); - var ary = this.toArray(obj); + let obj = this.newObject(); + let ary = this.toArray(obj); equal(get(obj, 'lastObject'), ary[ary.length - 1]); diff --git a/packages/ember-runtime/tests/suites/enumerable/map.js b/packages/ember-runtime/tests/suites/enumerable/map.js index f35960c9610..a90e7dd8008 100644 --- a/packages/ember-runtime/tests/suites/enumerable/map.js +++ b/packages/ember-runtime/tests/suites/enumerable/map.js @@ -2,16 +2,16 @@ import { SuiteModuleBuilder } from 'ember-runtime/tests/suites/suite'; import { get } from 'ember-metal/property_get'; import { guidFor } from 'ember-metal/utils'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('map'); -function mapFunc(item) { return item ? item.toString() : null; } +const mapFunc = item => item ? item.toString() : null; suite.test('map should iterate over list', function() { - var obj = this.newObject(); - var ary = this.toArray(obj).map(mapFunc); - var found = []; + let obj = this.newObject(); + let ary = this.toArray(obj).map(mapFunc); + let found = []; found = obj.map(mapFunc); deepEqual(found, ary, 'mapped arrays should match'); @@ -24,9 +24,9 @@ suite.test('map should iterate over list after mutation', function() { return; } - var obj = this.newObject(); - var ary = this.toArray(obj).map(mapFunc); - var found; + let obj = this.newObject(); + let ary = this.toArray(obj).map(mapFunc); + let found; found = obj.map(mapFunc); deepEqual(found, ary, 'items passed during forEach should match'); @@ -38,11 +38,11 @@ suite.test('map should iterate over list after mutation', function() { }); suite.test('2nd target parameter', function() { - var obj = this.newObject(); - var target = this; + let obj = this.newObject(); + let target = this; - obj.map(function() { + obj.map(() => { // ES6TODO: When transpiled we will end up with "use strict" which disables automatically binding to the global context. // Therefore, the following test can never pass in strict mode unless we modify the `map` function implementation to // use `Ember.lookup` if target is not specified. @@ -50,19 +50,18 @@ suite.test('2nd target parameter', function() { // equal(guidFor(this), guidFor(global), 'should pass the global object as this if no context'); }); - obj.map(function() { + obj.map(() => { equal(guidFor(this), guidFor(target), 'should pass target as this if context'); }, target); }); suite.test('callback params', function() { - var obj = this.newObject(); - var ary = this.toArray(obj); - var loc = 0; + let obj = this.newObject(); + let ary = this.toArray(obj); + let loc = 0; - - obj.map(function(item, idx, enumerable) { + obj.map((item, idx, enumerable) => { equal(item, ary[loc], 'item param'); equal(idx, loc, 'idx param'); equal(guidFor(enumerable), guidFor(obj), 'enumerable param'); diff --git a/packages/ember-runtime/tests/suites/enumerable/mapBy.js b/packages/ember-runtime/tests/suites/enumerable/mapBy.js index 46e51052d91..ee54796ba78 100644 --- a/packages/ember-runtime/tests/suites/enumerable/mapBy.js +++ b/packages/ember-runtime/tests/suites/enumerable/mapBy.js @@ -1,16 +1,16 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('mapBy'); suite.test('get value of each property', function() { - var obj = this.newObject([{ a: 1 }, { a: 2 }]); + let obj = this.newObject([{ a: 1 }, { a: 2 }]); equal(obj.mapBy('a').join(''), '12'); }); suite.test('should work also through getEach alias', function() { - var obj = this.newObject([{ a: 1 }, { a: 2 }]); + let obj = this.newObject([{ a: 1 }, { a: 2 }]); equal(obj.getEach('a').join(''), '12'); }); diff --git a/packages/ember-runtime/tests/suites/enumerable/reduce.js b/packages/ember-runtime/tests/suites/enumerable/reduce.js index e9e91034939..e52170fc489 100644 --- a/packages/ember-runtime/tests/suites/enumerable/reduce.js +++ b/packages/ember-runtime/tests/suites/enumerable/reduce.js @@ -1,24 +1,24 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('reduce'); suite.test('collects a summary value from an enumeration', function() { - var obj = this.newObject([1, 2, 3]); - var res = obj.reduce(function(previousValue, item, index, enumerable) { return previousValue + item; }, 0); + let obj = this.newObject([1, 2, 3]); + let res = obj.reduce((previousValue, item, index, enumerable) => previousValue + item, 0); equal(res, 6); }); suite.test('passes index of item to callback', function() { - var obj = this.newObject([1, 2, 3]); - var res = obj.reduce(function(previousValue, item, index, enumerable) { return previousValue + index; }, 0); + let obj = this.newObject([1, 2, 3]); + let res = obj.reduce((previousValue, item, index, enumerable) => previousValue + index, 0); equal(res, 3); }); suite.test('passes enumerable object to callback', function() { - var obj = this.newObject([1, 2, 3]); - var res = obj.reduce(function(previousValue, item, index, enumerable) { return enumerable; }, 0); + let obj = this.newObject([1, 2, 3]); + let res = obj.reduce((previousValue, item, index, enumerable) => enumerable, 0); equal(res, obj); }); diff --git a/packages/ember-runtime/tests/suites/enumerable/reject.js b/packages/ember-runtime/tests/suites/enumerable/reject.js index ce876a5b337..4b6daa9292c 100644 --- a/packages/ember-runtime/tests/suites/enumerable/reject.js +++ b/packages/ember-runtime/tests/suites/enumerable/reject.js @@ -1,7 +1,7 @@ import EmberObject from 'ember-runtime/system/object'; import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); // .......................................................... // reject() @@ -10,17 +10,17 @@ var suite = SuiteModuleBuilder.create(); suite.module('reject'); suite.test('should reject any item that does not meet the condition', function() { - var obj = this.newObject([1, 2, 3, 4]); - var result; + let obj = this.newObject([1, 2, 3, 4]); + let result; - result = obj.reject(function(i) { return i < 3; }); + result = obj.reject(i => i < 3); deepEqual(result, [3, 4], 'reject the correct items'); }); suite.test('should be the inverse of filter', function() { - var obj = this.newObject([1, 2, 3, 4]); - var isEven = function(i) { return i % 2 === 0; }; - var filtered, rejected; + let obj = this.newObject([1, 2, 3, 4]); + let isEven = i => i % 2 === 0; + let filtered, rejected; filtered = obj.filter(isEven); rejected = obj.reject(isEven); @@ -36,7 +36,7 @@ suite.test('should be the inverse of filter', function() { suite.module('rejectBy'); suite.test('should reject based on object', function() { - var obj, ary; + let obj, ary; ary = [ { foo: 'foo', bar: 'BAZ' }, @@ -50,7 +50,7 @@ suite.test('should reject based on object', function() { }); suite.test('should include in result if property is false', function() { - var obj, ary; + let obj, ary; ary = [ { foo: false, bar: true }, @@ -64,7 +64,7 @@ suite.test('should include in result if property is false', function() { }); suite.test('should reject on second argument if provided', function() { - var obj, ary; + let obj, ary; ary = [ { name: 'obj1', foo: 3 }, @@ -79,7 +79,7 @@ suite.test('should reject on second argument if provided', function() { }); suite.test('should correctly reject null second argument', function() { - var obj, ary; + let obj, ary; ary = [ { name: 'obj1', foo: 3 }, @@ -94,7 +94,7 @@ suite.test('should correctly reject null second argument', function() { }); suite.test('should correctly reject undefined second argument', function() { - var obj, ary; + let obj, ary; ary = [ { name: 'obj1', foo: 3 }, @@ -107,7 +107,7 @@ suite.test('should correctly reject undefined second argument', function() { }); suite.test('should correctly reject explicit undefined second argument', function() { - var obj, ary; + let obj, ary; ary = [ { name: 'obj1', foo: 3 }, @@ -124,7 +124,7 @@ suite.test('should correctly reject explicit undefined second argument', functio }); suite.test('should match undefined, null, or false properties without second argument', function() { - var obj, ary; + let obj, ary; ary = [ { name: 'obj1', foo: 3 }, diff --git a/packages/ember-runtime/tests/suites/enumerable/sortBy.js b/packages/ember-runtime/tests/suites/enumerable/sortBy.js index 668871998ab..35af9657398 100644 --- a/packages/ember-runtime/tests/suites/enumerable/sortBy.js +++ b/packages/ember-runtime/tests/suites/enumerable/sortBy.js @@ -1,21 +1,21 @@ import { SuiteModuleBuilder } from 'ember-runtime/tests/suites/suite'; import { get } from 'ember-metal/property_get'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('sortBy'); suite.test('sort by value of property', function() { - var obj = this.newObject([{ a: 2 }, { a: 1 }]); - var sorted = obj.sortBy('a'); + let obj = this.newObject([{ a: 2 }, { a: 1 }]); + let sorted = obj.sortBy('a'); equal(get(sorted[0], 'a'), 1); equal(get(sorted[1], 'a'), 2); }); suite.test('supports multiple propertyNames', function() { - var obj = this.newObject([{ a: 1, b: 2 }, { a: 1, b: 1 }]); - var sorted = obj.sortBy('a', 'b'); + let obj = this.newObject([{ a: 1, b: 2 }, { a: 1, b: 1 }]); + let sorted = obj.sortBy('a', 'b'); equal(get(sorted[0], 'b'), 1); equal(get(sorted[1], 'b'), 2); diff --git a/packages/ember-runtime/tests/suites/enumerable/toArray.js b/packages/ember-runtime/tests/suites/enumerable/toArray.js index 59674a881aa..3389dd6935d 100644 --- a/packages/ember-runtime/tests/suites/enumerable/toArray.js +++ b/packages/ember-runtime/tests/suites/enumerable/toArray.js @@ -1,11 +1,11 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('toArray'); suite.test('toArray should convert to an array', function() { - var obj = this.newObject(); + let obj = this.newObject(); deepEqual(obj.toArray(), this.toArray(obj)); }); diff --git a/packages/ember-runtime/tests/suites/enumerable/uniq.js b/packages/ember-runtime/tests/suites/enumerable/uniq.js index 09affb6845c..3284a61fc0e 100644 --- a/packages/ember-runtime/tests/suites/enumerable/uniq.js +++ b/packages/ember-runtime/tests/suites/enumerable/uniq.js @@ -1,11 +1,11 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('uniq'); suite.test('should return new instance with duplicates removed', function() { - var before, after, obj, ret; + let before, after, obj, ret; after = this.newFixture(3); before = [after[0], after[1], after[2], after[1], after[0]]; @@ -18,7 +18,7 @@ suite.test('should return new instance with duplicates removed', function() { }); suite.test('should return duplicate of same content if no duplicates found', function() { - var item, obj, ret; + let item, obj, ret; obj = this.newObject(this.newFixture(3)); ret = obj.uniq(item); ok(ret !== obj, 'should not be same object'); diff --git a/packages/ember-runtime/tests/suites/enumerable/uniqBy.js b/packages/ember-runtime/tests/suites/enumerable/uniqBy.js index 730460e7419..c089f72b333 100644 --- a/packages/ember-runtime/tests/suites/enumerable/uniqBy.js +++ b/packages/ember-runtime/tests/suites/enumerable/uniqBy.js @@ -1,13 +1,13 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; import isEnabled from 'ember-metal/features'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('uniqBy'); if (isEnabled('ember-runtime-computed-uniq-by')) { suite.test('should return new instance with duplicates removed', function() { - var numbers = this.newObject([ + let numbers = this.newObject([ { id: 1, value: 'one' }, { id: 2, value: 'two' }, { id: 1, value: 'one' } diff --git a/packages/ember-runtime/tests/suites/enumerable/without.js b/packages/ember-runtime/tests/suites/enumerable/without.js index 2277c0f1efc..532645e2bb8 100644 --- a/packages/ember-runtime/tests/suites/enumerable/without.js +++ b/packages/ember-runtime/tests/suites/enumerable/without.js @@ -1,12 +1,12 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; import isEnabled from 'ember-metal/features'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('without'); suite.test('should return new instance with item removed', function() { - var before, after, obj, ret; + let before, after, obj, ret; before = this.newFixture(3); after = [before[0], before[2]]; @@ -19,7 +19,7 @@ suite.test('should return new instance with item removed', function() { if (isEnabled('ember-runtime-enumerable-includes')) { suite.test('should remove NaN value', function() { - var before, after, obj, ret; + let before, after, obj, ret; before = [...this.newFixture(2), NaN]; after = [before[0], before[1]]; @@ -31,7 +31,7 @@ if (isEnabled('ember-runtime-enumerable-includes')) { } suite.test('should return same instance if object not found', function() { - var item, obj, ret; + let item, obj, ret; item = this.newFixture(1)[0]; obj = this.newObject(this.newFixture(3)); diff --git a/packages/ember-runtime/tests/suites/mutable_array.js b/packages/ember-runtime/tests/suites/mutable_array.js index 01a20fd478b..2a8db8f70ee 100644 --- a/packages/ember-runtime/tests/suites/mutable_array.js +++ b/packages/ember-runtime/tests/suites/mutable_array.js @@ -10,7 +10,7 @@ import shiftObjectTests from 'ember-runtime/tests/suites/mutable_array/shiftObje import unshiftObjectTests from 'ember-runtime/tests/suites/mutable_array/unshiftObject'; import reverseObjectsTests from 'ember-runtime/tests/suites/mutable_array/reverseObjects'; -var MutableArrayTests = ArrayTests.extend(); +const MutableArrayTests = ArrayTests.extend(); MutableArrayTests.importModuleTests(insertAtTests); MutableArrayTests.importModuleTests(popObjectTests); MutableArrayTests.importModuleTests(pushObjectTests); diff --git a/packages/ember-runtime/tests/suites/mutable_array/addObject.js b/packages/ember-runtime/tests/suites/mutable_array/addObject.js index 39e488a1d27..d1f558fb774 100644 --- a/packages/ember-runtime/tests/suites/mutable_array/addObject.js +++ b/packages/ember-runtime/tests/suites/mutable_array/addObject.js @@ -1,25 +1,23 @@ import get from 'ember-metal/property_get'; import { SuiteModuleBuilder } from 'ember-runtime/tests/suites/suite'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('addObject'); suite.test('should return receiver', function() { - var before, obj; - before = this.newFixture(3); - obj = this.newObject(before); + let before = this.newFixture(3); + let obj = this.newObject(before); equal(obj.addObject(before[1]), obj, 'should return receiver'); }); suite.test('[A,B].addObject(C) => [A,B,C] + notify', function() { - var obj, before, after, observer, item; + let before = this.newFixture(2); + let item = this.newFixture(1)[0]; + let after = [before[0], before[1], item]; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - before = this.newFixture(2); - item = this.newFixture(1)[0]; - after = [before[0], before[1], item]; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ obj.addObject(item); @@ -38,13 +36,12 @@ suite.test('[A,B].addObject(C) => [A,B,C] + notify', function() { }); suite.test('[A,B,C].addObject(A) => [A,B,C] + NO notify', function() { - var obj, before, after, observer, item; + let before = this.newFixture(3); + let after = before; + let item = before[0]; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - before = this.newFixture(3); - after = before; - item = before[0]; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ obj.addObject(item); // note: item in set diff --git a/packages/ember-runtime/tests/suites/mutable_array/clear.js b/packages/ember-runtime/tests/suites/mutable_array/clear.js index 9e846438829..f27a3a8f300 100644 --- a/packages/ember-runtime/tests/suites/mutable_array/clear.js +++ b/packages/ember-runtime/tests/suites/mutable_array/clear.js @@ -1,17 +1,16 @@ import get from 'ember-metal/property_get'; import { SuiteModuleBuilder } from 'ember-runtime/tests/suites/suite'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('clear'); suite.test('[].clear() => [] + notify', function () { - var obj, before, after, observer; + let before = []; + let after = []; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - before = []; - after = []; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ equal(obj.clear(), obj, 'return self'); diff --git a/packages/ember-runtime/tests/suites/mutable_array/insertAt.js b/packages/ember-runtime/tests/suites/mutable_array/insertAt.js index 274b3f7c4ba..45c0f652128 100644 --- a/packages/ember-runtime/tests/suites/mutable_array/insertAt.js +++ b/packages/ember-runtime/tests/suites/mutable_array/insertAt.js @@ -1,16 +1,14 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; import {get} from 'ember-metal/property_get'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('insertAt'); suite.test('[].insertAt(0, X) => [X] + notify', function() { - var obj, after, observer; - - after = this.newFixture(1); - obj = this.newObject([]); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + let after = this.newFixture(1); + let obj = this.newObject([]); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -34,22 +32,18 @@ suite.test('[].insertAt(0, X) => [X] + notify', function() { }); suite.test('[].insertAt(200,X) => OUT_OF_RANGE_EXCEPTION exception', function() { - var obj = this.newObject([]); - var that = this; + let obj = this.newObject([]); + let that = this; - throws(function() { - obj.insertAt(200, that.newFixture(1)[0]); - }, Error); + throws(() => obj.insertAt(200, that.newFixture(1)[0]), Error); }); suite.test('[A].insertAt(0, X) => [X,A] + notify', function() { - var obj, item, after, before, observer; - - item = this.newFixture(1)[0]; - before = this.newFixture(1); - after = [item, before[0]]; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + let item = this.newFixture(1)[0]; + let before = this.newFixture(1); + let after = [item, before[0]]; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -73,13 +67,11 @@ suite.test('[A].insertAt(0, X) => [X,A] + notify', function() { }); suite.test('[A].insertAt(1, X) => [A,X] + notify', function() { - var obj, item, after, before, observer; - - item = this.newFixture(1)[0]; - before = this.newFixture(1); - after = [before[0], item]; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + let item = this.newFixture(1)[0]; + let before = this.newFixture(1); + let after = [before[0], item]; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -103,22 +95,18 @@ suite.test('[A].insertAt(1, X) => [A,X] + notify', function() { }); suite.test('[A].insertAt(200,X) => OUT_OF_RANGE exception', function() { - var obj = this.newObject(this.newFixture(1)); - var that = this; + let obj = this.newObject(this.newFixture(1)); + let that = this; - throws(function() { - obj.insertAt(200, that.newFixture(1)[0]); - }, Error); + throws(() => obj.insertAt(200, that.newFixture(1)[0]), Error); }); suite.test('[A,B,C].insertAt(0,X) => [X,A,B,C] + notify', function() { - var obj, item, after, before, observer; - - item = this.newFixture(1)[0]; - before = this.newFixture(3); - after = [item, before[0], before[1], before[2]]; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + let item = this.newFixture(1)[0]; + let before = this.newFixture(3); + let after = [item, before[0], before[1], before[2]]; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -142,13 +130,11 @@ suite.test('[A,B,C].insertAt(0,X) => [X,A,B,C] + notify', function() { }); suite.test('[A,B,C].insertAt(1,X) => [A,X,B,C] + notify', function() { - var obj, item, after, before, observer; - - item = this.newFixture(1)[0]; - before = this.newFixture(3); - after = [before[0], item, before[1], before[2]]; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + let item = this.newFixture(1)[0]; + let before = this.newFixture(3); + let after = [before[0], item, before[1], before[2]]; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ @@ -172,13 +158,11 @@ suite.test('[A,B,C].insertAt(1,X) => [A,X,B,C] + notify', function() { }); suite.test('[A,B,C].insertAt(3,X) => [A,B,C,X] + notify', function() { - var obj, item, after, before, observer; - - item = this.newFixture(1)[0]; - before = this.newFixture(3); - after = [before[0], before[1], before[2], item]; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + let item = this.newFixture(1)[0]; + let before = this.newFixture(3); + let after = [before[0], before[1], before[2], item]; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ diff --git a/packages/ember-runtime/tests/suites/mutable_array/popObject.js b/packages/ember-runtime/tests/suites/mutable_array/popObject.js index 2cdc5918984..954aad79f6e 100644 --- a/packages/ember-runtime/tests/suites/mutable_array/popObject.js +++ b/packages/ember-runtime/tests/suites/mutable_array/popObject.js @@ -1,15 +1,14 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; import {get} from 'ember-metal/property_get'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('popObject'); suite.test('[].popObject() => [] + returns undefined + NO notify', function() { - var obj, observer; + let obj = this.newObject([]); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - obj = this.newObject([]); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ equal(obj.popObject(), undefined, 'popObject results'); @@ -24,15 +23,14 @@ suite.test('[].popObject() => [] + returns undefined + NO notify', function() { }); suite.test('[X].popObject() => [] + notify', function() { - var obj, before, after, observer, ret; + let before = this.newFixture(1); + let after = []; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - before = this.newFixture(1); - after = []; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ - ret = obj.popObject(); + let ret = obj.popObject(); equal(ret, before[0], 'return object'); deepEqual(this.toArray(obj), after, 'post item results'); @@ -46,15 +44,14 @@ suite.test('[X].popObject() => [] + notify', function() { }); suite.test('[A,B,C].popObject() => [A,B] + notify', function() { - var obj, before, after, observer, ret; + let before = this.newFixture(3); + let after = [before[0], before[1]]; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - before = this.newFixture(3); - after = [before[0], before[1]]; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ - ret = obj.popObject(); + let ret = obj.popObject(); equal(ret, before[2], 'return object'); deepEqual(this.toArray(obj), after, 'post item results'); diff --git a/packages/ember-runtime/tests/suites/mutable_array/pushObject.js b/packages/ember-runtime/tests/suites/mutable_array/pushObject.js index 5123772151c..8c1c064aa5a 100644 --- a/packages/ember-runtime/tests/suites/mutable_array/pushObject.js +++ b/packages/ember-runtime/tests/suites/mutable_array/pushObject.js @@ -1,23 +1,23 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; import {get} from 'ember-metal/property_get'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('pushObject'); suite.test('returns pushed object', function() { - var exp = this.newFixture(1)[0]; - var obj = this.newObject([]); + let exp = this.newFixture(1)[0]; + let obj = this.newObject([]); + equal(obj.pushObject(exp), exp, 'should return pushed object'); }); suite.test('[].pushObject(X) => [X] + notify', function() { - var obj, before, after, observer; + let before = []; + let after = this.newFixture(1); + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - before = []; - after = this.newFixture(1); - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ obj.pushObject(after[0]); @@ -33,13 +33,12 @@ suite.test('[].pushObject(X) => [X] + notify', function() { }); suite.test('[A,B,C].pushObject(X) => [A,B,C,X] + notify', function() { - var obj, before, after, item, observer; + let before = this.newFixture(3); + let item = this.newFixture(1)[0]; + let after = [before[0], before[1], before[2], item]; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - before = this.newFixture(3); - item = this.newFixture(1)[0]; - after = [before[0], before[1], before[2], item]; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ obj.pushObject(item); diff --git a/packages/ember-runtime/tests/suites/mutable_array/pushObjects.js b/packages/ember-runtime/tests/suites/mutable_array/pushObjects.js index b2a6547df67..df5994bd109 100644 --- a/packages/ember-runtime/tests/suites/mutable_array/pushObjects.js +++ b/packages/ember-runtime/tests/suites/mutable_array/pushObjects.js @@ -1,15 +1,13 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('pushObjects'); suite.test('should raise exception if not Ember.Enumerable is passed to pushObjects', function() { - var obj = this.newObject([]); + let obj = this.newObject([]); - throws(function() { - obj.pushObjects('string'); - }); + throws(() => obj.pushObjects('string')); }); export default suite; diff --git a/packages/ember-runtime/tests/suites/mutable_array/removeAt.js b/packages/ember-runtime/tests/suites/mutable_array/removeAt.js index b89795e78ee..2bf30b82783 100644 --- a/packages/ember-runtime/tests/suites/mutable_array/removeAt.js +++ b/packages/ember-runtime/tests/suites/mutable_array/removeAt.js @@ -1,17 +1,16 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; import {get} from 'ember-metal/property_get'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('removeAt'); suite.test('[X].removeAt(0) => [] + notify', function() { - var obj, before, after, observer; + let before = this.newFixture(1); + let after = []; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - before = this.newFixture(1); - after = []; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ equal(obj.removeAt(0), obj, 'return self'); @@ -27,19 +26,16 @@ suite.test('[X].removeAt(0) => [] + notify', function() { }); suite.test('[].removeAt(200) => OUT_OF_RANGE_EXCEPTION exception', function() { - var obj = this.newObject([]); - throws(function() { - obj.removeAt(200); - }, Error); + let obj = this.newObject([]); + throws(() => obj.removeAt(200), Error); }); suite.test('[A,B].removeAt(0) => [B] + notify', function() { - var obj, before, after, observer; + let before = this.newFixture(2); + let after = [before[1]]; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - before = this.newFixture(2); - after = [before[1]]; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ equal(obj.removeAt(0), obj, 'return self'); @@ -56,12 +52,11 @@ suite.test('[A,B].removeAt(0) => [B] + notify', function() { }); suite.test('[A,B].removeAt(1) => [A] + notify', function() { - var obj, before, after, observer; + let before = this.newFixture(2); + let after = [before[0]]; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - before = this.newFixture(2); - after = [before[0]]; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ equal(obj.removeAt(1), obj, 'return self'); @@ -78,12 +73,11 @@ suite.test('[A,B].removeAt(1) => [A] + notify', function() { }); suite.test('[A,B,C].removeAt(1) => [A,C] + notify', function() { - var obj, before, after, observer; + let before = this.newFixture(3); + let after = [before[0], before[2]]; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - before = this.newFixture(3); - after = [before[0], before[2]]; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ equal(obj.removeAt(1), obj, 'return self'); @@ -100,12 +94,11 @@ suite.test('[A,B,C].removeAt(1) => [A,C] + notify', function() { }); suite.test('[A,B,C,D].removeAt(1,2) => [A,D] + notify', function() { - var obj, before, after, observer; + let before = this.newFixture(4); + let after = [before[0], before[3]]; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - before = this.newFixture(4); - after = [before[0], before[3]]; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ equal(obj.removeAt(1, 2), obj, 'return self'); diff --git a/packages/ember-runtime/tests/suites/mutable_array/removeObject.js b/packages/ember-runtime/tests/suites/mutable_array/removeObject.js index 923c0e87b58..1c51acc2747 100644 --- a/packages/ember-runtime/tests/suites/mutable_array/removeObject.js +++ b/packages/ember-runtime/tests/suites/mutable_array/removeObject.js @@ -1,24 +1,23 @@ import get from 'ember-metal/property_get'; import { SuiteModuleBuilder } from 'ember-runtime/tests/suites/suite'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('removeObject'); suite.test('should return receiver', function() { - var before, obj; - before = this.newFixture(3); - obj = this.newObject(before); + let before = this.newFixture(3); + let obj = this.newObject(before); + equal(obj.removeObject(before[1]), obj, 'should return receiver'); }); suite.test('[A,B,C].removeObject(B) => [A,C] + notify', function() { - var obj, before, after, observer; + let before = this.newFixture(3); + let after = [before[0], before[2]]; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - before = this.newFixture(3); - after = [before[0], before[2]]; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ obj.removeObject(before[1]); @@ -37,13 +36,12 @@ suite.test('[A,B,C].removeObject(B) => [A,C] + notify', function() { }); suite.test('[A,B,C].removeObject(D) => [A,B,C]', function() { - var obj, before, after, observer, item; + let before = this.newFixture(3); + let after = before; + let item = this.newFixture(1)[0]; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - before = this.newFixture(3); - after = before; - item = this.newFixture(1)[0]; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ obj.removeObject(item); // note: item not in set diff --git a/packages/ember-runtime/tests/suites/mutable_array/replace.js b/packages/ember-runtime/tests/suites/mutable_array/replace.js index 7b8793c7232..9eb6e85a95f 100644 --- a/packages/ember-runtime/tests/suites/mutable_array/replace.js +++ b/packages/ember-runtime/tests/suites/mutable_array/replace.js @@ -1,14 +1,14 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('replace'); suite.test('[].replace(0,0,\'X\') => [\'X\'] + notify', function() { - var obj, exp, observer; - exp = this.newFixture(1); - obj = this.newObject([]); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + let exp = this.newFixture(1); + let obj = this.newObject([]); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); + obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ obj.replace(0, 0, exp); @@ -23,14 +23,13 @@ suite.test('[].replace(0,0,\'X\') => [\'X\'] + notify', function() { }); suite.test('[A,B,C,D].replace(1,2,X) => [A,X,D] + notify', function() { - var obj, observer, before, replace, after; + let before = this.newFixture(4); + let replace = this.newFixture(1); + let after = [before[0], replace[0], before[3]]; - before = this.newFixture(4); - replace = this.newFixture(1); - after = [before[0], replace[0], before[3]]; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ obj.replace(1, 2, replace); @@ -46,14 +45,13 @@ suite.test('[A,B,C,D].replace(1,2,X) => [A,X,D] + notify', function() { }); suite.test('[A,B,C,D].replace(1,2,[X,Y]) => [A,X,Y,D] + notify', function() { - var obj, observer, before, replace, after; + let before = this.newFixture(4); + let replace = this.newFixture(2); + let after = [before[0], replace[0], replace[1], before[3]]; - before = this.newFixture(4); - replace = this.newFixture(2); - after = [before[0], replace[0], replace[1], before[3]]; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ obj.replace(1, 2, replace); @@ -69,14 +67,13 @@ suite.test('[A,B,C,D].replace(1,2,[X,Y]) => [A,X,Y,D] + notify', function() { }); suite.test('[A,B].replace(1,0,[X,Y]) => [A,X,Y,B] + notify', function() { - var obj, observer, before, replace, after; + let before = this.newFixture(2); + let replace = this.newFixture(2); + let after = [before[0], replace[0], replace[1], before[1]]; - before = this.newFixture(2); - replace = this.newFixture(2); - after = [before[0], replace[0], replace[1], before[1]]; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ obj.replace(1, 0, replace); @@ -92,13 +89,12 @@ suite.test('[A,B].replace(1,0,[X,Y]) => [A,X,Y,B] + notify', function() { }); suite.test('[A,B,C,D].replace(2,2) => [A,B] + notify', function() { - var obj, observer, before, after; + let before = this.newFixture(4); + let after = [before[0], before[1]]; - before = this.newFixture(4); - after = [before[0], before[1]]; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ obj.replace(2, 2); @@ -114,10 +110,10 @@ suite.test('[A,B,C,D].replace(2,2) => [A,B] + notify', function() { }); suite.test('Adding object should notify enumerable observer', function() { - var fixtures = this.newFixture(4); - var obj = this.newObject(fixtures); - var observer = this.newObserver(obj).observeEnumerable(obj); - var item = this.newFixture(1)[0]; + let fixtures = this.newFixture(4); + let obj = this.newObject(fixtures); + let observer = this.newObserver(obj).observeEnumerable(obj); + let item = this.newFixture(1)[0]; obj.replace(2, 2, [item]); @@ -126,10 +122,10 @@ suite.test('Adding object should notify enumerable observer', function() { }); suite.test('Adding object should notify array observer', function() { - var fixtures = this.newFixture(4); - var obj = this.newObject(fixtures); - var observer = this.newObserver(obj).observeArray(obj); - var item = this.newFixture(1)[0]; + let fixtures = this.newFixture(4); + let obj = this.newObject(fixtures); + let observer = this.newObserver(obj).observeArray(obj); + let item = this.newFixture(1)[0]; obj.replace(2, 2, [item]); diff --git a/packages/ember-runtime/tests/suites/mutable_array/reverseObjects.js b/packages/ember-runtime/tests/suites/mutable_array/reverseObjects.js index c153afc1423..78d6d418059 100644 --- a/packages/ember-runtime/tests/suites/mutable_array/reverseObjects.js +++ b/packages/ember-runtime/tests/suites/mutable_array/reverseObjects.js @@ -1,17 +1,16 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; import {get} from 'ember-metal/property_get'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('reverseObjects'); suite.test('[A,B,C].reverseObjects() => [] + notify', function () { - var obj, before, after, observer; + let before = this.newFixture(3); + let after = [before[2], before[1], before[0]]; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - before = this.newFixture(3); - after = [before[2], before[1], before[0]]; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ equal(obj.reverseObjects(), obj, 'return self'); diff --git a/packages/ember-runtime/tests/suites/mutable_array/setObjects.js b/packages/ember-runtime/tests/suites/mutable_array/setObjects.js index bd8f264448e..3cdd9138015 100644 --- a/packages/ember-runtime/tests/suites/mutable_array/setObjects.js +++ b/packages/ember-runtime/tests/suites/mutable_array/setObjects.js @@ -1,17 +1,16 @@ import get from 'ember-metal/property_get'; import { SuiteModuleBuilder } from 'ember-runtime/tests/suites/suite'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('setObjects'); suite.test('[A,B,C].setObjects([]) = > [] + notify', function() { - var obj, before, after, observer; + let before = this.newFixture(3); + let after = []; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - before = this.newFixture(3); - after = []; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ equal(obj.setObjects(after), obj, 'return self'); @@ -27,12 +26,11 @@ suite.test('[A,B,C].setObjects([]) = > [] + notify', function() { }); suite.test('[A,B,C].setObjects([D, E, F, G]) = > [D, E, F, G] + notify', function() { - var obj, before, after, observer; + let before = this.newFixture(3); + let after = this.newFixture(4); + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - before = this.newFixture(3); - after = this.newFixture(4); - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ equal(obj.setObjects(after), obj, 'return self'); diff --git a/packages/ember-runtime/tests/suites/mutable_array/shiftObject.js b/packages/ember-runtime/tests/suites/mutable_array/shiftObject.js index 3d575255e22..0b625e699d1 100644 --- a/packages/ember-runtime/tests/suites/mutable_array/shiftObject.js +++ b/packages/ember-runtime/tests/suites/mutable_array/shiftObject.js @@ -1,17 +1,16 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; import {get} from 'ember-metal/property_get'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('shiftObject'); suite.test('[].shiftObject() => [] + returns undefined + NO notify', function() { - var obj, before, after, observer; + let before = []; + let after = []; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - before = []; - after = []; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ equal(obj.shiftObject(), undefined); @@ -28,12 +27,11 @@ suite.test('[].shiftObject() => [] + returns undefined + NO notify', function() }); suite.test('[X].shiftObject() => [] + notify', function() { - var obj, before, after, observer; + let before = this.newFixture(1); + let after = []; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - before = this.newFixture(1); - after = []; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ equal(obj.shiftObject(), before[0], 'should return object'); @@ -49,12 +47,11 @@ suite.test('[X].shiftObject() => [] + notify', function() { }); suite.test('[A,B,C].shiftObject() => [B,C] + notify', function() { - var obj, before, after, observer; + let before = this.newFixture(3); + let after = [before[1], before[2]]; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - before = this.newFixture(3); - after = [before[1], before[2]]; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ equal(obj.shiftObject(), before[0], 'should return object'); diff --git a/packages/ember-runtime/tests/suites/mutable_array/unshiftObject.js b/packages/ember-runtime/tests/suites/mutable_array/unshiftObject.js index 02cfaa50086..2d9579cbf2e 100644 --- a/packages/ember-runtime/tests/suites/mutable_array/unshiftObject.js +++ b/packages/ember-runtime/tests/suites/mutable_array/unshiftObject.js @@ -1,25 +1,24 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; import {get} from 'ember-metal/property_get'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('unshiftObject'); suite.test('returns unshifted object', function() { - var obj = this.newObject([]); - var item = this.newFixture(1)[0]; + let obj = this.newObject([]); + let item = this.newFixture(1)[0]; + equal(obj.unshiftObject(item), item, 'should return unshifted object'); }); - suite.test('[].unshiftObject(X) => [X] + notify', function() { - var obj, before, after, item, observer; + let before = []; + let item = this.newFixture(1)[0]; + let after = [item]; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - before = []; - item = this.newFixture(1)[0]; - after = [item]; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ obj.unshiftObject(item); @@ -35,13 +34,12 @@ suite.test('[].unshiftObject(X) => [X] + notify', function() { }); suite.test('[A,B,C].unshiftObject(X) => [X,A,B,C] + notify', function() { - var obj, before, after, item, observer; + let before = this.newFixture(3); + let item = this.newFixture(1)[0]; + let after = [item, before[0], before[1], before[2]]; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - before = this.newFixture(3); - item = this.newFixture(1)[0]; - after = [item, before[0], before[1], before[2]]; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ obj.unshiftObject(item); @@ -58,13 +56,12 @@ suite.test('[A,B,C].unshiftObject(X) => [X,A,B,C] + notify', function() { }); suite.test('[A,B,C].unshiftObject(A) => [A,A,B,C] + notify', function() { - var obj, before, after, item, observer; + let before = this.newFixture(3); + let item = before[0]; // note same object as current head. should end up twice + let after = [item, before[0], before[1], before[2]]; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - before = this.newFixture(3); - item = before[0]; // note same object as current head. should end up twice - after = [item, before[0], before[1], before[2]]; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ obj.unshiftObject(item); diff --git a/packages/ember-runtime/tests/suites/mutable_array/unshiftObjects.js b/packages/ember-runtime/tests/suites/mutable_array/unshiftObjects.js index b47d29ef86b..bcf3c80c172 100644 --- a/packages/ember-runtime/tests/suites/mutable_array/unshiftObjects.js +++ b/packages/ember-runtime/tests/suites/mutable_array/unshiftObjects.js @@ -1,23 +1,23 @@ import get from 'ember-metal/property_get'; import { SuiteModuleBuilder } from 'ember-runtime/tests/suites/suite'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('unshiftObjects'); suite.test('returns receiver', function() { - var obj = this.newObject([]); - var items = this.newFixture(3); + let obj = this.newObject([]); + let items = this.newFixture(3); + equal(obj.unshiftObjects(items), obj, 'should return receiver'); }); suite.test('[].unshiftObjects([A,B,C]) => [A,B,C] + notify', function() { - var obj, before, items, observer; + let before = []; + let items = this.newFixture(3); + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - before = []; - items = this.newFixture(3); - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ obj.unshiftObjects(items); @@ -33,13 +33,12 @@ suite.test('[].unshiftObjects([A,B,C]) => [A,B,C] + notify', function() { }); suite.test('[A,B,C].unshiftObjects([X,Y]) => [X,Y,A,B,C] + notify', function() { - var obj, before, items, after, observer; + let before = this.newFixture(3); + let items = this.newFixture(2); + let after = items.concat(before); + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - before = this.newFixture(3); - items = this.newFixture(2); - after = items.concat(before); - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ obj.unshiftObjects(items); @@ -56,13 +55,12 @@ suite.test('[A,B,C].unshiftObjects([X,Y]) => [X,Y,A,B,C] + notify', function() { }); suite.test('[A,B,C].unshiftObjects([A,B]) => [A,B,A,B,C] + notify', function() { - var obj, before, after, items, observer; + let before = this.newFixture(3); + let items = [before[0], before[1]]; // note same object as current head. should end up twice + let after = items.concat(before); + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); - before = this.newFixture(3); - items = [before[0], before[1]]; // note same object as current head. should end up twice - after = items.concat(before); - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ obj.unshiftObjects(items); diff --git a/packages/ember-runtime/tests/suites/mutable_enumerable.js b/packages/ember-runtime/tests/suites/mutable_enumerable.js index bcb8a6c19fc..3a02d18369a 100644 --- a/packages/ember-runtime/tests/suites/mutable_enumerable.js +++ b/packages/ember-runtime/tests/suites/mutable_enumerable.js @@ -4,7 +4,7 @@ import addObjectTests from 'ember-runtime/tests/suites/mutable_enumerable/addObj import removeObjectTests from 'ember-runtime/tests/suites/mutable_enumerable/removeObject'; import removeObjectsTests from 'ember-runtime/tests/suites/mutable_enumerable/removeObjects'; -var MutableEnumerableTests = EnumerableTests.extend(); +const MutableEnumerableTests = EnumerableTests.extend(); MutableEnumerableTests.importModuleTests(addObjectTests); MutableEnumerableTests.importModuleTests(removeObjectTests); MutableEnumerableTests.importModuleTests(removeObjectsTests); diff --git a/packages/ember-runtime/tests/suites/mutable_enumerable/addObject.js b/packages/ember-runtime/tests/suites/mutable_enumerable/addObject.js index eea731d32fa..8bcabd06f02 100644 --- a/packages/ember-runtime/tests/suites/mutable_enumerable/addObject.js +++ b/packages/ember-runtime/tests/suites/mutable_enumerable/addObject.js @@ -1,25 +1,24 @@ import {SuiteModuleBuilder} from 'ember-runtime/tests/suites/suite'; import {get} from 'ember-metal/property_get'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('addObject'); suite.test('should return receiver', function() { - var before, obj; - before = this.newFixture(3); - obj = this.newObject(before); + let before = this.newFixture(3); + let obj = this.newObject(before); + equal(obj.addObject(before[1]), obj, 'should return receiver'); }); suite.test('[A,B].addObject(C) => [A,B,C] + notify', function() { - var obj, before, after, observer, item; + let before = this.newFixture(2); + let item = this.newFixture(1)[0]; + let after = [before[0], before[1], item]; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); - before = this.newFixture(2); - item = this.newFixture(1)[0]; - after = [before[0], before[1], item]; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); get(obj, 'firstObject'); get(obj, 'lastObject'); @@ -38,13 +37,11 @@ suite.test('[A,B].addObject(C) => [A,B,C] + notify', function() { }); suite.test('[A,B,C].addObject(A) => [A,B,C] + NO notify', function() { - var obj, before, after, observer, item; - - before = this.newFixture(3); - after = before; - item = before[0]; - obj = this.newObject(before); - observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); + let before = this.newFixture(3); + let after = before; + let item = before[0]; + let obj = this.newObject(before); + let observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); obj.addObject(item); // note: item in set @@ -60,9 +57,9 @@ suite.test('[A,B,C].addObject(A) => [A,B,C] + NO notify', function() { }); suite.test('Adding object should notify enumerable observer', function() { - var obj = this.newObject(this.newFixture(3)); - var observer = this.newObserver(obj).observeEnumerable(obj); - var item = this.newFixture(1)[0]; + let obj = this.newObject(this.newFixture(3)); + let observer = this.newObserver(obj).observeEnumerable(obj); + let item = this.newFixture(1)[0]; obj.addObject(item); diff --git a/packages/ember-runtime/tests/suites/mutable_enumerable/removeObject.js b/packages/ember-runtime/tests/suites/mutable_enumerable/removeObject.js index efc8db74aab..23762b52830 100644 --- a/packages/ember-runtime/tests/suites/mutable_enumerable/removeObject.js +++ b/packages/ember-runtime/tests/suites/mutable_enumerable/removeObject.js @@ -2,24 +2,23 @@ import { get } from 'ember-metal/property_get'; import { SuiteModuleBuilder } from 'ember-runtime/tests/suites/suite'; import { A as emberA } from 'ember-runtime/system/native_array'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('removeObject'); suite.test('should return receiver', function() { - var before, obj; - before = this.newFixture(3); - obj = this.newObject(before); + let before = this.newFixture(3); + let obj = this.newObject(before); + equal(obj.removeObject(before[1]), obj, 'should return receiver'); }); suite.test('[A,B,C].removeObject(B) => [A,C] + notify', function() { - var obj, before, after, observer; + let before = emberA(this.newFixture(3)); + let after = [before[0], before[2]]; + let obj = before; + let observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); - before = emberA(this.newFixture(3)); - after = [before[0], before[2]]; - obj = before; - observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); // Prime the cache obj.removeObject(before[1]); @@ -37,13 +36,12 @@ suite.test('[A,B,C].removeObject(B) => [A,C] + notify', function() { }); suite.test('[A,B,C].removeObject(D) => [A,B,C]', function() { - var obj, before, after, observer, item; + let before = emberA(this.newFixture(3)); + let after = before; + let item = this.newFixture(1)[0]; + let obj = before; + let observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); - before = emberA(this.newFixture(3)); - after = before; - item = this.newFixture(1)[0]; - obj = before; - observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); // Prime the cache obj.removeObject(item); // Note: item not in set @@ -61,10 +59,10 @@ suite.test('[A,B,C].removeObject(D) => [A,B,C]', function() { }); suite.test('Removing object should notify enumerable observer', function() { - var fixtures = this.newFixture(3); - var obj = this.newObject(fixtures); - var observer = this.newObserver(obj).observeEnumerable(obj); - var item = fixtures[1]; + let fixtures = this.newFixture(3); + let obj = this.newObject(fixtures); + let observer = this.newObserver(obj).observeEnumerable(obj); + let item = fixtures[1]; obj.removeObject(item); diff --git a/packages/ember-runtime/tests/suites/mutable_enumerable/removeObjects.js b/packages/ember-runtime/tests/suites/mutable_enumerable/removeObjects.js index bde38d7138b..c1b7739e52e 100644 --- a/packages/ember-runtime/tests/suites/mutable_enumerable/removeObjects.js +++ b/packages/ember-runtime/tests/suites/mutable_enumerable/removeObjects.js @@ -2,24 +2,23 @@ import { SuiteModuleBuilder } from 'ember-runtime/tests/suites/suite'; import { get } from 'ember-metal/property_get'; import { A as emberA } from 'ember-runtime/system/native_array'; -var suite = SuiteModuleBuilder.create(); +const suite = SuiteModuleBuilder.create(); suite.module('removeObjects'); suite.test('should return receiver', function() { - var before, obj; - before = emberA(this.newFixture(3)); - obj = before; + let before = emberA(this.newFixture(3)); + let obj = before; + equal(obj.removeObjects(before[1]), obj, 'should return receiver'); }); suite.test('[A,B,C].removeObjects([B]) => [A,C] + notify', function() { - var obj, before, after, observer; + let before = emberA(this.newFixture(3)); + let after = [before[0], before[2]]; + let obj = before; + let observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); - before = emberA(this.newFixture(3)); - after = [before[0], before[2]]; - obj = before; - observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); // Prime the cache obj.removeObjects([before[1]]); @@ -37,12 +36,11 @@ suite.test('[A,B,C].removeObjects([B]) => [A,C] + notify', function() { }); suite.test('[{A},{B},{C}].removeObjects([{B}]) => [{A},{C}] + notify', function() { - var obj, before, after, observer; + let before = emberA(this.newObjectsFixture(3)); + let after = [before[0], before[2]]; + let obj = before; + let observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); - before = emberA(this.newObjectsFixture(3)); - after = [before[0], before[2]]; - obj = before; - observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); // Prime the cache obj.removeObjects([before[1]]); @@ -60,12 +58,11 @@ suite.test('[{A},{B},{C}].removeObjects([{B}]) => [{A},{C}] + notify', function( }); suite.test('[A,B,C].removeObjects([A,B]) => [C] + notify', function() { - var obj, before, after, observer; + let before = emberA(this.newFixture(3)); + let after = [before[2]]; + let obj = before; + let observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); - before = emberA(this.newFixture(3)); - after = [before[2]]; - obj = before; - observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); // Prime the cache obj.removeObjects([before[0], before[1]]); @@ -83,12 +80,11 @@ suite.test('[A,B,C].removeObjects([A,B]) => [C] + notify', function() { }); suite.test('[{A},{B},{C}].removeObjects([{A},{B}]) => [{C}] + notify', function() { - var obj, before, after, observer; + let before = emberA(this.newObjectsFixture(3)); + let after = [before[2]]; + let obj = before; + let observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); - before = emberA(this.newObjectsFixture(3)); - after = [before[2]]; - obj = before; - observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); // Prime the cache obj.removeObjects([before[0], before[1]]); @@ -106,12 +102,11 @@ suite.test('[{A},{B},{C}].removeObjects([{A},{B}]) => [{C}] + notify', function( }); suite.test('[A,B,C].removeObjects([A,B,C]) => [] + notify', function() { - var obj, before, after, observer; + let before = emberA(this.newFixture(3)); + let after = []; + let obj = before; + let observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); - before = emberA(this.newFixture(3)); - after = []; - obj = before; - observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); // Prime the cache obj.removeObjects([before[0], before[1], before[2]]); @@ -129,12 +124,11 @@ suite.test('[A,B,C].removeObjects([A,B,C]) => [] + notify', function() { }); suite.test('[{A},{B},{C}].removeObjects([{A},{B},{C}]) => [] + notify', function() { - var obj, before, after, observer; + let before = emberA(this.newObjectsFixture(3)); + let after = []; + let obj = before; + let observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); - before = emberA(this.newObjectsFixture(3)); - after = []; - obj = before; - observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); // Prime the cache obj.removeObjects(before); @@ -152,13 +146,12 @@ suite.test('[{A},{B},{C}].removeObjects([{A},{B},{C}]) => [] + notify', function }); suite.test('[A,B,C].removeObjects([D]) => [A,B,C]', function() { - var obj, before, after, observer, item; + let before = emberA(this.newFixture(3)); + let after = before; + let item = this.newFixture(1)[0]; + let obj = before; + let observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); - before = emberA(this.newFixture(3)); - after = before; - item = this.newFixture(1)[0]; - obj = before; - observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject'); obj.getProperties('firstObject', 'lastObject'); // Prime the cache obj.removeObjects([item]); // Note: item not in set @@ -176,10 +169,10 @@ suite.test('[A,B,C].removeObjects([D]) => [A,B,C]', function() { }); suite.test('Removing objects should notify enumerable observer', function() { - var fixtures = this.newFixture(3); - var obj = this.newObject(fixtures); - var observer = this.newObserver(obj).observeEnumerable(obj); - var item = fixtures[1]; + let fixtures = this.newFixture(3); + let obj = this.newObject(fixtures); + let observer = this.newObserver(obj).observeEnumerable(obj); + let item = fixtures[1]; obj.removeObjects([item]); diff --git a/packages/ember-runtime/tests/suites/suite.js b/packages/ember-runtime/tests/suites/suite.js index a314a28fc5d..a53a01aa09b 100644 --- a/packages/ember-runtime/tests/suites/suite.js +++ b/packages/ember-runtime/tests/suites/suite.js @@ -35,7 +35,7 @@ import { get } from 'ember-metal/property_get'; @extends Ember.Object @private */ -var Suite = EmberObject.extend({ +const Suite = EmberObject.extend({ /* __Required.__ You must implement this method to apply this mixin. @@ -58,7 +58,7 @@ Suite.reopenClass({ plan: null, run() { - var C = this; + let C = this; return new C().run(); }, @@ -67,13 +67,13 @@ Suite.reopenClass({ opts = {}; } - var setup = opts.setup; - var teardown = opts.teardown; + let setup = opts.setup; + let teardown = opts.teardown; this.reopen({ run() { this._super(...arguments); - var title = get(this, 'name') + ': ' + desc; - var ctx = this; + let title = get(this, 'name') + ': ' + desc; + let ctx = this; QUnit.module(title, { setup() { if (setup) { @@ -95,12 +95,12 @@ Suite.reopenClass({ this.reopen({ run() { this._super(...arguments); - var ctx = this; + let ctx = this; if (!func) { QUnit.test(name); // output warning } else { - QUnit.test(name, function() { func.call(ctx); }); + QUnit.test(name, () => func.call(ctx)); } } }); @@ -108,8 +108,8 @@ Suite.reopenClass({ // convert to guids to minimize logging. same(actual, exp, message) { - actual = (actual && actual.map) ? actual.map(function(x) { return guidFor(x); }) : actual; - exp = (exp && exp.map) ? exp.map(function(x) { return guidFor(x); }) : exp; + actual = (actual && actual.map) ? actual.map(x => guidFor(x)) : actual; + exp = (exp && exp.map) ? exp.map(x => guidFor(x)) : exp; return deepEqual(actual, exp, message); }, @@ -125,7 +125,7 @@ Suite.reopenClass({ } }); -var SuiteModuleBuilder = EmberObject.extend({ +const SuiteModuleBuilder = EmberObject.extend({ _module: null, _tests: null, diff --git a/packages/ember-runtime/tests/system/array_proxy/arranged_content_test.js b/packages/ember-runtime/tests/system/array_proxy/arranged_content_test.js index 9971270d06c..29d0698f152 100644 --- a/packages/ember-runtime/tests/system/array_proxy/arranged_content_test.js +++ b/packages/ember-runtime/tests/system/array_proxy/arranged_content_test.js @@ -4,15 +4,15 @@ import ArrayProxy from 'ember-runtime/system/array_proxy'; import { A as emberA } from 'ember-runtime/system/native_array'; import { objectAt } from 'ember-runtime/mixins/array'; -var array; +let array; QUnit.module('ArrayProxy - arrangedContent', { setup() { - run(function() { + run(() => { array = ArrayProxy.extend({ arrangedContent: computed('content.[]', function() { - var content = this.get('content'); - return content && emberA(content.slice().sort(function(a, b) { + let content = this.get('content'); + return content && emberA(content.slice().sort((a, b) => { if (a == null) { a = -1; } if (b == null) { b = -1; } return b - a; @@ -24,29 +24,31 @@ QUnit.module('ArrayProxy - arrangedContent', { }); }, teardown() { - run(function() { - array.destroy(); - }); + run(() => array.destroy()); } }); QUnit.test('addObject - adds to end of \'content\' if not present', function() { - run(function() { array.addObject(3); }); + run(() => array.addObject(3)); + deepEqual(array.get('content'), [1, 2, 4, 5, 3], 'adds to end of content'); deepEqual(array.get('arrangedContent'), [5, 4, 3, 2, 1], 'arrangedContent stays sorted'); - run(function() { array.addObject(1); }); + run(() => array.addObject(1)); + deepEqual(array.get('content'), [1, 2, 4, 5, 3], 'does not add existing number to content'); }); QUnit.test('addObjects - adds to end of \'content\' if not present', function() { - run(function() { array.addObjects([1, 3, 6]); }); + run(() => array.addObjects([1, 3, 6])); + deepEqual(array.get('content'), [1, 2, 4, 5, 3, 6], 'adds to end of content'); deepEqual(array.get('arrangedContent'), [6, 5, 4, 3, 2, 1], 'arrangedContent stays sorted'); }); QUnit.test('compact - returns arrangedContent without nulls and undefined', function() { - run(function() { array.set('content', emberA([1, 3, null, 2, undefined])); }); + run(() => array.set('content', emberA([1, 3, null, 2, undefined]))); + deepEqual(array.compact(), [3, 2, 1]); }); @@ -55,13 +57,12 @@ QUnit.test('indexOf - returns index of object in arrangedContent', function() { }); QUnit.test('insertAt - raises, indeterminate behavior', function() { - throws(function() { - run(function() { array.insertAt(2, 3); }); - }); + throws(() => run(() => array.insertAt(2, 3))); }); QUnit.test('lastIndexOf - returns last index of object in arrangedContent', function() { - run(function() { array.pushObject(4); }); + run(() => array.pushObject(4)); + equal(array.lastIndexOf(4), 2, 'returns last arranged index'); }); @@ -83,62 +84,58 @@ QUnit.test('objectsAt - returns objects at indices in arrangedContent', function }); QUnit.test('popObject - removes last object in arrangedContent', function() { - var popped; - run(function() { popped = array.popObject(); }); + let popped; + run(() => popped = array.popObject()); equal(popped, 1, 'returns last object'); deepEqual(array.get('content'), [2, 4, 5], 'removes from content'); }); QUnit.test('pushObject - adds to end of content even if it already exists', function() { - run(function() { array.pushObject(1); }); + run(() => array.pushObject(1)); deepEqual(array.get('content'), [1, 2, 4, 5, 1], 'adds to end of content'); }); QUnit.test('pushObjects - adds multiple to end of content even if it already exists', function() { - run(function() { array.pushObjects([1, 2, 4]); }); + run(() => array.pushObjects([1, 2, 4])); deepEqual(array.get('content'), [1, 2, 4, 5, 1, 2, 4], 'adds to end of content'); }); QUnit.test('removeAt - removes from index in arrangedContent', function() { - run(function() { array.removeAt(1, 2); }); + run(() => array.removeAt(1, 2)); deepEqual(array.get('content'), [1, 5]); }); QUnit.test('removeObject - removes object from content', function() { - run(function() { array.removeObject(2); }); + run(() => array.removeObject(2)); deepEqual(array.get('content'), [1, 4, 5]); }); QUnit.test('removeObjects - removes objects from content', function() { - run(function() { array.removeObjects([2, 4, 6]); }); + run(() => array.removeObjects([2, 4, 6])); deepEqual(array.get('content'), [1, 5]); }); QUnit.test('replace - raises, indeterminate behavior', function() { - throws(function() { - run(function() { array.replace(1, 2, [3]); }); - }); + throws(() => run(() => array.replace(1, 2, [3]))); }); QUnit.test('replaceContent - does a standard array replace on content', function() { - run(function() { array.replaceContent(1, 2, [3]); }); + run(() => array.replaceContent(1, 2, [3])); deepEqual(array.get('content'), [1, 3, 5]); }); QUnit.test('reverseObjects - raises, use Sortable#sortAscending', function() { - throws(function() { - run(function() { array.reverseObjects(); }); - }); + throws(() => run(() => array.reverseObjects())); }); QUnit.test('setObjects - replaces entire content', function() { - run(function() { array.setObjects([6, 7, 8]); }); + run(() => array.setObjects([6, 7, 8])); deepEqual(array.get('content'), [6, 7, 8], 'replaces content'); }); QUnit.test('shiftObject - removes from start of arrangedContent', function() { - var shifted; - run(function() { shifted = array.shiftObject(); }); + let shifted = run(() => array.shiftObject()); + equal(shifted, 5, 'returns first object'); deepEqual(array.get('content'), [1, 2, 4], 'removes object from content'); }); @@ -152,7 +149,7 @@ QUnit.test('toArray - returns copy of arrangedContent', function() { }); QUnit.test('unshiftObject - adds to start of content', function() { - run(function() { array.unshiftObject(6); }); + run(() => array.unshiftObject(6)); deepEqual(array.get('content'), [6, 1, 2, 4, 5], 'adds to start of content'); }); @@ -209,7 +206,7 @@ QUnit.module('ArrayProxy - arrangedContent with transforms', { run(function() { array = ArrayProxy.extend({ arrangedContent: computed(function() { - var content = this.get('content'); + let content = this.get('content'); return content && emberA(content.slice().sort(function(a, b) { if (a == null) { a = -1; } if (b == null) { b = -1; } @@ -218,7 +215,7 @@ QUnit.module('ArrayProxy - arrangedContent with transforms', { }).property('content.[]'), objectAtContent(idx) { - var obj = objectAt(this.get('arrangedContent'), idx); + let obj = objectAt(this.get('arrangedContent'), idx); return obj && obj.toString(); } }).create({ @@ -260,7 +257,7 @@ QUnit.test('objectsAt - returns objects at indices in arrangedContent', function }); QUnit.test('popObject - removes last object in arrangedContent', function() { - var popped; + let popped; run(function() { popped = array.popObject(); }); equal(popped, '1', 'returns last object'); deepEqual(array.get('content'), [2, 4, 5], 'removes from content'); @@ -277,7 +274,7 @@ QUnit.test('removeObjects - removes objects from content', function() { }); QUnit.test('shiftObject - removes from start of arrangedContent', function() { - var shifted; + let shifted; run(function() { shifted = array.shiftObject(); }); equal(shifted, '5', 'returns first object'); deepEqual(array.get('content'), [1, 2, 4], 'removes object from content'); diff --git a/packages/ember-runtime/tests/system/array_proxy/content_change_test.js b/packages/ember-runtime/tests/system/array_proxy/content_change_test.js index 43a7bf78468..9dba0ed21a1 100644 --- a/packages/ember-runtime/tests/system/array_proxy/content_change_test.js +++ b/packages/ember-runtime/tests/system/array_proxy/content_change_test.js @@ -7,9 +7,9 @@ import { A as emberA } from 'ember-runtime/system/native_array'; QUnit.module('ArrayProxy - content change'); QUnit.test('should update length for null content', function() { - var proxy = ArrayProxy.create({ - content: emberA([1, 2, 3]) - }); + let proxy = ArrayProxy.create({ + content: emberA([1, 2, 3]) + }); equal(proxy.get('length'), 3, 'precond - length is 3'); @@ -19,7 +19,7 @@ QUnit.test('should update length for null content', function() { }); QUnit.test('should update length for null content when there is a computed property watching length', function() { - var proxy = ArrayProxy.extend({ + let proxy = ArrayProxy.extend({ isEmpty: not('length') }).create({ content: emberA([1, 2, 3]) @@ -37,10 +37,10 @@ QUnit.test('should update length for null content when there is a computed prope }); QUnit.test('The `arrangedContentWillChange` method is invoked before `content` is changed.', function() { - var callCount = 0; - var expectedLength; + let callCount = 0; + let expectedLength; - var proxy = ArrayProxy.extend({ + let proxy = ArrayProxy.extend({ arrangedContentWillChange() { equal(this.get('arrangedContent.length'), expectedLength, 'hook should be invoked before array has changed'); callCount++; @@ -59,10 +59,10 @@ QUnit.test('The `arrangedContentWillChange` method is invoked before `content` i }); QUnit.test('The `arrangedContentDidChange` method is invoked after `content` is changed.', function() { - var callCount = 0; - var expectedLength; + let callCount = 0; + let expectedLength; - var proxy = ArrayProxy.extend({ + let proxy = ArrayProxy.extend({ arrangedContentDidChange() { equal(this.get('arrangedContent.length'), expectedLength, 'hook should be invoked after array has changed'); callCount++; @@ -85,12 +85,10 @@ QUnit.test('The `arrangedContentDidChange` method is invoked after `content` is }); QUnit.test('The ArrayProxy doesn\'t explode when assigned a destroyed object', function() { - var proxy1 = ArrayProxy.create(); - var proxy2 = ArrayProxy.create(); + let proxy1 = ArrayProxy.create(); + let proxy2 = ArrayProxy.create(); - run(function() { - proxy1.destroy(); - }); + run(() => proxy1.destroy()); set(proxy2, 'content', proxy1); diff --git a/packages/ember-runtime/tests/system/array_proxy/content_update_test.js b/packages/ember-runtime/tests/system/array_proxy/content_update_test.js index c8a269bbde6..7b908b6af1d 100644 --- a/packages/ember-runtime/tests/system/array_proxy/content_update_test.js +++ b/packages/ember-runtime/tests/system/array_proxy/content_update_test.js @@ -5,10 +5,8 @@ import { A as emberA } from 'ember-runtime/system/native_array'; QUnit.module('Ember.ArrayProxy - content update'); QUnit.test('The `contentArrayDidChange` method is invoked after `content` is updated.', function() { - var proxy; - var observerCalled = false; - - proxy = ArrayProxy.extend({ + let observerCalled = false; + let proxy = ArrayProxy.extend({ arrangedContent: computed('content', function(key) { return emberA(this.get('content').slice()); }), diff --git a/packages/ember-runtime/tests/system/array_proxy/length_test.js b/packages/ember-runtime/tests/system/array_proxy/length_test.js index 669769cbb1e..1afb5c01518 100644 --- a/packages/ember-runtime/tests/system/array_proxy/length_test.js +++ b/packages/ember-runtime/tests/system/array_proxy/length_test.js @@ -7,33 +7,19 @@ import { A as a } from 'ember-runtime/system/native_array'; QUnit.module('Ember.ArrayProxy - content change (length)'); QUnit.test('array proxy + aliasedProperty complex test', function() { - var aCalled, bCalled, cCalled, dCalled, eCalled; + let aCalled, bCalled, cCalled, dCalled, eCalled; aCalled = bCalled = cCalled = dCalled = eCalled = 0; - var obj = Object.extend({ + let obj = Object.extend({ colors: computed.reads('model'), length: computed.reads('colors.length'), - a: observer('length', function() { - aCalled++; - }), - - b: observer('colors.length', function() { - bCalled++; - }), - - c: observer('colors.content.length', function() { - cCalled++; - }), - - d: observer('colors.[]', function() { - dCalled++; - }), - - e: observer('colors.content.[]', function() { - eCalled++; - }) + a: observer('length', () => aCalled++), + b: observer('colors.length', () => bCalled++), + c: observer('colors.content.length', () => cCalled++), + d: observer('colors.[]', () => dCalled++), + e: observer('colors.content.[]', () => eCalled++) }).create(); obj.set('model', ArrayProxy.create({ diff --git a/packages/ember-runtime/tests/system/array_proxy/suite_test.js b/packages/ember-runtime/tests/system/array_proxy/suite_test.js index 7186acbdb26..029a1be62d4 100644 --- a/packages/ember-runtime/tests/system/array_proxy/suite_test.js +++ b/packages/ember-runtime/tests/system/array_proxy/suite_test.js @@ -4,11 +4,10 @@ import { get } from 'ember-metal/property_get'; import { A as emberA } from 'ember-runtime/system/native_array'; MutableArrayTests.extend({ - name: 'Ember.ArrayProxy', newObject(ary) { - var ret = ary ? ary.slice() : this.newFixture(3); + let ret = ary ? ary.slice() : this.newFixture(3); return ArrayProxy.create({ content: emberA(ret) }); }, @@ -19,5 +18,4 @@ MutableArrayTests.extend({ toArray(obj) { return obj.toArray ? obj.toArray() : obj.slice(); } - }).run(); diff --git a/packages/ember-runtime/tests/system/core_object_test.js b/packages/ember-runtime/tests/system/core_object_test.js index 703bcc5302a..be24a28d289 100644 --- a/packages/ember-runtime/tests/system/core_object_test.js +++ b/packages/ember-runtime/tests/system/core_object_test.js @@ -4,7 +4,7 @@ import CoreObject from 'ember-runtime/system/core_object'; QUnit.module('Ember.CoreObject'); QUnit.test('works with new (one arg)', function() { - var obj = new CoreObject({ + let obj = new CoreObject({ firstName: 'Stef', lastName: 'Penner' }); @@ -14,7 +14,7 @@ QUnit.test('works with new (one arg)', function() { }); QUnit.test('works with new (> 1 arg)', function() { - var obj = new CoreObject({ + let obj = new CoreObject({ firstName: 'Stef', lastName: 'Penner' }, { @@ -28,7 +28,7 @@ QUnit.test('works with new (> 1 arg)', function() { }); QUnit.test('toString should be not be added as a property when calling toString()', function() { - var obj = new CoreObject({ + let obj = new CoreObject({ firstName: 'Foo', lastName: 'Bar' }); diff --git a/packages/ember-runtime/tests/system/lazy_load_test.js b/packages/ember-runtime/tests/system/lazy_load_test.js index 31f6fd4d4e2..25085df7709 100644 --- a/packages/ember-runtime/tests/system/lazy_load_test.js +++ b/packages/ember-runtime/tests/system/lazy_load_test.js @@ -4,7 +4,7 @@ import {onLoad, runLoadHooks} from 'ember-runtime/system/lazy_load'; QUnit.module('Lazy Loading'); QUnit.test('if a load hook is registered, it is executed when runLoadHooks are exected', function() { - var count = 0; + let count = 0; run(function() { onLoad('__test_hook__', function(object) { @@ -20,22 +20,16 @@ QUnit.test('if a load hook is registered, it is executed when runLoadHooks are e }); QUnit.test('if runLoadHooks was already run, it executes newly added hooks immediately', function() { - var count = 0; - run(function() { - onLoad('__test_hook__', function(object) { - count += object; - }); + let count = 0; + run(() => { + onLoad('__test_hook__', object => count += object); }); - run(function() { - runLoadHooks('__test_hook__', 1); - }); + run(() => runLoadHooks('__test_hook__', 1)); count = 0; - run(function() { - onLoad('__test_hook__', function(object) { - count += object; - }); + run(() => { + onLoad('__test_hook__', object => count += object); }); equal(count, 1, 'the original object was passed into the load hook'); @@ -45,7 +39,7 @@ QUnit.test('hooks in ENV.EMBER_LOAD_HOOKS[\'hookName\'] get executed', function( // Note that the necessary code to perform this test is run before // the Ember lib is loaded in tests/index.html - run(function() { + run(() => { runLoadHooks('__before_ember_test_hook__', 1); }); @@ -54,14 +48,14 @@ QUnit.test('hooks in ENV.EMBER_LOAD_HOOKS[\'hookName\'] get executed', function( if (typeof window === 'object' && typeof window.dispatchEvent === 'function' && typeof CustomEvent === 'function') { QUnit.test('load hooks trigger a custom event', function() { - var eventObject = 'super duper awesome events'; + let eventObject = 'super duper awesome events'; window.addEventListener('__test_hook_for_events__', function(e) { ok(true, 'custom event was fired'); equal(e.detail, eventObject, 'event details are provided properly'); }); - run(function() { + run(() => { runLoadHooks('__test_hook_for_events__', eventObject); }); }); diff --git a/packages/ember-runtime/tests/system/namespace/base_test.js b/packages/ember-runtime/tests/system/namespace/base_test.js index ec31b448bd7..b9b140e6a83 100644 --- a/packages/ember-runtime/tests/system/namespace/base_test.js +++ b/packages/ember-runtime/tests/system/namespace/base_test.js @@ -18,7 +18,7 @@ QUnit.module('Namespace', { teardown() { setNamespaceSearchDisabled(false); - for (var prop in lookup) { + for (let prop in lookup) { if (lookup[prop]) { run(lookup[prop], 'destroy'); } } @@ -35,22 +35,22 @@ QUnit.test('Namespace should be duck typed', function() { }); QUnit.test('Namespace is found and named', function() { - var nsA = lookup.NamespaceA = Namespace.create(); + let nsA = lookup.NamespaceA = Namespace.create(); equal(nsA.toString(), 'NamespaceA', 'namespaces should have a name if they are on lookup'); - var nsB = lookup.NamespaceB = Namespace.create(); + let nsB = lookup.NamespaceB = Namespace.create(); equal(nsB.toString(), 'NamespaceB', 'namespaces work if created after the first namespace processing pass'); }); QUnit.test('Classes under an Namespace are properly named', function() { - var nsA = lookup.NamespaceA = Namespace.create(); + let nsA = lookup.NamespaceA = Namespace.create(); nsA.Foo = EmberObject.extend(); equal(nsA.Foo.toString(), 'NamespaceA.Foo', 'Classes pick up their parent namespace'); nsA.Bar = EmberObject.extend(); equal(nsA.Bar.toString(), 'NamespaceA.Bar', 'New Classes get the naming treatment too'); - var nsB = lookup.NamespaceB = Namespace.create(); + let nsB = lookup.NamespaceB = Namespace.create(); nsB.Foo = EmberObject.extend(); equal(nsB.Foo.toString(), 'NamespaceB.Foo', 'Classes in new namespaces get the naming treatment'); }); @@ -62,16 +62,16 @@ QUnit.test('Classes under an Namespace are properly named', function() { //}); QUnit.test('Lowercase namespaces are no longer supported', function() { - var nsC = lookup.namespaceC = Namespace.create(); + let nsC = lookup.namespaceC = Namespace.create(); equal(nsC.toString(), undefined); }); QUnit.test('A namespace can be assigned a custom name', function() { - var nsA = Namespace.create({ + let nsA = Namespace.create({ name: 'NamespaceA' }); - var nsB = lookup.NamespaceB = Namespace.create({ + let nsB = lookup.NamespaceB = Namespace.create({ name: 'CustomNamespaceB' }); @@ -85,7 +85,7 @@ QUnit.test('A namespace can be assigned a custom name', function() { QUnit.test('Calling namespace.nameClasses() eagerly names all classes', function() { setNamespaceSearchDisabled(true); - var namespace = lookup.NS = Namespace.create(); + let namespace = lookup.NS = Namespace.create(); namespace.ClassA = EmberObject.extend(); namespace.ClassB = EmberObject.extend(); @@ -97,9 +97,9 @@ QUnit.test('Calling namespace.nameClasses() eagerly names all classes', function }); QUnit.test('A namespace can be looked up by its name', function() { - var NS = lookup.NS = Namespace.create(); - var UI = lookup.UI = Namespace.create(); - var CF = lookup.CF = Namespace.create(); + let NS = lookup.NS = Namespace.create(); + let UI = lookup.UI = Namespace.create(); + let CF = lookup.CF = Namespace.create(); equal(Namespace.byName('NS'), NS); equal(Namespace.byName('UI'), UI); @@ -107,21 +107,21 @@ QUnit.test('A namespace can be looked up by its name', function() { }); QUnit.test('A nested namespace can be looked up by its name', function() { - var UI = lookup.UI = Namespace.create(); + let UI = lookup.UI = Namespace.create(); UI.Nav = Namespace.create(); equal(Namespace.byName('UI.Nav'), UI.Nav); }); QUnit.test('Destroying a namespace before caching lookup removes it from the list of namespaces', function() { - var CF = lookup.CF = Namespace.create(); + let CF = lookup.CF = Namespace.create(); run(CF, 'destroy'); equal(Namespace.byName('CF'), undefined, 'namespace can not be found after destroyed'); }); QUnit.test('Destroying a namespace after looking up removes it from the list of namespaces', function() { - var CF = lookup.CF = Namespace.create(); + let CF = lookup.CF = Namespace.create(); equal(Namespace.byName('CF'), CF, 'precondition - namespace can be looked up by name'); diff --git a/packages/ember-runtime/tests/system/native_array/copyable_suite_test.js b/packages/ember-runtime/tests/system/native_array/copyable_suite_test.js index ae8f6977aa4..791cdf7d778 100644 --- a/packages/ember-runtime/tests/system/native_array/copyable_suite_test.js +++ b/packages/ember-runtime/tests/system/native_array/copyable_suite_test.js @@ -31,9 +31,9 @@ CopyableTests.extend({ QUnit.module('NativeArray Copyable'); QUnit.test('deep copy is respected', function() { - var array = emberA([{ id: 1 }, { id: 2 }, { id: 3 }]); + let array = emberA([{ id: 1 }, { id: 2 }, { id: 3 }]); - var copiedArray = array.copy(true); + let copiedArray = array.copy(true); deepEqual(copiedArray, array, 'copied array is equivalent'); ok(copiedArray[0] !== array[0], 'objects inside should be unique'); diff --git a/packages/ember-runtime/tests/system/native_array/suite_test.js b/packages/ember-runtime/tests/system/native_array/suite_test.js index 617c046b813..931d6df197b 100644 --- a/packages/ember-runtime/tests/system/native_array/suite_test.js +++ b/packages/ember-runtime/tests/system/native_array/suite_test.js @@ -2,7 +2,6 @@ import { A as emberA } from 'ember-runtime/system/native_array'; import MutableArrayTests from 'ember-runtime/tests/suites/mutable_array'; MutableArrayTests.extend({ - name: 'Native Array', newObject(ary) { @@ -16,5 +15,4 @@ MutableArrayTests.extend({ toArray(obj) { return obj.slice(); // make a copy. } - }).run(); diff --git a/packages/ember-runtime/tests/system/object/computed_test.js b/packages/ember-runtime/tests/system/object/computed_test.js index 91ae1e59787..66e5a62c16a 100644 --- a/packages/ember-runtime/tests/system/object/computed_test.js +++ b/packages/ember-runtime/tests/system/object/computed_test.js @@ -10,7 +10,7 @@ function K() { return this; } QUnit.module('EmberObject computed property'); testWithDefault('computed property on instance', function(get, set) { - var MyClass = EmberObject.extend({ + let MyClass = EmberObject.extend({ foo: computed(function() { return 'FOO'; }) }); @@ -19,11 +19,11 @@ testWithDefault('computed property on instance', function(get, set) { testWithDefault('computed property on subclass', function(get, set) { - var MyClass = EmberObject.extend({ + let MyClass = EmberObject.extend({ foo: computed(function() { return 'FOO'; }) }); - var Subclass = MyClass.extend({ + let Subclass = MyClass.extend({ foo: computed(function() { return 'BAR'; }) }); @@ -32,11 +32,11 @@ testWithDefault('computed property on subclass', function(get, set) { testWithDefault('replacing computed property with regular val', function(get, set) { - var MyClass = EmberObject.extend({ + let MyClass = EmberObject.extend({ foo: computed(function() { return 'FOO'; }) }); - var Subclass = MyClass.extend({ + let Subclass = MyClass.extend({ foo: 'BAR' }); @@ -44,7 +44,7 @@ testWithDefault('replacing computed property with regular val', function(get, se }); testWithDefault('complex depndent keys', function(get, set) { - var MyClass = EmberObject.extend({ + let MyClass = EmberObject.extend({ init() { this._super(...arguments); @@ -60,12 +60,12 @@ testWithDefault('complex depndent keys', function(get, set) { }); - var Subclass = MyClass.extend({ + let Subclass = MyClass.extend({ count: 20 }); - var obj1 = new MyClass(); - var obj2 = new Subclass(); + let obj1 = new MyClass(); + let obj2 = new Subclass(); equal(get(obj1, 'foo'), 'BIFF 1'); equal(get(obj2, 'foo'), 'BIFF 21'); @@ -82,7 +82,7 @@ testWithDefault('complex depndent keys', function(get, set) { }); testWithDefault('complex dependent keys changing complex dependent keys', function(get, set) { - var MyClass = EmberObject.extend({ + let MyClass = EmberObject.extend({ init() { this._super(...arguments); set(this, 'bar', { baz: 'BIFF' }); @@ -96,7 +96,7 @@ testWithDefault('complex dependent keys changing complex dependent keys', functi }).property('bar.baz') }); - var Subclass = MyClass.extend({ + let Subclass = MyClass.extend({ init() { this._super(...arguments); set(this, 'bar2', { baz: 'BIFF2' }); @@ -110,7 +110,7 @@ testWithDefault('complex dependent keys changing complex dependent keys', functi }).property('bar2.baz') }); - var obj2 = new Subclass(); + let obj2 = new Subclass(); equal(get(obj2, 'foo'), 'BIFF2 1'); @@ -122,14 +122,14 @@ testWithDefault('complex dependent keys changing complex dependent keys', functi }); QUnit.test('can retrieve metadata for a computed property', function() { - var MyClass = EmberObject.extend({ + let MyClass = EmberObject.extend({ computedProperty: computed(function() { }).meta({ key: 'keyValue' }) }); equal(emberGet(MyClass.metaForProperty('computedProperty'), 'key'), 'keyValue', 'metadata saved on the computed property can be retrieved'); - var ClassWithNoMetadata = EmberObject.extend({ + let ClassWithNoMetadata = EmberObject.extend({ computedProperty: computed(function() { }).volatile(), @@ -148,7 +148,7 @@ QUnit.test('can retrieve metadata for a computed property', function() { }); QUnit.test('can iterate over a list of computed properties for a class', function() { - var MyClass = EmberObject.extend({ + let MyClass = EmberObject.extend({ foo: computed(function() {}), fooDidChange: observer('foo', function() {}), @@ -158,7 +158,7 @@ QUnit.test('can iterate over a list of computed properties for a class', functio qux: alias('foo') }); - var SubClass = MyClass.extend({ + let SubClass = MyClass.extend({ baz: computed(function() {}) }); @@ -166,7 +166,7 @@ QUnit.test('can iterate over a list of computed properties for a class', functio bat: computed(function() {}).meta({ iAmBat: true }) }); - var list = []; + let list = []; MyClass.eachComputedProperty(function(name) { list.push(name); @@ -190,7 +190,7 @@ QUnit.test('can iterate over a list of computed properties for a class', functio }); QUnit.test('list of properties updates when an additional property is added (such cache busting)', function() { - var MyClass = EmberObject.extend({ + let MyClass = EmberObject.extend({ foo: computed(K), fooDidChange: observer('foo', function() {}), @@ -198,7 +198,7 @@ QUnit.test('list of properties updates when an additional property is added (suc bar: computed(K) }); - var list = []; + let list = []; MyClass.eachComputedProperty(function(name) { list.push(name); @@ -228,13 +228,13 @@ QUnit.test('Calling _super in call outside the immediate function of a CP getter }); } - var MyClass = EmberObject.extend({ + let MyClass = EmberObject.extend({ foo: computed(function() { return 'FOO'; }) }); - var SubClass = MyClass.extend({ + let SubClass = MyClass.extend({ foo: macro(function() { return this._super(); }) @@ -250,13 +250,13 @@ QUnit.test('Calling _super in apply outside the immediate function of a CP gette }); } - var MyClass = EmberObject.extend({ + let MyClass = EmberObject.extend({ foo: computed(function() { return 'FOO'; }) }); - var SubClass = MyClass.extend({ + let SubClass = MyClass.extend({ foo: macro(function() { return this._super(); }) diff --git a/packages/ember-runtime/tests/system/object/create_test.js b/packages/ember-runtime/tests/system/object/create_test.js index beee399bfc9..79dc48dc4c9 100644 --- a/packages/ember-runtime/tests/system/object/create_test.js +++ b/packages/ember-runtime/tests/system/object/create_test.js @@ -7,38 +7,38 @@ import EmberObject from 'ember-runtime/system/object'; QUnit.module('EmberObject.create', {}); QUnit.test('simple properties are set', function() { - var o = EmberObject.create({ ohai: 'there' }); + let o = EmberObject.create({ ohai: 'there' }); equal(o.get('ohai'), 'there'); }); QUnit.test('calls computed property setters', function() { - var MyClass = EmberObject.extend({ + let MyClass = EmberObject.extend({ foo: computed({ - get: function() { + get() { return 'this is not the value you\'re looking for'; }, - set: function(key, value) { + set(key, value) { return value; } }) }); - var o = MyClass.create({ foo: 'bar' }); + let o = MyClass.create({ foo: 'bar' }); equal(o.get('foo'), 'bar'); }); if (isEnabled('mandatory-setter')) { QUnit.test('sets up mandatory setters for watched simple properties', function() { - var MyClass = EmberObject.extend({ + let MyClass = EmberObject.extend({ foo: null, bar: null, fooDidChange: observer('foo', function() {}) }); - var o = MyClass.create({ foo: 'bar', bar: 'baz' }); + let o = MyClass.create({ foo: 'bar', bar: 'baz' }); equal(o.get('foo'), 'bar'); - var descriptor = Object.getOwnPropertyDescriptor(o, 'foo'); + let descriptor = Object.getOwnPropertyDescriptor(o, 'foo'); ok(descriptor.set, 'Mandatory setter was setup'); descriptor = Object.getOwnPropertyDescriptor(o, 'bar'); @@ -63,9 +63,9 @@ QUnit.test('allows bindings to be defined', function() { }); QUnit.test('calls setUnknownProperty if defined', function() { - var setUnknownPropertyCalled = false; + let setUnknownPropertyCalled = false; - var MyClass = EmberObject.extend({ + let MyClass = EmberObject.extend({ setUnknownProperty(key, value) { setUnknownPropertyCalled = true; } @@ -94,7 +94,7 @@ QUnit.test('throws if you try to call _super in a method', function() { }); QUnit.test('throws if you try to \'mixin\' a definition', function() { - var myMixin = Mixin.create({ + let myMixin = Mixin.create({ adder(arg1, arg2) { return arg1 + arg2; } @@ -107,7 +107,7 @@ QUnit.test('throws if you try to \'mixin\' a definition', function() { // This test is for IE8. QUnit.test('property name is the same as own prototype property', function() { - var MyClass = EmberObject.extend({ + let MyClass = EmberObject.extend({ toString() { return 'MyClass'; } }); @@ -115,27 +115,25 @@ QUnit.test('property name is the same as own prototype property', function() { }); QUnit.test('inherits properties from passed in EmberObject', function() { - var baseObj = EmberObject.create({ foo: 'bar' }); - var secondaryObj = EmberObject.create(baseObj); + let baseObj = EmberObject.create({ foo: 'bar' }); + let secondaryObj = EmberObject.create(baseObj); equal(secondaryObj.foo, baseObj.foo, 'Em.O.create inherits properties from EmberObject parameter'); }); QUnit.test('throws if you try to pass anything a string as a parameter', function() { - var expected = 'EmberObject.create only accepts an objects.'; + let expected = 'EmberObject.create only accepts an objects.'; - throws(function() { - EmberObject.create('some-string'); - }, expected); + throws(() => EmberObject.create('some-string'), expected); }); QUnit.test('EmberObject.create can take undefined as a parameter', function() { - var o = EmberObject.create(undefined); + let o = EmberObject.create(undefined); deepEqual(EmberObject.create(), o); }); QUnit.test('EmberObject.create can take null as a parameter', function() { - var o = EmberObject.create(null); + let o = EmberObject.create(null); deepEqual(EmberObject.create(), o); }); diff --git a/packages/ember-runtime/tests/system/object/destroy_test.js b/packages/ember-runtime/tests/system/object/destroy_test.js index 08c86167b15..21d7f68e91e 100644 --- a/packages/ember-runtime/tests/system/object/destroy_test.js +++ b/packages/ember-runtime/tests/system/object/destroy_test.js @@ -13,10 +13,10 @@ import { peekMeta } from 'ember-metal/meta'; QUnit.module('ember-runtime/system/object/destroy_test'); testBoth('should schedule objects to be destroyed at the end of the run loop', function(get, set) { - var obj = EmberObject.create(); - var meta; + let obj = EmberObject.create(); + let meta; - run(function() { + run(() => { obj.destroy(); meta = peekMeta(obj); ok(meta, 'meta is not destroyed immediately'); @@ -34,25 +34,21 @@ if (isEnabled('mandatory-setter')) { // a destroyed object removes meta but leaves the accessor // that looks it up QUnit.test('should raise an exception when modifying watched properties on a destroyed object', function() { - var obj = EmberObject.extend({ + let obj = EmberObject.extend({ fooDidChange: observer('foo', function() { }) }).create({ foo: 'bar' }); - run(function() { - obj.destroy(); - }); + run(() => obj.destroy()); - throws(function() { - set(obj, 'foo', 'baz'); - }, Error, 'raises an exception'); + throws(() => set(obj, 'foo', 'baz'), Error, 'raises an exception'); }); } QUnit.test('observers should not fire after an object has been destroyed', function() { - var count = 0; - var obj = EmberObject.extend({ + let count = 0; + let obj = EmberObject.extend({ fooDidChange: observer('foo', function() { count++; }) @@ -62,7 +58,7 @@ QUnit.test('observers should not fire after an object has been destroyed', funct equal(count, 1, 'observer was fired once'); - run(function() { + run(() => { beginPropertyChanges(); obj.set('foo', 'quux'); obj.destroy(); @@ -73,12 +69,12 @@ QUnit.test('observers should not fire after an object has been destroyed', funct }); QUnit.test('destroyed objects should not see each others changes during teardown but a long lived object should', function () { - var shouldChange = 0; - var shouldNotChange = 0; + let shouldChange = 0; + let shouldNotChange = 0; - var objs = {}; + let objs = {}; - var A = EmberObject.extend({ + let A = EmberObject.extend({ objs: objs, isAlive: true, willDestroy() { @@ -92,7 +88,7 @@ QUnit.test('destroyed objects should not see each others changes during teardown }) }); - var B = EmberObject.extend({ + let B = EmberObject.extend({ objs: objs, isAlive: true, willDestroy() { @@ -106,7 +102,7 @@ QUnit.test('destroyed objects should not see each others changes during teardown }) }); - var C = EmberObject.extend({ + let C = EmberObject.extend({ objs: objs, isAlive: true, willDestroy() { @@ -120,7 +116,7 @@ QUnit.test('destroyed objects should not see each others changes during teardown }) }); - var LongLivedObject = EmberObject.extend({ + let LongLivedObject = EmberObject.extend({ objs: objs, isAliveDidChange: observer('objs.a.isAlive', function () { shouldChange++; @@ -135,9 +131,9 @@ QUnit.test('destroyed objects should not see each others changes during teardown new LongLivedObject(); - run(function () { - var keys = Object.keys(objs); - for (var i = 0; i < keys.length; i++) { + run(() => { + let keys = Object.keys(objs); + for (let i = 0; i < keys.length; i++) { objs[keys[i]].destroy(); } }); @@ -147,19 +143,19 @@ QUnit.test('destroyed objects should not see each others changes during teardown }); QUnit.test('bindings should be synced when are updated in the willDestroy hook', function() { - var bar = EmberObject.create({ + let bar = EmberObject.create({ value: false, willDestroy() { this.set('value', true); } }); - var foo = EmberObject.create({ + let foo = EmberObject.create({ value: null, bar: bar }); - run(function() { + run(() => { let deprecationMessage = '`Ember.Binding` is deprecated. Consider' + ' using an `alias` computed property instead.'; @@ -170,9 +166,7 @@ QUnit.test('bindings should be synced when are updated in the willDestroy hook', ok(bar.get('value') === false, 'the initial value has been bound'); - run(function() { - bar.destroy(); - }); + run(() => bar.destroy()); ok(foo.get('value'), 'foo is synced when the binding is updated in the willDestroy hook'); }); diff --git a/packages/ember-runtime/tests/system/object/detectInstance_test.js b/packages/ember-runtime/tests/system/object/detectInstance_test.js index d6e43e7b079..0ab64e83cfd 100644 --- a/packages/ember-runtime/tests/system/object/detectInstance_test.js +++ b/packages/ember-runtime/tests/system/object/detectInstance_test.js @@ -3,14 +3,14 @@ import EmberObject from 'ember-runtime/system/object'; QUnit.module('system/object/detectInstance'); QUnit.test('detectInstance detects instances correctly', function() { - var A = EmberObject.extend(); - var B = A.extend(); - var C = A.extend(); + let A = EmberObject.extend(); + let B = A.extend(); + let C = A.extend(); - var o = EmberObject.create(); - var a = A.create(); - var b = B.create(); - var c = C.create(); + let o = EmberObject.create(); + let a = A.create(); + let b = B.create(); + let c = C.create(); ok(EmberObject.detectInstance(o), 'o is an instance of EmberObject'); ok(EmberObject.detectInstance(a), 'a is an instance of EmberObject'); diff --git a/packages/ember-runtime/tests/system/object/detect_test.js b/packages/ember-runtime/tests/system/object/detect_test.js index 51df823f38e..05c69d6ded0 100644 --- a/packages/ember-runtime/tests/system/object/detect_test.js +++ b/packages/ember-runtime/tests/system/object/detect_test.js @@ -3,9 +3,9 @@ import EmberObject from 'ember-runtime/system/object'; QUnit.module('system/object/detect'); QUnit.test('detect detects classes correctly', function() { - var A = EmberObject.extend(); - var B = A.extend(); - var C = A.extend(); + let A = EmberObject.extend(); + let B = A.extend(); + let C = A.extend(); ok(EmberObject.detect(EmberObject), 'EmberObject is an EmberObject class'); ok(EmberObject.detect(A), 'A is an EmberObject class'); diff --git a/packages/ember-runtime/tests/system/object/events_test.js b/packages/ember-runtime/tests/system/object/events_test.js index ff9884c7ca9..31e697c8f53 100644 --- a/packages/ember-runtime/tests/system/object/events_test.js +++ b/packages/ember-runtime/tests/system/object/events_test.js @@ -4,10 +4,10 @@ import Evented from 'ember-runtime/mixins/evented'; QUnit.module('Object events'); QUnit.test('a listener can be added to an object', function() { - var count = 0; - var F = function() { count++; }; + let count = 0; + let F = function() { count++; }; - var obj = EmberObject.extend(Evented).create(); + let obj = EmberObject.extend(Evented).create(); obj.on('event!', F); obj.trigger('event!'); @@ -20,10 +20,10 @@ QUnit.test('a listener can be added to an object', function() { }); QUnit.test('a listener can be added and removed automatically the first time it is triggered', function() { - var count = 0; - var F = function() { count++; }; + let count = 0; + let F = function() { count++; }; - var obj = EmberObject.extend(Evented).create(); + let obj = EmberObject.extend(Evented).create(); obj.one('event!', F); obj.trigger('event!'); @@ -36,9 +36,9 @@ QUnit.test('a listener can be added and removed automatically the first time it }); QUnit.test('triggering an event can have arguments', function() { - var self, args; + let self, args; - var obj = EmberObject.extend(Evented).create(); + let obj = EmberObject.extend(Evented).create(); obj.on('event!', function() { args = [].slice.call(arguments); @@ -52,10 +52,10 @@ QUnit.test('triggering an event can have arguments', function() { }); QUnit.test('a listener can be added and removed automatically and have arguments', function() { - var self, args; - var count = 0; + let self, args; + let count = 0; - var obj = EmberObject.extend(Evented).create(); + let obj = EmberObject.extend(Evented).create(); obj.one('event!', function() { args = [].slice.call(arguments); @@ -77,10 +77,10 @@ QUnit.test('a listener can be added and removed automatically and have arguments }); QUnit.test('binding an event can specify a different target', function() { - var self, args; + let self, args; - var obj = EmberObject.extend(Evented).create(); - var target = {}; + let obj = EmberObject.extend(Evented).create(); + let target = {}; obj.on('event!', target, function() { args = [].slice.call(arguments); @@ -94,11 +94,11 @@ QUnit.test('binding an event can specify a different target', function() { }); QUnit.test('a listener registered with one can take method as string and can be added with different target', function() { - var count = 0; - var target = {}; + let count = 0; + let target = {}; target.fn = function() { count++; }; - var obj = EmberObject.extend(Evented).create(); + let obj = EmberObject.extend(Evented).create(); obj.one('event!', target, 'fn'); obj.trigger('event!'); @@ -111,10 +111,10 @@ QUnit.test('a listener registered with one can take method as string and can be }); QUnit.test('a listener registered with one can be removed with off', function() { - var obj = EmberObject.extend(Evented, { + let obj = EmberObject.extend(Evented, { F() {} }).create(); - var F = function() {}; + let F = function() {}; obj.one('event!', F); obj.one('event!', obj, 'F'); @@ -128,10 +128,10 @@ QUnit.test('a listener registered with one can be removed with off', function() }); QUnit.test('adding and removing listeners should be chainable', function() { - var obj = EmberObject.extend(Evented).create(); - var F = function() {}; + let obj = EmberObject.extend(Evented).create(); + let F = function() {}; - var ret = obj.on('event!', F); + let ret = obj.on('event!', F); equal(ret, obj, '#on returns self'); ret = obj.off('event!', F); diff --git a/packages/ember-runtime/tests/system/object/extend_test.js b/packages/ember-runtime/tests/system/object/extend_test.js index 209ec29aad5..054baa211aa 100644 --- a/packages/ember-runtime/tests/system/object/extend_test.js +++ b/packages/ember-runtime/tests/system/object/extend_test.js @@ -4,22 +4,22 @@ import EmberObject from 'ember-runtime/system/object'; QUnit.module('EmberObject.extend'); QUnit.test('Basic extend', function() { - var SomeClass = EmberObject.extend({ foo: 'BAR' }); + let SomeClass = EmberObject.extend({ foo: 'BAR' }); ok(SomeClass.isClass, 'A class has isClass of true'); - var obj = new SomeClass(); + let obj = new SomeClass(); equal(obj.foo, 'BAR'); }); QUnit.test('Sub-subclass', function() { - var SomeClass = EmberObject.extend({ foo: 'BAR' }); - var AnotherClass = SomeClass.extend({ bar: 'FOO' }); - var obj = new AnotherClass(); + let SomeClass = EmberObject.extend({ foo: 'BAR' }); + let AnotherClass = SomeClass.extend({ bar: 'FOO' }); + let obj = new AnotherClass(); equal(obj.foo, 'BAR'); equal(obj.bar, 'FOO'); }); QUnit.test('Overriding a method several layers deep', function() { - var SomeClass = EmberObject.extend({ + let SomeClass = EmberObject.extend({ fooCnt: 0, foo() { this.fooCnt++; }, @@ -27,7 +27,7 @@ QUnit.test('Overriding a method several layers deep', function() { bar() { this.barCnt++; } }); - var AnotherClass = SomeClass.extend({ + let AnotherClass = SomeClass.extend({ barCnt: 0, bar() { this.barCnt++; @@ -35,7 +35,7 @@ QUnit.test('Overriding a method several layers deep', function() { } }); - var FinalClass = AnotherClass.extend({ + let FinalClass = AnotherClass.extend({ fooCnt: 0, foo() { this.fooCnt++; @@ -43,7 +43,7 @@ QUnit.test('Overriding a method several layers deep', function() { } }); - var obj = new FinalClass(); + let obj = new FinalClass(); obj.foo(); obj.bar(); equal(obj.fooCnt, 2, 'should invoke both'); @@ -64,30 +64,30 @@ QUnit.test('Overriding a method several layers deep', function() { }); QUnit.test('With concatenatedProperties', function() { - var SomeClass = EmberObject.extend({ things: 'foo', concatenatedProperties: ['things'] }); - var AnotherClass = SomeClass.extend({ things: 'bar' }); - var YetAnotherClass = SomeClass.extend({ things: 'baz' }); - var some = new SomeClass(); - var another = new AnotherClass(); - var yetAnother = new YetAnotherClass(); + let SomeClass = EmberObject.extend({ things: 'foo', concatenatedProperties: ['things'] }); + let AnotherClass = SomeClass.extend({ things: 'bar' }); + let YetAnotherClass = SomeClass.extend({ things: 'baz' }); + let some = new SomeClass(); + let another = new AnotherClass(); + let yetAnother = new YetAnotherClass(); deepEqual(some.get('things'), ['foo'], 'base class should have just its value'); deepEqual(another.get('things'), ['foo', 'bar'], 'subclass should have base class\' and its own'); deepEqual(yetAnother.get('things'), ['foo', 'baz'], 'subclass should have base class\' and its own'); }); QUnit.test('With concatenatedProperties class properties', function() { - var SomeClass = EmberObject.extend(); + let SomeClass = EmberObject.extend(); SomeClass.reopenClass({ concatenatedProperties: ['things'], things: 'foo' }); - var AnotherClass = SomeClass.extend(); + let AnotherClass = SomeClass.extend(); AnotherClass.reopenClass({ things: 'bar' }); - var YetAnotherClass = SomeClass.extend(); + let YetAnotherClass = SomeClass.extend(); YetAnotherClass.reopenClass({ things: 'baz' }); - var some = new SomeClass(); - var another = new AnotherClass(); - var yetAnother = new YetAnotherClass(); + let some = new SomeClass(); + let another = new AnotherClass(); + let yetAnother = new YetAnotherClass(); deepEqual(get(some.constructor, 'things'), ['foo'], 'base class should have just its value'); deepEqual(get(another.constructor, 'things'), ['foo', 'bar'], 'subclass should have base class\' and its own'); deepEqual(get(yetAnother.constructor, 'things'), ['foo', 'baz'], 'subclass should have base class\' and its own'); diff --git a/packages/ember-runtime/tests/system/object/observer_test.js b/packages/ember-runtime/tests/system/object/observer_test.js index 90cdb6ab7a2..10103f7c80b 100644 --- a/packages/ember-runtime/tests/system/object/observer_test.js +++ b/packages/ember-runtime/tests/system/object/observer_test.js @@ -6,17 +6,15 @@ import EmberObject from 'ember-runtime/system/object'; QUnit.module('EmberObject observer'); testBoth('observer on class', function(get, set) { - var MyClass = EmberObject.extend({ - + let MyClass = EmberObject.extend({ count: 0, foo: observer('bar', function() { set(this, 'count', get(this, 'count') + 1); }) - }); - var obj = new MyClass(); + let obj = new MyClass(); equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); set(obj, 'bar', 'BAZ'); @@ -24,23 +22,21 @@ testBoth('observer on class', function(get, set) { }); testBoth('observer on subclass', function(get, set) { - var MyClass = EmberObject.extend({ - + let MyClass = EmberObject.extend({ count: 0, foo: observer('bar', function() { set(this, 'count', get(this, 'count') + 1); }) - }); - var Subclass = MyClass.extend({ + let Subclass = MyClass.extend({ foo: observer('baz', function() { set(this, 'count', get(this, 'count') + 1); }) }); - var obj = new Subclass(); + let obj = new Subclass(); equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); set(obj, 'bar', 'BAZ'); @@ -51,7 +47,7 @@ testBoth('observer on subclass', function(get, set) { }); testBoth('observer on instance', function(get, set) { - var obj = EmberObject.extend({ + let obj = EmberObject.extend({ foo: observer('bar', function() { set(this, 'count', get(this, 'count') + 1); }) @@ -66,7 +62,7 @@ testBoth('observer on instance', function(get, set) { }); testBoth('observer on instance overriding class', function(get, set) { - var MyClass = EmberObject.extend({ + let MyClass = EmberObject.extend({ count: 0, foo: observer('bar', function() { @@ -74,7 +70,7 @@ testBoth('observer on instance overriding class', function(get, set) { }) }); - var obj = MyClass.extend({ + let obj = MyClass.extend({ foo: observer('baz', function() { // <-- change property we observe set(this, 'count', get(this, 'count') + 1); }) @@ -90,7 +86,7 @@ testBoth('observer on instance overriding class', function(get, set) { }); testBoth('observer should not fire after being destroyed', function(get, set) { - var obj = EmberObject.extend({ + let obj = EmberObject.extend({ count: 0, foo: observer('bar', function() { set(this, 'count', get(this, 'count') + 1); @@ -99,7 +95,7 @@ testBoth('observer should not fire after being destroyed', function(get, set) { equal(get(obj, 'count'), 0, 'precond - should not invoke observer immediately'); - run(function() { obj.destroy(); }); + run(() => obj.destroy()); expectAssertion(function() { set(obj, 'bar', 'BAZ'); @@ -113,7 +109,7 @@ testBoth('observer should not fire after being destroyed', function(get, set) { testBoth('chain observer on class', function(get, set) { - var MyClass = EmberObject.extend({ + let MyClass = EmberObject.extend({ count: 0, foo: observer('bar.baz', function() { @@ -121,11 +117,11 @@ testBoth('chain observer on class', function(get, set) { }) }); - var obj1 = MyClass.create({ + let obj1 = MyClass.create({ bar: { baz: 'biff' } }); - var obj2 = MyClass.create({ + let obj2 = MyClass.create({ bar: { baz: 'biff2' } }); @@ -143,7 +139,7 @@ testBoth('chain observer on class', function(get, set) { testBoth('chain observer on class', function(get, set) { - var MyClass = EmberObject.extend({ + let MyClass = EmberObject.extend({ count: 0, foo: observer('bar.baz', function() { @@ -151,11 +147,11 @@ testBoth('chain observer on class', function(get, set) { }) }); - var obj1 = MyClass.extend().create({ + let obj1 = MyClass.extend().create({ bar: { baz: 'biff' } }); - var obj2 = MyClass.extend({ + let obj2 = MyClass.extend({ foo: observer('bar2.baz', function() { set(this, 'count', get(this, 'count') + 1); }) @@ -181,16 +177,16 @@ testBoth('chain observer on class', function(get, set) { }); testBoth('chain observer on class that has a reference to an uninitialized object will finish chains that reference it', function(get, set) { - var changed = false; + let changed = false; - var ChildClass = EmberObject.extend({ + let ChildClass = EmberObject.extend({ parent: null, parentOneTwoDidChange: observer('parent.one.two', function() { changed = true; }) }); - var ParentClass = EmberObject.extend({ + let ParentClass = EmberObject.extend({ one: { two: 'old' }, @@ -201,7 +197,7 @@ testBoth('chain observer on class that has a reference to an uninitialized objec } }); - var parent = new ParentClass(); + let parent = new ParentClass(); equal(changed, false, 'precond'); diff --git a/packages/ember-runtime/tests/system/object/reopenClass_test.js b/packages/ember-runtime/tests/system/object/reopenClass_test.js index 5d309fa9cd9..8e24e33ac11 100644 --- a/packages/ember-runtime/tests/system/object/reopenClass_test.js +++ b/packages/ember-runtime/tests/system/object/reopenClass_test.js @@ -4,7 +4,7 @@ import EmberObject from 'ember-runtime/system/object'; QUnit.module('system/object/reopenClass'); QUnit.test('adds new properties to subclass', function() { - var Subclass = EmberObject.extend(); + let Subclass = EmberObject.extend(); Subclass.reopenClass({ foo() { return 'FOO'; }, bar: 'BAR' @@ -15,13 +15,13 @@ QUnit.test('adds new properties to subclass', function() { }); QUnit.test('class properties inherited by subclasses', function() { - var Subclass = EmberObject.extend(); + let Subclass = EmberObject.extend(); Subclass.reopenClass({ foo() { return 'FOO'; }, bar: 'BAR' }); - var SubSub = Subclass.extend(); + let SubSub = Subclass.extend(); equal(SubSub.foo(), 'FOO', 'Adds method'); equal(get(SubSub, 'bar'), 'BAR', 'Adds property'); diff --git a/packages/ember-runtime/tests/system/object/reopen_test.js b/packages/ember-runtime/tests/system/object/reopen_test.js index 498c7f9c35b..92784c5b7fc 100644 --- a/packages/ember-runtime/tests/system/object/reopen_test.js +++ b/packages/ember-runtime/tests/system/object/reopen_test.js @@ -4,7 +4,7 @@ import EmberObject from 'ember-runtime/system/object'; QUnit.module('system/core_object/reopen'); QUnit.test('adds new properties to subclass instance', function() { - var Subclass = EmberObject.extend(); + let Subclass = EmberObject.extend(); Subclass.reopen({ foo() { return 'FOO'; }, bar: 'BAR' @@ -15,21 +15,20 @@ QUnit.test('adds new properties to subclass instance', function() { }); QUnit.test('reopened properties inherited by subclasses', function() { - var Subclass = EmberObject.extend(); - var SubSub = Subclass.extend(); + let Subclass = EmberObject.extend(); + let SubSub = Subclass.extend(); Subclass.reopen({ foo() { return 'FOO'; }, bar: 'BAR' }); - equal(new SubSub().foo(), 'FOO', 'Adds method'); equal(get(new SubSub(), 'bar'), 'BAR', 'Adds property'); }); QUnit.test('allows reopening already instantiated classes', function() { - var Subclass = EmberObject.extend(); + let Subclass = EmberObject.extend(); Subclass.create(); diff --git a/packages/ember-runtime/tests/system/object/strict-mode-test.js b/packages/ember-runtime/tests/system/object/strict-mode-test.js index 2eb55e90b6f..6378192ae7c 100644 --- a/packages/ember-runtime/tests/system/object/strict-mode-test.js +++ b/packages/ember-runtime/tests/system/object/strict-mode-test.js @@ -3,25 +3,25 @@ import EmberObject from 'ember-runtime/system/object'; QUnit.module('strict mode tests'); QUnit.test('__superWrapper does not throw errors in strict mode', function() { - var Foo = EmberObject.extend({ + let Foo = EmberObject.extend({ blah() { return 'foo'; } }); - var Bar = Foo.extend({ + let Bar = Foo.extend({ blah() { return 'bar'; }, callBlah() { - var blah = this.blah; + let blah = this.blah; return blah(); } }); - var bar = Bar.create(); + let bar = Bar.create(); equal(bar.callBlah(), 'bar', 'can call local function without call/apply'); }); diff --git a/packages/ember-runtime/tests/system/object/subclasses_test.js b/packages/ember-runtime/tests/system/object/subclasses_test.js index 68a86019eaa..233098862d7 100644 --- a/packages/ember-runtime/tests/system/object/subclasses_test.js +++ b/packages/ember-runtime/tests/system/object/subclasses_test.js @@ -5,8 +5,8 @@ import EmberObject from 'ember-runtime/system/object'; QUnit.module('system/object/subclasses'); QUnit.test('chains should copy forward to subclasses when prototype created', function () { - var ObjectWithChains, objWithChains, SubWithChains, SubSub, subSub; - run(function () { + let ObjectWithChains, objWithChains, SubWithChains, SubSub, subSub; + run(() => { ObjectWithChains = EmberObject.extend({ obj: { a: 'a', @@ -40,8 +40,6 @@ QUnit.test('chains should copy forward to subclasses when prototype created', fu }, deprecationMessage); }); equal(subSub.get('greeting'), 'hi world'); - run(function () { - objWithChains.set('obj.hi', 'hello'); - }); + run(() => objWithChains.set('obj.hi', 'hello')); equal(subSub.get('greeting'), 'hello world'); }); diff --git a/packages/ember-runtime/tests/system/object/toString_test.js b/packages/ember-runtime/tests/system/object/toString_test.js index 00b47ee4d52..4da6c224023 100644 --- a/packages/ember-runtime/tests/system/object/toString_test.js +++ b/packages/ember-runtime/tests/system/object/toString_test.js @@ -16,7 +16,7 @@ QUnit.module('system/object/toString', { }); QUnit.test('toString() returns the same value if called twice', function() { - var Foo = Namespace.create(); + let Foo = Namespace.create(); Foo.toString = function() { return 'Foo'; }; Foo.Bar = EmberObject.extend(); @@ -24,7 +24,7 @@ QUnit.test('toString() returns the same value if called twice', function() { equal(Foo.Bar.toString(), 'Foo.Bar'); equal(Foo.Bar.toString(), 'Foo.Bar'); - var obj = Foo.Bar.create(); + let obj = Foo.Bar.create(); equal(obj.toString(), ''); equal(obj.toString(), ''); @@ -33,9 +33,9 @@ QUnit.test('toString() returns the same value if called twice', function() { }); QUnit.test('toString on a class returns a useful value when nested in a namespace', function() { - var obj; + let obj; - var Foo = Namespace.create(); + let Foo = Namespace.create(); Foo.toString = function() { return 'Foo'; }; Foo.Bar = EmberObject.extend(); @@ -55,14 +55,14 @@ QUnit.test('toString on a class returns a useful value when nested in a namespac }); QUnit.test('toString on a namespace finds the namespace in lookup', function() { - var Foo = lookup.Foo = Namespace.create(); + let Foo = lookup.Foo = Namespace.create(); equal(Foo.toString(), 'Foo'); }); QUnit.test('toString on a namespace finds the namespace in lookup', function() { - var Foo = lookup.Foo = Namespace.create(); - var obj; + let Foo = lookup.Foo = Namespace.create(); + let obj; Foo.Bar = EmberObject.extend(); @@ -73,20 +73,20 @@ QUnit.test('toString on a namespace finds the namespace in lookup', function() { }); QUnit.test('toString on a namespace falls back to modulePrefix, if defined', function() { - var Foo = Namespace.create({ modulePrefix: 'foo' }); + let Foo = Namespace.create({ modulePrefix: 'foo' }); equal(Foo.toString(), 'foo'); }); QUnit.test('toString includes toStringExtension if defined', function() { - var Foo = EmberObject.extend({ + let Foo = EmberObject.extend({ toStringExtension() { return 'fooey'; } }); - var foo = Foo.create(); - var Bar = EmberObject.extend({}); - var bar = Bar.create(); + let foo = Foo.create(); + let Bar = EmberObject.extend({}); + let bar = Bar.create(); // simulate these classes being defined on a Namespace Foo[GUID_KEY + '_name'] = 'Foo'; diff --git a/packages/ember-runtime/tests/system/object_proxy_test.js b/packages/ember-runtime/tests/system/object_proxy_test.js index 8547fac3a91..0a926797c2d 100644 --- a/packages/ember-runtime/tests/system/object_proxy_test.js +++ b/packages/ember-runtime/tests/system/object_proxy_test.js @@ -7,16 +7,16 @@ import ObjectProxy from 'ember-runtime/system/object_proxy'; QUnit.module('ObjectProxy'); testBoth('should not proxy properties passed to create', function (get, set) { - var Proxy = ObjectProxy.extend({ + let Proxy = ObjectProxy.extend({ cp: computed({ - get: function(key) { return this._cp; }, - set: function(key, value) { + get(key) { return this._cp; }, + set(key, value) { this._cp = value; return this._cp; } }) }); - var proxy = Proxy.create({ + let proxy = Proxy.create({ prop: 'Foo', cp: 'Bar' }); @@ -26,15 +26,15 @@ testBoth('should not proxy properties passed to create', function (get, set) { }); testBoth('should proxy properties to content', function(get, set) { - var content = { + let content = { firstName: 'Tom', lastName: 'Dale', unknownProperty(key) { return key + ' unknown';} }; - var proxy = ObjectProxy.create(); + let proxy = ObjectProxy.create(); equal(get(proxy, 'firstName'), undefined, 'get on proxy without content should return undefined'); - expectAssertion(function () { + expectAssertion(() => { set(proxy, 'firstName', 'Foo'); }, /Cannot delegate set\('firstName', Foo\) to the 'content'/i); @@ -56,15 +56,15 @@ testBoth('should proxy properties to content', function(get, set) { }); testBoth('should work with watched properties', function(get, set) { - var content1 = { firstName: 'Tom', lastName: 'Dale' }; - var content2 = { firstName: 'Yehuda', lastName: 'Katz' }; - var count = 0; - var Proxy, proxy, last; + let content1 = { firstName: 'Tom', lastName: 'Dale' }; + let content2 = { firstName: 'Yehuda', lastName: 'Katz' }; + let count = 0; + let last; - Proxy = ObjectProxy.extend({ + let Proxy = ObjectProxy.extend({ fullName: computed(function () { - var firstName = this.get('firstName'); - var lastName = this.get('lastName'); + let firstName = this.get('firstName'); + let lastName = this.get('lastName'); if (firstName && lastName) { return firstName + ' ' + lastName; @@ -73,7 +73,7 @@ testBoth('should work with watched properties', function(get, set) { }).property('firstName', 'lastName') }); - proxy = Proxy.create(); + let proxy = Proxy.create(); addObserver(proxy, 'fullName', function () { last = get(proxy, 'fullName'); @@ -117,9 +117,9 @@ testBoth('should work with watched properties', function(get, set) { }); QUnit.test('set and get should work with paths', function () { - var content = { foo: { bar: 'baz' } }; - var proxy = ObjectProxy.create({ content: content }); - var count = 0; + let content = { foo: { bar: 'baz' } }; + let proxy = ObjectProxy.create({ content }); + let count = 0; proxy.set('foo.bar', 'hello'); equal(proxy.get('foo.bar'), 'hello'); @@ -137,9 +137,9 @@ QUnit.test('set and get should work with paths', function () { }); testBoth('should transition between watched and unwatched strategies', function(get, set) { - var content = { foo: 'foo' }; - var proxy = ObjectProxy.create({ content: content }); - var count = 0; + let content = { foo: 'foo' }; + let proxy = ObjectProxy.create({ content: content }); + let count = 0; function observer() { count++; @@ -185,7 +185,7 @@ testBoth('should transition between watched and unwatched strategies', function( }); testBoth('setting `undefined` to a proxied content property should override its existing value', function(get, set) { - var proxyObject = ObjectProxy.create({ + let proxyObject = ObjectProxy.create({ content: { prop: 'emberjs' } diff --git a/packages/ember-runtime/tests/system/string/loc_test.js b/packages/ember-runtime/tests/system/string/loc_test.js index cb852e082cd..c59da84f86a 100644 --- a/packages/ember-runtime/tests/system/string/loc_test.js +++ b/packages/ember-runtime/tests/system/string/loc_test.js @@ -2,7 +2,7 @@ import Ember from 'ember-metal/core'; // ES6TODO Ember.STRINGS import { ENV } from 'ember-environment'; import { loc } from 'ember-runtime/system/string'; -var oldString; +let oldString; QUnit.module('EmberStringUtils.loc', { setup() { diff --git a/packages/ember-template-compiler/lib/compat/precompile.js b/packages/ember-template-compiler/lib/compat/precompile.js index d84b5ba9576..e7390dd9c6b 100644 --- a/packages/ember-template-compiler/lib/compat/precompile.js +++ b/packages/ember-template-compiler/lib/compat/precompile.js @@ -6,7 +6,7 @@ import require, { has } from 'require'; import isEnabled from 'ember-metal/features'; -var compile, compileSpec, compileOptions; +let compile, compileSpec, compileOptions; // Note we don't really want to expose this from main file if (isEnabled('ember-glimmer')) { @@ -17,7 +17,7 @@ if (isEnabled('ember-glimmer')) { export default function(string) { if ((!compile || !compileSpec) && has('htmlbars-compiler/compiler')) { - var Compiler = require('htmlbars-compiler/compiler'); + let Compiler = require('htmlbars-compiler/compiler'); compile = Compiler.compile; compileSpec = Compiler.compileSpec; @@ -27,8 +27,8 @@ export default function(string) { throw new Error('Cannot call `precompile` without the template compiler loaded. Please load `ember-template-compiler.js` prior to calling `precompile`.'); } - var asObject = arguments[1] === undefined ? true : arguments[1]; - var compileFunc = asObject ? compile : compileSpec; + let asObject = arguments[1] === undefined ? true : arguments[1]; + let compileFunc = asObject ? compile : compileSpec; return compileFunc(string, compileOptions()); } diff --git a/packages/ember-template-compiler/lib/plugins/transform-angle-bracket-components.js b/packages/ember-template-compiler/lib/plugins/transform-angle-bracket-components.js index 813d06309ee..aad24be3653 100644 --- a/packages/ember-template-compiler/lib/plugins/transform-angle-bracket-components.js +++ b/packages/ember-template-compiler/lib/plugins/transform-angle-bracket-components.js @@ -1,4 +1,4 @@ -function TransformAngleBracketComponents() { +export default function TransformAngleBracketComponents() { // set later within HTMLBars to the syntax package this.syntax = null; } @@ -9,9 +9,9 @@ function TransformAngleBracketComponents() { @param {AST} ast The AST to be transformed. */ TransformAngleBracketComponents.prototype.transform = function TransformAngleBracketComponents_transform(ast) { - var walker = new this.syntax.Walker(); + let walker = new this.syntax.Walker(); - walker.visit(ast, function(node) { + walker.visit(ast, node => { if (!validate(node)) { return; } node.tag = `<${node.tag}>`; @@ -23,5 +23,3 @@ TransformAngleBracketComponents.prototype.transform = function TransformAngleBra function validate(node) { return node.type === 'ComponentNode'; } - -export default TransformAngleBracketComponents; diff --git a/packages/ember-template-compiler/lib/plugins/transform-input-on-to-onEvent.js b/packages/ember-template-compiler/lib/plugins/transform-input-on-to-onEvent.js index 81d4ae20446..be906958cb1 100644 --- a/packages/ember-template-compiler/lib/plugins/transform-input-on-to-onEvent.js +++ b/packages/ember-template-compiler/lib/plugins/transform-input-on-to-onEvent.js @@ -24,7 +24,7 @@ import calculateLocationDisplay from 'ember-template-compiler/system/calculate-l @private @class TransformInputOnToOnEvent */ -function TransformInputOnToOnEvent(options = {}) { +export default function TransformInputOnToOnEvent(options = {}) { // set later within HTMLBars to the syntax package this.syntax = null; this.options = options; @@ -124,7 +124,7 @@ function hashPairForKey(hash, key) { } function removeFromHash(hash, pairToRemove) { - var newPairs = []; + let newPairs = []; for (let i = 0; i < hash.pairs.length; i++) { let pair = hash.pairs[i]; @@ -135,5 +135,3 @@ function removeFromHash(hash, pairToRemove) { hash.pairs = newPairs; } - -export default TransformInputOnToOnEvent; diff --git a/packages/ember-template-compiler/lib/plugins/transform-item-class.js b/packages/ember-template-compiler/lib/plugins/transform-item-class.js index 96c2483009d..2df50e01656 100644 --- a/packages/ember-template-compiler/lib/plugins/transform-item-class.js +++ b/packages/ember-template-compiler/lib/plugins/transform-item-class.js @@ -3,13 +3,14 @@ export default function TransformItemClass() { } TransformItemClass.prototype.transform = function TransformItemClass_transform(ast) { - var b = this.syntax.builders; - var walker = new this.syntax.Walker(); + let b = this.syntax.builders; + let walker = new this.syntax.Walker(); - walker.visit(ast, function(node) { + walker.visit(ast, node => { if (!validate(node)) { return; } - each(node.hash.pairs, function(pair) { + for (let i = 0; i < node.hash.pairs.length; i++) { + let pair = node.hash.pairs[i]; let { key, value } = pair; if (key !== 'itemClass') { return; } @@ -23,7 +24,7 @@ TransformItemClass.prototype.transform = function TransformItemClass_transform(a let sexpr = b.sexpr(b.string('if'), params); pair.value = sexpr; - }); + } }); return ast; @@ -33,9 +34,3 @@ function validate(node) { return (node.type === 'BlockStatement' || node.type === 'MustacheStatement') && node.path.original === 'collection'; } - -function each(list, callback) { - for (var i = 0; i < list.length; i++) { - callback(list[i]); - } -} diff --git a/packages/ember-template-compiler/lib/plugins/transform-old-binding-syntax.js b/packages/ember-template-compiler/lib/plugins/transform-old-binding-syntax.js index f9767aa8971..9a7d7138f46 100644 --- a/packages/ember-template-compiler/lib/plugins/transform-old-binding-syntax.js +++ b/packages/ember-template-compiler/lib/plugins/transform-old-binding-syntax.js @@ -11,10 +11,11 @@ TransformOldBindingSyntax.prototype.transform = function TransformOldBindingSynt var b = this.syntax.builders; var walker = new this.syntax.Walker(); - walker.visit(ast, function(node) { + walker.visit(ast, node => { if (!validate(node)) { return; } - each(node.hash.pairs, function(pair) { + for (let i = 0; i < node.hash.pairs.length; i++) { + let pair = node.hash.pairs[i]; let { key, value } = pair; var sourceInformation = calculateLocationDisplay(moduleName, pair.loc); @@ -37,7 +38,7 @@ TransformOldBindingSyntax.prototype.transform = function TransformOldBindingSynt pair.value = b.path(value.original); } } - }); + } }); return ast; @@ -47,12 +48,6 @@ function validate(node) { return (node.type === 'BlockStatement' || node.type === 'MustacheStatement'); } -function each(list, callback) { - for (var i = 0; i < list.length; i++) { - callback(list[i]); - } -} - function exprToString(expr) { switch (expr.type) { case 'StringLiteral': return `"${expr.original}"`; diff --git a/packages/ember-template-compiler/lib/plugins/transform-top-level-components.js b/packages/ember-template-compiler/lib/plugins/transform-top-level-components.js index 658c3a7fa49..384af7dab80 100644 --- a/packages/ember-template-compiler/lib/plugins/transform-top-level-components.js +++ b/packages/ember-template-compiler/lib/plugins/transform-top-level-components.js @@ -1,4 +1,4 @@ -function TransformTopLevelComponents() { +export default function TransformTopLevelComponents() { // set later within HTMLBars to the syntax package this.syntax = null; } @@ -46,5 +46,3 @@ function hasSingleComponentNode(program, componentCallback) { componentCallback(lastComponentNode); } } - -export default TransformTopLevelComponents; diff --git a/packages/ember-template-compiler/tests/plugins/deprecate-render-model-test.js b/packages/ember-template-compiler/tests/plugins/deprecate-render-model-test.js index 7961aedb9e4..0b2fd13b62c 100644 --- a/packages/ember-template-compiler/tests/plugins/deprecate-render-model-test.js +++ b/packages/ember-template-compiler/tests/plugins/deprecate-render-model-test.js @@ -9,7 +9,7 @@ QUnit.test('Using `{{render` with model provides a deprecation', function() { `Please refactor \`{{render "foo-bar" coolModel}}\` to a component and` + ` invoke via \`{{foo-bar model=coolModel}}\`. ('baz/foo-bar' @ L1:C0) `; - expectDeprecation(function() { + expectDeprecation(() => { compile('{{render "foo-bar" coolModel}}', { moduleName: 'baz/foo-bar' }); diff --git a/packages/ember-template-compiler/tests/plugins/transform-input-on-test.js b/packages/ember-template-compiler/tests/plugins/transform-input-on-test.js index f2098096553..a0a06954d52 100644 --- a/packages/ember-template-compiler/tests/plugins/transform-input-on-test.js +++ b/packages/ember-template-compiler/tests/plugins/transform-input-on-test.js @@ -5,7 +5,7 @@ QUnit.module('ember-template-compiler: transform-input-on'); QUnit.test('Using `action` without `on` provides a deprecation', function() { expect(1); - expectDeprecation(function() { + expectDeprecation(() => { compile('{{input action="foo"}}', { moduleName: 'foo/bar/baz' }); @@ -15,7 +15,7 @@ QUnit.test('Using `action` without `on` provides a deprecation', function() { QUnit.test('Using `action` with `on` provides a deprecation', function() { expect(1); - expectDeprecation(function() { + expectDeprecation(() => { compile('{{input on="focus-in" action="foo"}}', { moduleName: 'foo/bar/baz' }); @@ -25,7 +25,7 @@ QUnit.test('Using `action` with `on` provides a deprecation', function() { QUnit.test('Using `on=\'keyPress\'` does not clobber `keyPress`', function() { expect(1); - expectDeprecation(function() { + expectDeprecation(() => { compile('{{input on="keyPress" action="foo"}}', { moduleName: 'foo/bar/baz' }); @@ -35,7 +35,7 @@ QUnit.test('Using `on=\'keyPress\'` does not clobber `keyPress`', function() { QUnit.test('Using `on=\'foo\'` without `action=\'asdf\'` raises specific deprecation', function() { expect(1); - expectDeprecation(function() { + expectDeprecation(() => { compile('{{input on="asdf"}}', { moduleName: 'foo/bar/baz' }); diff --git a/packages/ember-template-compiler/tests/system/compile_test.js b/packages/ember-template-compiler/tests/system/compile_test.js index 52deb26b1bc..85d94ae5b1c 100644 --- a/packages/ember-template-compiler/tests/system/compile_test.js +++ b/packages/ember-template-compiler/tests/system/compile_test.js @@ -9,18 +9,18 @@ import { test, testModule } from 'internal-test-helpers/tests/skip-if-glimmer'; testModule('ember-template-compiler: compile'); test('includes the current revision in the compiled template', function() { - var templateString = '{{foo}} -- {{some-bar blah=\'foo\'}}'; + let templateString = '{{foo}} -- {{some-bar blah=\'foo\'}}'; - var actual = compile(templateString); + let actual = compile(templateString); equal(actual.meta.revision, 'Ember@' + VERSION, 'revision is included in generated template'); }); test('the template revision is different than the HTMLBars default revision', function() { - var templateString = '{{foo}} -- {{some-bar blah=\'foo\'}}'; + let templateString = '{{foo}} -- {{some-bar blah=\'foo\'}}'; - var actual = compile(templateString); - var expected = htmlbarsCompile(templateString); + let actual = compile(templateString); + let expected = htmlbarsCompile(templateString); ok(actual.meta.revision !== expected.meta.revision, 'revision differs from default'); }); diff --git a/packages/ember-template-compiler/tests/system/template_test.js b/packages/ember-template-compiler/tests/system/template_test.js index fac38a504ae..21d1e751046 100644 --- a/packages/ember-template-compiler/tests/system/template_test.js +++ b/packages/ember-template-compiler/tests/system/template_test.js @@ -7,7 +7,7 @@ testModule('ember-htmlbars: template'); test('sets `isTop` on the provided function', function() { function test() { } - var result = template(test); + let result = template(test); equal(result.isTop, true, 'sets isTop on the provided function'); }); @@ -15,7 +15,7 @@ test('sets `isTop` on the provided function', function() { test('sets `isMethod` on the provided function', function() { function test() { } - var result = template(test); + let result = template(test); equal(result.isMethod, false, 'sets isMethod on the provided function'); }); diff --git a/packages/ember-templates/lib/bootstrap.js b/packages/ember-templates/lib/bootstrap.js index aa2de89a650..01f0af56dfa 100644 --- a/packages/ember-templates/lib/bootstrap.js +++ b/packages/ember-templates/lib/bootstrap.js @@ -38,18 +38,18 @@ import { @param ctx */ function bootstrap(ctx) { - var selectors = 'script[type="text/x-handlebars"], script[type="text/x-raw-handlebars"]'; + let selectors = 'script[type="text/x-handlebars"], script[type="text/x-raw-handlebars"]'; jQuery(selectors, ctx) - .each(function() { + .each(function() { // Get a reference to the script tag. - var script = jQuery(this); + let script = jQuery(this); // Get the name of the script, used by Ember.View's templateName property. // First look for data-template-name attribute, then fall back to its // id if no name is found. - var templateName = script.attr('data-template-name') || script.attr('id') || 'application'; - var template, compile; + let templateName = script.attr('data-template-name') || script.attr('id') || 'application'; + let template, compile; if (script.attr('type') === 'text/x-raw-handlebars') { compile = jQuery.proxy(Handlebars.compile, Handlebars); diff --git a/packages/ember-templates/tests/bootstrap_test.js b/packages/ember-templates/tests/bootstrap_test.js index 72ffa72179b..a86a37bc83c 100644 --- a/packages/ember-templates/tests/bootstrap_test.js +++ b/packages/ember-templates/tests/bootstrap_test.js @@ -6,26 +6,26 @@ import { runDestroy } from 'ember-runtime/tests/utils'; import bootstrap from 'ember-templates/bootstrap'; import { setTemplates, get as getTemplate } from 'ember-templates/template_registry'; -var trim = jQuery.trim; +const { trim } = jQuery; -var originalLookup = context.lookup; -var lookup, App, component; +const originalLookup = context.lookup; +let lookup, App, component; function checkTemplate(templateName) { - run(function() { - bootstrap(jQuery('#qunit-fixture')); - }); - var template = getTemplate(templateName); + run(() => bootstrap(jQuery('#qunit-fixture'))); + + let template = getTemplate(templateName); + ok(template, 'template is available on Ember.TEMPLATES'); equal(jQuery('#qunit-fixture script').length, 0, 'script removed'); - var component = Component.create({ + + let component = Component.create({ layout: template, firstName: 'Tobias', drug: 'teamocil' }); - run(function() { - component.createElement(); - }); + + run(() => component.createElement()); equal(trim(component.$().text()), 'Tobias takes teamocil', 'template works'); runDestroy(component); } @@ -66,9 +66,7 @@ if (typeof Handlebars === 'object') { QUnit.test('template with type text/x-raw-handlebars should be parsed', function() { jQuery('#qunit-fixture').html(''); - run(function() { - bootstrap(jQuery('#qunit-fixture')); - }); + run(() => bootstrap(jQuery('#qunit-fixture'))); let template = getTemplate('funkyTemplate'); @@ -82,49 +80,39 @@ if (typeof Handlebars === 'object') { QUnit.test('duplicated default application templates should throw exception', function() { jQuery('#qunit-fixture').html(''); - throws(function () { - bootstrap(jQuery('#qunit-fixture')); - }, - /Template named "[^"]+" already exists\./, - 'duplicate templates should not be allowed'); + throws(() => bootstrap(jQuery('#qunit-fixture')), + /Template named "[^"]+" already exists\./, + 'duplicate templates should not be allowed'); }); QUnit.test('default application template and id application template present should throw exception', function() { jQuery('#qunit-fixture').html(''); - throws(function () { - bootstrap(jQuery('#qunit-fixture')); - }, - /Template named "[^"]+" already exists\./, - 'duplicate templates should not be allowed'); + throws(() => bootstrap(jQuery('#qunit-fixture')), + /Template named "[^"]+" already exists\./, + 'duplicate templates should not be allowed'); }); QUnit.test('default application template and data-template-name application template present should throw exception', function() { jQuery('#qunit-fixture').html(''); - throws(function () { - bootstrap(jQuery('#qunit-fixture')); - }, - /Template named "[^"]+" already exists\./, - 'duplicate templates should not be allowed'); + throws(() => bootstrap(jQuery('#qunit-fixture')), + /Template named "[^"]+" already exists\./, + 'duplicate templates should not be allowed'); }); QUnit.test('duplicated template id should throw exception', function() { jQuery('#qunit-fixture').html(''); - throws(function () { - bootstrap(jQuery('#qunit-fixture')); - }, - /Template named "[^"]+" already exists\./, - 'duplicate templates should not be allowed'); + throws(() => bootstrap(jQuery('#qunit-fixture')), + /Template named "[^"]+" already exists\./, + 'duplicate templates should not be allowed'); }); QUnit.test('duplicated template data-template-name should throw exception', function() { jQuery('#qunit-fixture').html(''); - throws(function () { - bootstrap(jQuery('#qunit-fixture')); - }, - /Template named "[^"]+" already exists\./, - 'duplicate templates should not be allowed'); + throws(() => bootstrap(jQuery('#qunit-fixture')), + /Template named "[^"]+" already exists\./, + 'duplicate templates should not be allowed'); }); diff --git a/packages/ember-testing/lib/adapters/adapter.js b/packages/ember-testing/lib/adapters/adapter.js index 75c3f180025..a1ff278c22c 100644 --- a/packages/ember-testing/lib/adapters/adapter.js +++ b/packages/ember-testing/lib/adapters/adapter.js @@ -15,7 +15,7 @@ function K() { return this; } @namespace Ember.Test @public */ -var Adapter = EmberObject.extend({ +export default EmberObject.extend({ /** This callback will be called whenever an async operation is about to start. @@ -56,5 +56,3 @@ var Adapter = EmberObject.extend({ throw error; } }); - -export default Adapter; diff --git a/packages/ember-testing/lib/ext/application.js b/packages/ember-testing/lib/ext/application.js index 447cf16043b..3c59349ab21 100644 --- a/packages/ember-testing/lib/ext/application.js +++ b/packages/ember-testing/lib/ext/application.js @@ -126,7 +126,7 @@ EmberApplication.reopen({ }); this.testHelpers = {}; - for (var name in helpers) { + for (let name in helpers) { this.originalMethods[name] = this.helperContainer[name]; this.testHelpers[name] = this.helperContainer[name] = helper(this, name); protoWrap(TestPromise.prototype, name, helper(this, name), helpers[name].meta.wait); @@ -151,7 +151,7 @@ EmberApplication.reopen({ removeTestHelpers() { if (!this.helperContainer) { return; } - for (var name in helpers) { + for (let name in helpers) { this.helperContainer[name] = this.originalMethods[name]; delete TestPromise.prototype[name]; delete this.testHelpers[name]; diff --git a/packages/ember-testing/lib/helpers/fill_in.js b/packages/ember-testing/lib/helpers/fill_in.js index d431ab4f0ff..6d7fe7291ae 100644 --- a/packages/ember-testing/lib/helpers/fill_in.js +++ b/packages/ember-testing/lib/helpers/fill_in.js @@ -2,7 +2,7 @@ import run from 'ember-metal/run_loop'; import { focus, fireEvent } from '../events'; export default function fillIn(app, selector, contextOrText, text) { - var $el, el, context; + let $el, el, context; if (typeof text === 'undefined') { text = contextOrText; } else { @@ -11,7 +11,7 @@ export default function fillIn(app, selector, contextOrText, text) { $el = app.testHelpers.findWithAssert(selector, context); el = $el[0]; focus(el); - run(function() { + run(() => { $el.val(text); fireEvent(el, 'input'); fireEvent(el, 'change'); diff --git a/packages/ember-testing/lib/helpers/find_with_assert.js b/packages/ember-testing/lib/helpers/find_with_assert.js index 37f71366e0a..3711e03b02f 100644 --- a/packages/ember-testing/lib/helpers/find_with_assert.js +++ b/packages/ember-testing/lib/helpers/find_with_assert.js @@ -1,5 +1,5 @@ export default function findWithAssert(app, selector, context) { - var $el = app.testHelpers.find(selector, context); + let $el = app.testHelpers.find(selector, context); if ($el.length === 0) { throw new Error('Element ' + selector + ' not found.'); } diff --git a/packages/ember-testing/lib/helpers/key_event.js b/packages/ember-testing/lib/helpers/key_event.js index 698c21298a3..26c05607ff7 100644 --- a/packages/ember-testing/lib/helpers/key_event.js +++ b/packages/ember-testing/lib/helpers/key_event.js @@ -1,5 +1,5 @@ export default function keyEvent(app, selector, contextOrType, typeOrKeyCode, keyCode) { - var context, type; + let context, type; if (typeof keyCode === 'undefined') { context = null; diff --git a/packages/ember-testing/lib/helpers/trigger_event.js b/packages/ember-testing/lib/helpers/trigger_event.js index 22a126780a6..9ba5e8f4a28 100644 --- a/packages/ember-testing/lib/helpers/trigger_event.js +++ b/packages/ember-testing/lib/helpers/trigger_event.js @@ -2,8 +2,8 @@ import run from 'ember-metal/run_loop'; import { fireEvent } from '../events'; export default function triggerEvent(app, selector, contextOrType, typeOrOptions, possibleOptions) { - var arity = arguments.length; - var context, type, options; + let arity = arguments.length; + let context, type, options; if (arity === 3) { // context and options are optional, so this is @@ -30,8 +30,8 @@ export default function triggerEvent(app, selector, contextOrType, typeOrOptions options = possibleOptions; } - var $el = app.testHelpers.findWithAssert(selector, context); - var el = $el[0]; + let $el = app.testHelpers.findWithAssert(selector, context); + let el = $el[0]; run(null, fireEvent, el, type, options); diff --git a/packages/ember-testing/lib/helpers/visit.js b/packages/ember-testing/lib/helpers/visit.js index 00a5fbdd45f..6ebaf898d6a 100644 --- a/packages/ember-testing/lib/helpers/visit.js +++ b/packages/ember-testing/lib/helpers/visit.js @@ -4,7 +4,7 @@ export default function visit(app, url) { let router = app.__container__.lookup('router:main'); let shouldHandleURL = false; - app.boot().then(function() { + app.boot().then(() => { router.location.setURL(url); if (shouldHandleURL) { diff --git a/packages/ember-testing/lib/helpers/wait.js b/packages/ember-testing/lib/helpers/wait.js index 25032c3cfce..6e5c9c8f1e4 100644 --- a/packages/ember-testing/lib/helpers/wait.js +++ b/packages/ember-testing/lib/helpers/wait.js @@ -8,7 +8,7 @@ export default function wait(app, value) { let router = app.__container__.lookup('router:main'); // Every 10ms, poll for the async thing to have finished - let watcher = setInterval(function() { + let watcher = setInterval(() => { // 1. If the router is loading, keep polling let routerIsLoading = router.router && !!router.router.activeTransition; if (routerIsLoading) { return; } diff --git a/packages/ember-testing/lib/initializers.js b/packages/ember-testing/lib/initializers.js index 252c905f1cb..bc2dfc5bdee 100644 --- a/packages/ember-testing/lib/initializers.js +++ b/packages/ember-testing/lib/initializers.js @@ -1,6 +1,6 @@ import { onLoad } from 'ember-runtime/system/lazy_load'; -var name = 'deferReadiness in `testing` mode'; +let name = 'deferReadiness in `testing` mode'; onLoad('Ember.Application', function(Application) { if (!Application.initializers[name]) { diff --git a/packages/ember-testing/lib/support.js b/packages/ember-testing/lib/support.js index 3548dcf19e5..de93902f1a6 100644 --- a/packages/ember-testing/lib/support.js +++ b/packages/ember-testing/lib/support.js @@ -8,7 +8,7 @@ import { environment } from 'ember-environment'; @submodule ember-testing */ -var $ = jQuery; +const $ = jQuery; /** This method creates a checkbox and triggers the click event to fire the diff --git a/packages/ember-testing/lib/test/on_inject_helpers.js b/packages/ember-testing/lib/test/on_inject_helpers.js index 2d9a34ad367..3fbd2bb50b9 100644 --- a/packages/ember-testing/lib/test/on_inject_helpers.js +++ b/packages/ember-testing/lib/test/on_inject_helpers.js @@ -30,7 +30,7 @@ export function onInjectHelpers(callback) { } export function invokeInjectHelpersCallbacks(app) { - for (var i = 0; i < callbacks.length; i++) { + for (let i = 0; i < callbacks.length; i++) { callbacks[i](app); } } diff --git a/packages/ember-views/lib/compat/attrs-proxy.js b/packages/ember-views/lib/compat/attrs-proxy.js index bc6db894f0a..d88dc8c6df5 100644 --- a/packages/ember-views/lib/compat/attrs-proxy.js +++ b/packages/ember-views/lib/compat/attrs-proxy.js @@ -12,7 +12,7 @@ function isCell(val) { return val && val[MUTABLE_CELL]; } -let AttrsProxyMixin = { +const AttrsProxyMixin = { attrs: null, getAttr(key) { diff --git a/packages/ember-views/lib/index.js b/packages/ember-views/lib/index.js index b0bdeec6453..14160b4adcc 100644 --- a/packages/ember-views/lib/index.js +++ b/packages/ember-views/lib/index.js @@ -39,7 +39,7 @@ Ember.$ = jQuery; Ember.ViewTargetActionSupport = ViewTargetActionSupport; -var ViewUtils = Ember.ViewUtils = {}; +const ViewUtils = Ember.ViewUtils = {}; ViewUtils.isSimpleClick = isSimpleClick; ViewUtils.getViewClientRects = getViewClientRects; ViewUtils.getViewBoundingClientRect = getViewBoundingClientRect; diff --git a/packages/ember-views/lib/mixins/class_names_support.js b/packages/ember-views/lib/mixins/class_names_support.js index dd258b624a8..9ef6d630d76 100644 --- a/packages/ember-views/lib/mixins/class_names_support.js +++ b/packages/ember-views/lib/mixins/class_names_support.js @@ -6,7 +6,7 @@ import { assert } from 'ember-metal/debug'; import { Mixin } from 'ember-metal/mixin'; import { A as emberA } from 'ember-runtime/system/native_array'; -var EMPTY_ARRAY = []; +const EMPTY_ARRAY = []; /** @class ClassNamesSupport diff --git a/packages/ember-views/lib/mixins/instrumentation_support.js b/packages/ember-views/lib/mixins/instrumentation_support.js index 7f658f4e1b0..b4412dfe837 100644 --- a/packages/ember-views/lib/mixins/instrumentation_support.js +++ b/packages/ember-views/lib/mixins/instrumentation_support.js @@ -10,7 +10,7 @@ import { get } from 'ember-metal/property_get'; @namespace Ember @public */ -var InstrumentationSupport = Mixin.create({ +export default Mixin.create({ /** Used to identify this view during debugging @@ -27,5 +27,3 @@ var InstrumentationSupport = Mixin.create({ this._super(hash); } }); - -export default InstrumentationSupport; diff --git a/packages/ember-views/lib/mixins/legacy_view_support.js b/packages/ember-views/lib/mixins/legacy_view_support.js index 7b1a9bfd350..fe457f18097 100644 --- a/packages/ember-views/lib/mixins/legacy_view_support.js +++ b/packages/ember-views/lib/mixins/legacy_view_support.js @@ -11,7 +11,7 @@ import { get } from 'ember-metal/property_get'; @namespace Ember @private */ -var LegacyViewSupport = Mixin.create({ +export default Mixin.create({ /** Return the nearest ancestor whose parent is an instance of `klass`. @@ -29,7 +29,7 @@ var LegacyViewSupport = Mixin.create({ { id: 'ember-views.nearest-child-of', until: '3.0.0' } ); - var view = get(this, 'parentView'); + let view = get(this, 'parentView'); while (view) { if (get(view, 'parentView') instanceof klass) { return view; } @@ -54,7 +54,7 @@ var LegacyViewSupport = Mixin.create({ { id: 'ember-views.nearest-instance-of', until: '3.0.0' } ); - var view = get(this, 'parentView'); + let view = get(this, 'parentView'); while (view) { if (view instanceof klass) { return view; } @@ -62,5 +62,3 @@ var LegacyViewSupport = Mixin.create({ } } }); - -export default LegacyViewSupport; diff --git a/packages/ember-views/lib/mixins/template_support.js b/packages/ember-views/lib/mixins/template_support.js index 6b2b754eb2e..e92358e268f 100644 --- a/packages/ember-views/lib/mixins/template_support.js +++ b/packages/ember-views/lib/mixins/template_support.js @@ -59,8 +59,8 @@ export default Mixin.create({ */ template: computed({ get() { - var templateName = get(this, 'templateName'); - var template = this.templateForName(templateName, 'template'); + let templateName = get(this, 'templateName'); + let template = this.templateForName(templateName, 'template'); assert('You specified the templateName ' + templateName + ' for ' + this + ', but it did not exist.', !templateName || !!template); return template || get(this, 'defaultTemplate'); }, @@ -87,8 +87,8 @@ export default Mixin.create({ */ layout: computed({ get(key) { - var layoutName = get(this, 'layoutName'); - var layout = this.templateForName(layoutName, 'layout'); + let layoutName = get(this, 'layoutName'); + let layout = this.templateForName(layoutName, 'layout'); assert('You specified the layoutName ' + layoutName + ' for ' + this + ', but it did not exist.', !layoutName || !!layout); diff --git a/packages/ember-views/lib/mixins/text_support.js b/packages/ember-views/lib/mixins/text_support.js index 77630023964..d5c1c3dfa19 100644 --- a/packages/ember-views/lib/mixins/text_support.js +++ b/packages/ember-views/lib/mixins/text_support.js @@ -111,7 +111,7 @@ const KEY_EVENTS = { @extends Ember.Mixin @private */ -var TextSupport = Mixin.create(TargetActionSupport, { +export default Mixin.create(TargetActionSupport, { value: '', attributeBindings: [ @@ -188,8 +188,8 @@ var TextSupport = Mixin.create(TargetActionSupport, { bubbles: false, interpretKeyEvents(event) { - var map = KEY_EVENTS; - var method = map[event.keyCode]; + let map = KEY_EVENTS; + let method = map[event.keyCode]; this._elementValueDidChange(); if (method) { return this[method](event); } @@ -334,9 +334,9 @@ var TextSupport = Mixin.create(TargetActionSupport, { // sendAction semantics for TextField are different from // the component semantics so this method normalizes them. function sendAction(eventName, view, event) { - var action = get(view, 'attrs.' + eventName) || get(view, eventName); - var on = get(view, 'onEvent'); - var value = get(view, 'value'); + let action = get(view, 'attrs.' + eventName) || get(view, eventName); + let on = get(view, 'onEvent'); + let value = get(view, 'value'); // back-compat support for keyPress as an event name even though // it's also a method name that consumes the event (and therefore @@ -353,5 +353,3 @@ function sendAction(eventName, view, event) { } } } - -export default TextSupport; diff --git a/packages/ember-views/lib/mixins/view_child_views_support.js b/packages/ember-views/lib/mixins/view_child_views_support.js index b93ee1a0740..48ba96151b2 100644 --- a/packages/ember-views/lib/mixins/view_child_views_support.js +++ b/packages/ember-views/lib/mixins/view_child_views_support.js @@ -10,7 +10,7 @@ import setProperties from 'ember-metal/set_properties'; import { A as emberA } from 'ember-runtime/system/native_array'; import { getOwner, setOwner, OWNER } from 'container/owner'; -var EMPTY_ARRAY = []; +const EMPTY_ARRAY = []; export default Mixin.create({ /** @@ -59,9 +59,9 @@ export default Mixin.create({ this.unlinkChild(view); // remove view from childViews array. - var childViews = get(this, 'childViews'); + let childViews = get(this, 'childViews'); - var index = childViews.indexOf(view); + let index = childViews.indexOf(view); if (index !== -1) { childViews.splice(index, 1); } return this; @@ -91,7 +91,7 @@ export default Mixin.create({ return maybeViewClass; } - var view; + let view; attrs.parentView = this; attrs.renderer = this.renderer; @@ -106,8 +106,8 @@ export default Mixin.create({ set(this, view.viewName, view); } } else if ('string' === typeof maybeViewClass) { - var fullName = 'view:' + maybeViewClass; - var ViewKlass = owner._lookupFactory(fullName); + let fullName = 'view:' + maybeViewClass; + let ViewKlass = owner._lookupFactory(fullName); assert('Could not find view: \'' + fullName + '\'', !!ViewKlass); diff --git a/packages/ember-views/lib/mixins/view_context_support.js b/packages/ember-views/lib/mixins/view_context_support.js index 2ef8e939ba0..2ccfb79e90c 100644 --- a/packages/ember-views/lib/mixins/view_context_support.js +++ b/packages/ember-views/lib/mixins/view_context_support.js @@ -10,7 +10,7 @@ import LegacyViewSupport from 'ember-views/mixins/legacy_view_support'; import { observer } from 'ember-metal/mixin'; import { on } from 'ember-metal/events'; -var ViewContextSupport = Mixin.create(LegacyViewSupport, { +export default Mixin.create(LegacyViewSupport, { /** The object from which templates should access properties. @@ -103,5 +103,3 @@ var ViewContextSupport = Mixin.create(LegacyViewSupport, { this.notifyPropertyChange('controller'); }) }); - -export default ViewContextSupport; diff --git a/packages/ember-views/lib/mixins/view_state_support.js b/packages/ember-views/lib/mixins/view_state_support.js index 59289845bcd..1aa5c719820 100644 --- a/packages/ember-views/lib/mixins/view_state_support.js +++ b/packages/ember-views/lib/mixins/view_state_support.js @@ -1,6 +1,6 @@ import { Mixin } from 'ember-metal/mixin'; -var ViewStateSupport = Mixin.create({ +export default Mixin.create({ _transitionTo(state) { var priorState = this._currentState; var currentState = this._currentState = this._states[state]; @@ -10,5 +10,3 @@ var ViewStateSupport = Mixin.create({ if (currentState.enter) { currentState.enter(this); } } }); - -export default ViewStateSupport; diff --git a/packages/ember-views/lib/mixins/view_support.js b/packages/ember-views/lib/mixins/view_support.js index ec58ed6131d..53b9c620e57 100644 --- a/packages/ember-views/lib/mixins/view_support.js +++ b/packages/ember-views/lib/mixins/view_support.js @@ -30,10 +30,10 @@ export default Mixin.create({ @private */ nearestOfType(klass) { - var view = get(this, 'parentView'); - var isOfType = klass instanceof Mixin ? - function(view) { return klass.detect(view); } : - function(view) { return klass.detect(view.constructor); }; + let view = get(this, 'parentView'); + let isOfType = klass instanceof Mixin ? + view => klass.detect(view) : + view => klass.detect(view.constructor); while (view) { if (isOfType(view)) { return view; } @@ -50,7 +50,7 @@ export default Mixin.create({ @private */ nearestWithProperty(property) { - var view = get(this, 'parentView'); + let view = get(this, 'parentView'); while (view) { if (property in view) { return view; } @@ -111,11 +111,11 @@ export default Mixin.create({ }, forEachChildView(callback) { - var childViews = this.childViews; + let childViews = this.childViews; if (!childViews) { return this; } - var view, idx; + let view, idx; for (idx = 0; idx < childViews.length; idx++) { view = childViews[idx]; @@ -178,7 +178,7 @@ export default Mixin.create({ inserted directly into the DOM. ```js - var element = view.renderToElement(); + let element = view.renderToElement(); element.tagName; // => "BODY" ``` @@ -186,7 +186,7 @@ export default Mixin.create({ specifying an optional tag name as the first argument. ```js - var element = view.renderToElement('table'); + let element = view.renderToElement('table'); element.tagName; // => "TABLE" ``` @@ -197,7 +197,7 @@ export default Mixin.create({ ```js app.visit('/').then(function(instance) { - var element; + let element; Ember.run(function() { element = renderToElement(instance); }); @@ -214,7 +214,7 @@ export default Mixin.create({ renderToElement(tagName) { tagName = tagName || 'body'; - var element = this.renderer._dom.createElement(tagName); + let element = this.renderer._dom.createElement(tagName); this.renderer.appendTo(this, element); return element; @@ -235,7 +235,7 @@ export default Mixin.create({ @private */ replaceIn(selector) { - var target = jQuery(selector); + let target = jQuery(selector); assert('You tried to replace in (' + selector + ') but that isn\'t in the DOM', target.length > 0); assert('You cannot replace an existing Ember.View.', !target.is('.ember-view') && !target.parents().is('.ember-view')); @@ -303,7 +303,7 @@ export default Mixin.create({ ```javascript export default Ember.Component.extend({ setElementId: Ember.on('init', function() { - var index = this.get('index'); + let index = this.get('index'); this.set('elementId', 'component-id' + index); }) }); @@ -328,7 +328,7 @@ export default Mixin.create({ @private */ findElementInParentElement(parentElem) { - var id = '#' + this.elementId; + let id = '#' + this.elementId; return jQuery(id)[0] || jQuery(id, parentElem)[0]; }, @@ -606,7 +606,7 @@ export default Mixin.create({ @private */ removeFromParent() { - var parent = this.parentView; + let parent = this.parentView; // Remove DOM element from parent this.remove(); @@ -626,8 +626,8 @@ export default Mixin.create({ */ destroy() { // get parentView before calling super because it'll be destroyed - var parentView = this.parentView; - var viewName = this.viewName; + let parentView = this.parentView; + let viewName = this.viewName; if (!this._super(...arguments)) { return; } diff --git a/packages/ember-views/lib/mixins/visibility_support.js b/packages/ember-views/lib/mixins/visibility_support.js index c57961c8581..f5c180288b2 100644 --- a/packages/ember-views/lib/mixins/visibility_support.js +++ b/packages/ember-views/lib/mixins/visibility_support.js @@ -16,7 +16,7 @@ function K() { return this; } @namespace Ember @public */ -var VisibilitySupport = Mixin.create({ +export default Mixin.create({ /** If `false`, the view will appear hidden in DOM. @@ -43,8 +43,8 @@ var VisibilitySupport = Mixin.create({ }), _toggleVisibility() { - var $el = this.$(); - var isVisible = get(this, 'isVisible'); + let $el = this.$(); + let isVisible = get(this, 'isVisible'); if (this._isVisible === isVisible) { return ; } @@ -68,8 +68,8 @@ var VisibilitySupport = Mixin.create({ _notifyBecameVisible() { this.trigger('becameVisible'); - this.forEachChildView(function(view) { - var isVisible = get(view, 'isVisible'); + this.forEachChildView(view => { + let isVisible = get(view, 'isVisible'); if (isVisible || isVisible === null) { view._notifyBecameVisible(); @@ -79,8 +79,8 @@ var VisibilitySupport = Mixin.create({ _notifyBecameHidden() { this.trigger('becameHidden'); - this.forEachChildView(function(view) { - var isVisible = get(view, 'isVisible'); + this.forEachChildView(view => { + let isVisible = get(view, 'isVisible'); if (isVisible || isVisible === null) { view._notifyBecameHidden(); @@ -89,7 +89,7 @@ var VisibilitySupport = Mixin.create({ }, _isAncestorHidden() { - var parent = get(this, 'parentView'); + let parent = get(this, 'parentView'); while (parent) { if (get(parent, 'isVisible') === false) { return true; } @@ -100,5 +100,3 @@ var VisibilitySupport = Mixin.create({ return false; } }); - -export default VisibilitySupport; diff --git a/packages/ember-views/lib/system/action_manager.js b/packages/ember-views/lib/system/action_manager.js index 80af390d93b..cd600e2f4c3 100644 --- a/packages/ember-views/lib/system/action_manager.js +++ b/packages/ember-views/lib/system/action_manager.js @@ -3,7 +3,7 @@ @submodule ember-views */ -function ActionManager() {} +export default function ActionManager() {} /** Global action id hash. @@ -13,5 +13,3 @@ function ActionManager() {} @type Object */ ActionManager.registeredActions = {}; - -export default ActionManager; diff --git a/packages/ember-views/lib/system/event_dispatcher.js b/packages/ember-views/lib/system/event_dispatcher.js index 1f1335967ac..6975db2ea62 100644 --- a/packages/ember-views/lib/system/event_dispatcher.js +++ b/packages/ember-views/lib/system/event_dispatcher.js @@ -16,8 +16,8 @@ import assign from 'ember-metal/assign'; import { getOwner } from 'container/owner'; import { environment } from 'ember-environment'; -let ROOT_ELEMENT_CLASS = 'ember-application'; -let ROOT_ELEMENT_SELECTOR = '.' + ROOT_ELEMENT_CLASS; +const ROOT_ELEMENT_CLASS = 'ember-application'; +const ROOT_ELEMENT_SELECTOR = '.' + ROOT_ELEMENT_CLASS; /** `Ember.EventDispatcher` handles delegating browser events to their @@ -40,7 +40,7 @@ export default EmberObject.extend({ To add new events to be listened to: ```javascript - var App = Ember.Application.create({ + let App = Ember.Application.create({ customEvents: { paste: 'paste' } @@ -50,7 +50,7 @@ export default EmberObject.extend({ To prevent default events from being listened to: ```javascript - var App = Ember.Application.create({ + let App = Ember.Application.create({ customEvents: { mouseenter: null, mouseleave: null @@ -117,7 +117,7 @@ export default EmberObject.extend({ `eventManager` on the view tree. ```javascript - var EventDispatcher = Em.EventDispatcher.extend({ + let EventDispatcher = Em.EventDispatcher.extend({ events: { click : 'click', focusin : 'focusIn', @@ -155,8 +155,8 @@ export default EmberObject.extend({ @param addedEvents {Object} */ setup(addedEvents, rootElement) { - var event; - var events = this._finalEvents = assign({}, get(this, 'events'), addedEvents); + let event; + let events = this._finalEvents = assign({}, get(this, 'events'), addedEvents); if (!isNone(rootElement)) { set(this, 'rootElement', rootElement); @@ -194,7 +194,7 @@ export default EmberObject.extend({ @param {String} eventName the name of the method to call on the view */ setupHandler(rootElement, event, eventName) { - var self = this; + let self = this; let owner = getOwner(this); let viewRegistry = owner && owner.lookup('-view-registry:main') || View.views; @@ -204,10 +204,10 @@ export default EmberObject.extend({ } rootElement.on(event + '.ember', '.ember-view', function(evt, triggeringManager) { - var view = viewRegistry[this.id]; - var result = true; + let view = viewRegistry[this.id]; + let result = true; - var manager = self.canDispatchToEventManager ? self._findNearestEventManager(view, eventName) : null; + let manager = self.canDispatchToEventManager ? self._findNearestEventManager(view, eventName) : null; if (manager && manager !== triggeringManager) { result = self._dispatchEvent(manager, evt, eventName, view); @@ -219,22 +219,22 @@ export default EmberObject.extend({ }); rootElement.on(event + '.ember', '[data-ember-action]', function(evt) { - var actionId = jQuery(evt.currentTarget).attr('data-ember-action'); - var actions = ActionManager.registeredActions[actionId]; + let actionId = jQuery(evt.currentTarget).attr('data-ember-action'); + let actions = ActionManager.registeredActions[actionId]; // In Glimmer2 this attribute is set to an empty string and an additional // attribute it set for each action on a given element. In this case, the // attributes need to be read so that a proper set of action handlers can // be coalesced. if (actionId === '') { - var attributes = evt.currentTarget.attributes; - var attributeCount = attributes.length; + let attributes = evt.currentTarget.attributes; + let attributeCount = attributes.length; actions = []; - for (var i = 0; i < attributeCount; i++) { - var attr = attributes.item(i); - var attrName = attr.name; + for (let i = 0; i < attributeCount; i++) { + let attr = attributes.item(i); + let attrName = attr.name; if (attrName.indexOf('data-ember-action-') === 0) { actions = actions.concat(ActionManager.registeredActions[attr.value]); @@ -260,7 +260,7 @@ export default EmberObject.extend({ }, _findNearestEventManager(view, eventName) { - var manager = null; + let manager = null; while (view) { manager = get(view, 'eventManager'); @@ -273,9 +273,9 @@ export default EmberObject.extend({ }, _dispatchEvent(object, evt, eventName, view) { - var result = true; + let result = true; - var handler = object[eventName]; + let handler = object[eventName]; if (typeof handler === 'function') { result = run(object, handler, evt, view); // Do not preventDefault in eventManagers. @@ -292,7 +292,7 @@ export default EmberObject.extend({ }, destroy() { - var rootElement = get(this, 'rootElement'); + let rootElement = get(this, 'rootElement'); jQuery(rootElement).off('.ember', '**').removeClass(ROOT_ELEMENT_CLASS); return this._super(...arguments); }, diff --git a/packages/ember-views/lib/system/jquery.js b/packages/ember-views/lib/system/jquery.js index 6c3440444f4..6e02411eb2d 100644 --- a/packages/ember-views/lib/system/jquery.js +++ b/packages/ember-views/lib/system/jquery.js @@ -19,7 +19,7 @@ if (environment.hasDOM) { 'dragover', 'drop', 'dragend' - ].forEach(function(eventName) { + ].forEach(eventName => { jQuery.event.fixHooks[eventName] = { props: ['dataTransfer'] }; diff --git a/packages/ember-views/lib/system/platform.js b/packages/ember-views/lib/system/platform.js index 00e7dc60f7a..8b2dcd3eb49 100644 --- a/packages/ember-views/lib/system/platform.js +++ b/packages/ember-views/lib/system/platform.js @@ -3,9 +3,9 @@ import { environment } from 'ember-environment'; // IE 6/7 have bugs around setting names on inputs during creation. // From http://msdn.microsoft.com/en-us/library/ie/ms536389(v=vs.85).aspx: // "To include the NAME attribute at run time on objects created with the createElement method, use the eTag." -export var canSetNameOnInputs = environment.hasDOM && (function() { - var div = document.createElement('div'); - var el = document.createElement('input'); +export let canSetNameOnInputs = environment.hasDOM && (function() { + let div = document.createElement('div'); + let el = document.createElement('input'); el.setAttribute('name', 'foo'); div.appendChild(el); diff --git a/packages/ember-views/lib/system/utils.js b/packages/ember-views/lib/system/utils.js index 6ce6c70ff38..7b9b6ecf6b2 100644 --- a/packages/ember-views/lib/system/utils.js +++ b/packages/ember-views/lib/system/utils.js @@ -4,8 +4,8 @@ */ export function isSimpleClick(event) { - var modifier = event.shiftKey || event.metaKey || event.altKey || event.ctrlKey; - var secondaryClick = event.which > 1; // IE9 may return undefined + let modifier = event.shiftKey || event.metaKey || event.altKey || event.ctrlKey; + let secondaryClick = event.which > 1; // IE9 may return undefined return !modifier && !secondaryClick; } @@ -16,7 +16,7 @@ export function isSimpleClick(event) { @param {Ember.View} view */ function getViewRange(view) { - var range = document.createRange(); + let range = document.createRange(); range.setStartBefore(view._renderNode.firstNode); range.setEndAfter(view._renderNode.lastNode); return range; @@ -34,7 +34,7 @@ function getViewRange(view) { @param {Ember.View} view */ export function getViewClientRects(view) { - var range = getViewRange(view); + let range = getViewRange(view); return range.getClientRects(); } @@ -50,6 +50,6 @@ export function getViewClientRects(view) { @param {Ember.View} view */ export function getViewBoundingClientRect(view) { - var range = getViewRange(view); + let range = getViewRange(view); return range.getBoundingClientRect(); } diff --git a/packages/ember-views/lib/views/core_view.js b/packages/ember-views/lib/views/core_view.js index 3b69aa1d372..b19bc5df9fe 100644 --- a/packages/ember-views/lib/views/core_view.js +++ b/packages/ember-views/lib/views/core_view.js @@ -14,7 +14,7 @@ import require from 'require'; // container (e.g. `Ember.View.create().append()`) then we create a fallback // DOM renderer that is shared. In general, this path should be avoided since // views created this way cannot run in a node environment. -var renderer; +let renderer; /** `Ember.CoreView` is an abstract class that exists to give view-like behavior @@ -46,7 +46,7 @@ const CoreView = EmberObject.extend(Evented, ActionHandler, { // Fallback for legacy cases where the view was created directly // via `create()` instead of going through the container. if (!this.renderer) { - var DOMHelper = domHelper(); + let DOMHelper = domHelper(); renderer = renderer || InteractiveRenderer.create({ dom: new DOMHelper() }); this.renderer = renderer; } @@ -84,11 +84,11 @@ const CoreView = EmberObject.extend(Evented, ActionHandler, { */ trigger() { this._super(...arguments); - var name = arguments[0]; - var method = this[name]; + let name = arguments[0]; + let method = this[name]; if (method) { - var args = new Array(arguments.length - 1); - for (var i = 1; i < arguments.length; i++) { + let args = new Array(arguments.length - 1); + for (let i = 1; i < arguments.length; i++) { args[i - 1] = arguments[i]; } return method.apply(this, args); @@ -114,7 +114,7 @@ CoreView.reopenClass({ isViewFactory: true }); -var _domHelper; +let _domHelper; function domHelper() { return _domHelper = _domHelper || require('ember-htmlbars/system/dom-helper').default; } diff --git a/packages/ember-views/lib/views/states.js b/packages/ember-views/lib/views/states.js index 92735d0d945..4377f261193 100644 --- a/packages/ember-views/lib/views/states.js +++ b/packages/ember-views/lib/views/states.js @@ -6,7 +6,7 @@ import inDOM from 'ember-views/views/states/in_dom'; import destroying from 'ember-views/views/states/destroying'; export function cloneStates(from) { - var into = {}; + let into = {}; into._default = {}; into.preRender = Object.create(into._default); @@ -14,7 +14,7 @@ export function cloneStates(from) { into.hasElement = Object.create(into._default); into.inDOM = Object.create(into.hasElement); - for (var stateName in from) { + for (let stateName in from) { if (!from.hasOwnProperty(stateName)) { continue; } assign(into[stateName], from[stateName]); } @@ -22,7 +22,7 @@ export function cloneStates(from) { return into; } -export var states = { +export let states = { _default: _default, preRender: preRender, inDOM: inDOM, diff --git a/packages/ember-views/lib/views/states/destroying.js b/packages/ember-views/lib/views/states/destroying.js index 2899505b8a4..2ea1e59707f 100644 --- a/packages/ember-views/lib/views/states/destroying.js +++ b/packages/ember-views/lib/views/states/destroying.js @@ -6,7 +6,7 @@ import EmberError from 'ember-metal/error'; @submodule ember-views */ -var destroying = Object.create(_default); +const destroying = Object.create(_default); assign(destroying, { appendChild() { diff --git a/packages/ember-views/lib/views/states/has_element.js b/packages/ember-views/lib/views/states/has_element.js index 035218d375b..53ac1fa2ffc 100644 --- a/packages/ember-views/lib/views/states/has_element.js +++ b/packages/ember-views/lib/views/states/has_element.js @@ -11,16 +11,16 @@ import { flaggedInstrument } from 'ember-metal/instrumentation'; import { get } from 'ember-metal/property_get'; -var hasElement = Object.create(_default); +const hasElement = Object.create(_default); assign(hasElement, { $(view, sel) { - var elem = view.element; + let elem = view.element; return sel ? jQuery(sel, elem) : jQuery(elem); }, getElement(view) { - var parent = get(view, 'parentView'); + let parent = get(view, 'parentView'); if (parent) { parent = get(parent, 'element'); } if (parent) { return view.findElementInParentElement(parent); } return jQuery('#' + get(view, 'elementId'))[0]; diff --git a/packages/ember-views/lib/views/states/in_dom.js b/packages/ember-views/lib/views/states/in_dom.js index 35119bd6796..b0edeec8334 100644 --- a/packages/ember-views/lib/views/states/in_dom.js +++ b/packages/ember-views/lib/views/states/in_dom.js @@ -9,7 +9,7 @@ import hasElement from 'ember-views/views/states/has_element'; @submodule ember-views */ -var inDOM = Object.create(hasElement); +const inDOM = Object.create(hasElement); assign(inDOM, { enter(view) { @@ -19,8 +19,8 @@ assign(inDOM, { view._register(); } - runInDebug(function() { - _addBeforeObserver(view, 'elementId', function() { + runInDebug(() => { + _addBeforeObserver(view, 'elementId', () => { throw new EmberError('Changing a view\'s elementId after creation is not allowed'); }); }); diff --git a/packages/ember-views/tests/mixins/view_target_action_support_test.js b/packages/ember-views/tests/mixins/view_target_action_support_test.js index 40322e604cf..025878e2faa 100644 --- a/packages/ember-views/tests/mixins/view_target_action_support_test.js +++ b/packages/ember-views/tests/mixins/view_target_action_support_test.js @@ -7,7 +7,7 @@ QUnit.module('ViewTargetActionSupport'); QUnit.test('it should return false if no action is specified', function() { expect(1); - var view = View.extend(ViewTargetActionSupport).create({ + let view = View.extend(ViewTargetActionSupport).create({ controller: EmberObject.create() }); @@ -17,7 +17,7 @@ QUnit.test('it should return false if no action is specified', function() { QUnit.test('it should support actions specified as strings', function() { expect(2); - var view = View.extend(ViewTargetActionSupport).create({ + let view = View.extend(ViewTargetActionSupport).create({ controller: EmberObject.create({ anEvent() { ok(true, 'anEvent method was called'); @@ -32,7 +32,7 @@ QUnit.test('it should support actions specified as strings', function() { QUnit.test('it should invoke the send() method on the controller with the view\'s context', function() { expect(3); - var view = View.extend(ViewTargetActionSupport, { + let view = View.extend(ViewTargetActionSupport, { controller: EmberObject.create({ send(evt, context) { equal(evt, 'anEvent', 'send() method was invoked with correct event name'); diff --git a/packages/ember-views/tests/system/event_dispatcher_test.js b/packages/ember-views/tests/system/event_dispatcher_test.js index 334edb16def..05ebc73bf88 100644 --- a/packages/ember-views/tests/system/event_dispatcher_test.js +++ b/packages/ember-views/tests/system/event_dispatcher_test.js @@ -14,8 +14,8 @@ import { OWNER } from 'container/owner'; import { runAppend, runDestroy } from 'ember-runtime/tests/utils'; import { subscribe, reset } from 'ember-metal/instrumentation'; -var owner, view; -var dispatcher; +let owner, view; +let dispatcher; import isEnabled from 'ember-metal/features'; @@ -44,7 +44,7 @@ if (isEnabled('ember-improved-instrumentation')) { QUnit.test('should instrument triggered events', function() { let clicked = 0; - run(function () { + run(() => { view = View.create({ click(evt) { clicked++; @@ -93,7 +93,7 @@ if (isEnabled('ember-improved-instrumentation')) { } QUnit.test('should not dispatch events to views not inDOM', function() { - var receivedEvent; + let receivedEvent; view = View.extend({ mouseDown(evt) { @@ -103,13 +103,11 @@ QUnit.test('should not dispatch events to views not inDOM', function() { template: compile('some awesome content') }); - run(function() { - view.append(); - }); + run(() => view.append()); - var $element = view.$(); + let $element = view.$(); - run(function() { + run(() => { // TODO change this test not to use private API // Force into preRender view.renderer.remove(view, false, true); @@ -129,7 +127,7 @@ QUnit.test('should not dispatch events to views not inDOM', function() { }); QUnit.test('should send change events up view hierarchy if view contains form elements', function() { - var receivedEvent; + let receivedEvent; view = View.create({ template: compile(''), @@ -138,9 +136,7 @@ QUnit.test('should send change events up view hierarchy if view contains form el } }); - run(function() { - view.append(); - }); + run(() => view.append()); jQuery('#is-done').trigger('change'); ok(receivedEvent, 'calls change method when a child element is changed'); @@ -148,15 +144,13 @@ QUnit.test('should send change events up view hierarchy if view contains form el }); QUnit.test('events should stop propagating if the view is destroyed', function() { - var parentComponentReceived, receivedEvent; + let parentComponentReceived, receivedEvent; owner.register('component:x-foo', Component.extend({ layout: compile(''), change(evt) { receivedEvent = true; - run(() => { - get(this, 'parentView').destroy(); - }); + run(() => get(this, 'parentView').destroy()); } })); @@ -178,7 +172,7 @@ QUnit.test('events should stop propagating if the view is destroyed', function() }); QUnit.test('should dispatch events to nearest event manager', function() { - var receivedEvent = 0; + let receivedEvent = 0; view = View.create({ template: compile(''), @@ -191,16 +185,14 @@ QUnit.test('should dispatch events to nearest event manager', function() { mouseDown() {} }); - run(function() { - view.append(); - }); + run(() => view.append()); jQuery('#is-done').trigger('mousedown'); equal(receivedEvent, 1, 'event should go to manager and not view'); }); QUnit.test('event manager should be able to re-dispatch events to view', function() { - var receivedEvent = 0; + let receivedEvent = 0; owner.register('component:x-foo', Component.extend({ elementId: 'nestedView', @@ -252,14 +244,14 @@ QUnit.test('event handlers should be wrapped in a run loop', function() { elementId: 'test-view' }); - run(function() { view.append(); }); + run(() => view.append()); jQuery('#test-view').trigger('mousedown'); }); QUnit.module('EventDispatcher#setup', { setup() { - run(function() { + run(() => { dispatcher = EventDispatcher.create({ rootElement: '#qunit-fixture' }); @@ -267,7 +259,7 @@ QUnit.module('EventDispatcher#setup', { }, teardown() { - run(function() { + run(() => { if (view) { view.destroy(); } dispatcher.destroy(); }); @@ -277,7 +269,7 @@ QUnit.module('EventDispatcher#setup', { QUnit.test('additional events which should be listened on can be passed', function () { expect(1); - run(function () { + run(() => { dispatcher.setup({ myevent: 'myEvent' }); view = View.create({ @@ -296,7 +288,7 @@ QUnit.test('additional events and rootElement can be specified', function () { jQuery('#qunit-fixture').append('
'); - run(function () { + run(() => { dispatcher.setup({ myevent: 'myEvent' }, '.custom-root'); view = View.create({ @@ -316,7 +308,7 @@ QUnit.test('additional events and rootElement can be specified', function () { QUnit.test('default events can be disabled via `customEvents`', function () { expect(1); - run(function () { + run(() => { dispatcher.setup({ click: null }); diff --git a/packages/ember-views/tests/system/jquery_ext_test.js b/packages/ember-views/tests/system/jquery_ext_test.js index d248bb9f330..35f65d4f210 100644 --- a/packages/ember-views/tests/system/jquery_ext_test.js +++ b/packages/ember-views/tests/system/jquery_ext_test.js @@ -3,14 +3,14 @@ import EventDispatcher from 'ember-views/system/event_dispatcher'; import jQuery from 'ember-views/system/jquery'; import View from 'ember-views/views/view'; -var view, dispatcher; +let view, dispatcher; // Adapted from https://github.com/jquery/jquery/blob/f30f7732e7775b6e417c4c22ced7adb2bf76bf89/test/data/testinit.js -var canDataTransfer = !!document.createEvent('HTMLEvents').dataTransfer; +let canDataTransfer = !!document.createEvent('HTMLEvents').dataTransfer; function fireNativeWithDataTransfer(node, type, dataTransfer) { - var event = document.createEvent('HTMLEvents'); + let event = document.createEvent('HTMLEvents'); event.initEvent(type, true, true); event.dataTransfer = dataTransfer; node.dispatchEvent(event); @@ -18,14 +18,14 @@ function fireNativeWithDataTransfer(node, type, dataTransfer) { QUnit.module('EventDispatcher - jQuery integration', { setup() { - run(function() { + run(() => { dispatcher = EventDispatcher.create(); dispatcher.setup(); }); }, teardown() { - run(function() { + run(() => { if (view) { view.destroy(); } dispatcher.destroy(); }); @@ -34,8 +34,8 @@ QUnit.module('EventDispatcher - jQuery integration', { if (canDataTransfer) { QUnit.test('jQuery.event.fix copies over the dataTransfer property', function() { - var originalEvent; - var receivedEvent; + let originalEvent; + let receivedEvent; originalEvent = { type: 'drop', @@ -50,8 +50,8 @@ if (canDataTransfer) { }); QUnit.test('drop handler should receive event with dataTransfer property', function() { - var receivedEvent; - var dropCalled = 0; + let receivedEvent; + let dropCalled = 0; view = View.extend({ drop(evt) { @@ -60,9 +60,7 @@ if (canDataTransfer) { } }).create(); - run(function() { - view.append(); - }); + run(() => view.append()); fireNativeWithDataTransfer(view.$().get(0), 'drop', 'success'); diff --git a/packages/ember-views/tests/system/view_utils_test.js b/packages/ember-views/tests/system/view_utils_test.js index cff428187b0..20fdae9b9a0 100644 --- a/packages/ember-views/tests/system/view_utils_test.js +++ b/packages/ember-views/tests/system/view_utils_test.js @@ -5,32 +5,32 @@ import { getViewBoundingClientRect } from 'ember-views/system/utils'; -var hasGetClientRects, hasGetBoundingClientRect; -var ClientRectListCtor, ClientRectCtor; +let hasGetClientRects, hasGetBoundingClientRect; +let ClientRectListCtor, ClientRectCtor; (function() { if (document.createRange) { - var range = document.createRange(); + let range = document.createRange(); if (range.getClientRects) { - var clientRectsList = range.getClientRects(); + let clientRectsList = range.getClientRects(); hasGetClientRects = true; ClientRectListCtor = clientRectsList && clientRectsList.constructor; } if (range.getBoundingClientRect) { - var clientRect = range.getBoundingClientRect(); + let clientRect = range.getBoundingClientRect(); hasGetBoundingClientRect = true; ClientRectCtor = clientRect && clientRect.constructor; } } })(); -var view; +let view; QUnit.module('ViewUtils', { teardown() { - run(function() { + run(() => { if (view) { view.destroy(); } }); } @@ -45,7 +45,7 @@ QUnit.test('getViewClientRects', function() { view = View.create(); - run(function() { view.appendTo('#qunit-fixture'); }); + run(() => view.appendTo('#qunit-fixture')); ok(getViewClientRects(view) instanceof ClientRectListCtor); }); @@ -58,7 +58,7 @@ QUnit.test('getViewBoundingClientRect', function() { view = View.create(); - run(function() { view.appendTo('#qunit-fixture'); }); + run(() => view.appendTo('#qunit-fixture')); ok(getViewBoundingClientRect(view) instanceof ClientRectCtor); }); diff --git a/packages/ember-views/tests/test-helpers/equal-html.js b/packages/ember-views/tests/test-helpers/equal-html.js index f0b8d28399b..8c831ec9b4c 100644 --- a/packages/ember-views/tests/test-helpers/equal-html.js +++ b/packages/ember-views/tests/test-helpers/equal-html.js @@ -1,10 +1,10 @@ export function equalHTML(element, expectedHTML, message) { - var html; + let html; if (typeof element === 'string') { html = document.getElementById(element).innerHTML; } else { if (element instanceof window.NodeList) { - var fragment = document.createElement('div'); + let fragment = document.createElement('div'); while (element[0]) { fragment.appendChild(element[0]); } @@ -14,10 +14,8 @@ export function equalHTML(element, expectedHTML, message) { } } - var actualHTML = html.replace(/ id="[^"]+"/gmi, ''); - actualHTML = actualHTML.replace(/<\/?([A-Z]+)/gi, function(tag) { - return tag.toLowerCase(); - }); + let actualHTML = html.replace(/ id="[^"]+"/gmi, ''); + actualHTML = actualHTML.replace(/<\/?([A-Z]+)/gi, tag => tag.toLowerCase()); actualHTML = actualHTML.replace(/\r\n/gm, ''); actualHTML = actualHTML.replace(/ $/, ''); equal(actualHTML, expectedHTML, message || 'HTML matches'); diff --git a/packages/ember-views/tests/test-helpers/get-element-style.js b/packages/ember-views/tests/test-helpers/get-element-style.js index 044a7b71429..5f6b6f3f240 100644 --- a/packages/ember-views/tests/test-helpers/get-element-style.js +++ b/packages/ember-views/tests/test-helpers/get-element-style.js @@ -1,5 +1,5 @@ export default function(element) { - var style = element.getAttribute('style'); + let style = element.getAttribute('style'); style = style.toUpperCase(); // IE8 keeps this is uppercase, so lets just upcase them all if (style !== '' && style.slice(-1) !== ';') { diff --git a/packages/ember-views/tests/views/checkbox_test.js b/packages/ember-views/tests/views/checkbox_test.js index d4cd8db01dc..99c16b974e8 100644 --- a/packages/ember-views/tests/views/checkbox_test.js +++ b/packages/ember-views/tests/views/checkbox_test.js @@ -6,16 +6,14 @@ import run from 'ember-metal/run_loop'; import EventDispatcher from 'ember-views/system/event_dispatcher'; function set(obj, key, value) { - run(function() { o_set(obj, key, value); }); + run(() => o_set(obj, key, value)); } function append() { - run(function() { - checkboxComponent.appendTo('#qunit-fixture'); - }); + run(() => checkboxComponent.appendTo('#qunit-fixture')); } -var checkboxComponent, dispatcher; +let checkboxComponent, dispatcher; QUnit.module('Ember.Checkbox', { setup() { @@ -24,7 +22,7 @@ QUnit.module('Ember.Checkbox', { }, teardown() { - run(function() { + run(() => { dispatcher.destroy(); checkboxComponent.destroy(); }); @@ -46,10 +44,10 @@ QUnit.test('should become disabled if the disabled attribute is changed', functi append(); ok(checkboxComponent.$().is(':not(:disabled)')); - run(function() { checkboxComponent.set('disabled', true); }); + run(() => checkboxComponent.set('disabled', true)); ok(checkboxComponent.$().is(':disabled')); - run(function() { checkboxComponent.set('disabled', false); }); + run(() => checkboxComponent.set('disabled', false)); ok(checkboxComponent.$().is(':not(:disabled)')); }); @@ -69,41 +67,41 @@ QUnit.test('should become indeterminate if the indeterminate attribute is change equal(checkboxComponent.$().prop('indeterminate'), false, 'Checkbox should not be indeterminate'); - run(function() { checkboxComponent.set('indeterminate', true); }); + run(() => checkboxComponent.set('indeterminate', true)); equal(checkboxComponent.$().prop('indeterminate'), true, 'Checkbox should be indeterminate'); - run(function() { checkboxComponent.set('indeterminate', false); }); + run(() => checkboxComponent.set('indeterminate', false)); equal(checkboxComponent.$().prop('indeterminate'), false, 'Checkbox should not be indeterminate'); }); QUnit.test('should support the tabindex property', function() { checkboxComponent = Checkbox.create({}); - run(function() { checkboxComponent.set('tabindex', 6); }); + run(() => checkboxComponent.set('tabindex', 6)); append(); equal(checkboxComponent.$().prop('tabindex'), '6', 'the initial checkbox tabindex is set in the DOM'); - run(function() { checkboxComponent.set('tabindex', 3); }); + run(() => checkboxComponent.set('tabindex', 3)); equal(checkboxComponent.$().prop('tabindex'), '3', 'the checkbox tabindex changes when it is changed in the component'); }); QUnit.test('checkbox name is updated when setting name property of view', function() { checkboxComponent = Checkbox.create({}); - run(function() { checkboxComponent.set('name', 'foo'); }); + run(() => checkboxComponent.set('name', 'foo')); append(); equal(checkboxComponent.$().attr('name'), 'foo', 'renders checkbox with the name'); - run(function() { checkboxComponent.set('name', 'bar'); }); + run(() => checkboxComponent.set('name', 'bar')); equal(checkboxComponent.$().attr('name'), 'bar', 'updates checkbox after name changes'); }); QUnit.test('checked property mirrors input value', function() { checkboxComponent = Checkbox.create({}); - run(function() { checkboxComponent.append(); }); + run(() => checkboxComponent.append()); equal(get(checkboxComponent, 'checked'), false, 'initially starts with a false value'); equal(!!checkboxComponent.$().prop('checked'), false, 'the initial checked property is false'); @@ -112,14 +110,14 @@ QUnit.test('checked property mirrors input value', function() { equal(checkboxComponent.$().prop('checked'), true, 'changing the value property changes the DOM'); - run(function() { checkboxComponent.remove(); }); - run(function() { checkboxComponent.append(); }); + run(() => checkboxComponent.remove()); + run(() => checkboxComponent.append()); equal(checkboxComponent.$().prop('checked'), true, 'changing the value property changes the DOM'); - run(function() { checkboxComponent.remove(); }); - run(function() { set(checkboxComponent, 'checked', false); }); - run(function() { checkboxComponent.append(); }); + run(() => checkboxComponent.remove()); + run(() => set(checkboxComponent, 'checked', false)); + run(() => checkboxComponent.append()); equal(checkboxComponent.$().prop('checked'), false, 'changing the value property changes the DOM'); }); diff --git a/packages/ember-views/tests/views/component_test.js b/packages/ember-views/tests/views/component_test.js index a609c8badbd..081c9f26fa4 100644 --- a/packages/ember-views/tests/views/component_test.js +++ b/packages/ember-views/tests/views/component_test.js @@ -11,16 +11,16 @@ import { MUTABLE_CELL } from 'ember-views/compat/attrs-proxy'; import buildOwner from 'container/tests/test-helpers/build-owner'; import computed from 'ember-metal/computed'; -var a_slice = Array.prototype.slice; +const a_slice = Array.prototype.slice; -var component, controller, actionCounts, sendCount, actionArguments; +let component, controller, actionCounts, sendCount, actionArguments; QUnit.module('Ember.Component', { setup() { component = Component.create(); }, teardown() { - run(function() { + run(() => { if (component) { component.destroy(); } if (controller) { controller.destroy(); } }); @@ -32,7 +32,7 @@ QUnit.test('throws an error if `this._super` is not called from `init`', functio init() { } }); - expectAssertion(function() { + expectAssertion(() => { TestComponent.create(); }, /You must call `this._super\(...arguments\);` when implementing `init` in a component. Please update .* to call `this._super` from `init`/); }); @@ -42,13 +42,13 @@ QUnit.test('can access `actions` hash via `_actions` [DEPRECATED]', function() { component = Component.extend({ actions: { - foo: function() { + foo() { ok(true, 'called foo action'); } } }).create(); - expectDeprecation(function() { + expectDeprecation(() => { component._actions.foo(); }, 'Usage of `_actions` is deprecated, use `actions` instead.'); }); @@ -62,7 +62,7 @@ QUnit.test('The controller (target of `action`) of an Ember.Component is itself' }); QUnit.test('Specifying a defaultLayout to a component is deprecated', function() { - expectDeprecation(function() { + expectDeprecation(() => { Component.extend({ defaultLayout: 'hum-drum' }).create(); @@ -70,7 +70,7 @@ QUnit.test('Specifying a defaultLayout to a component is deprecated', function() }); QUnit.test('should warn if a computed property is used for classNames', function() { - expectAssertion(function() { + expectAssertion(() => { Component.extend({ elementId: 'test', classNames: computed(function() { @@ -81,7 +81,7 @@ QUnit.test('should warn if a computed property is used for classNames', function }); QUnit.test('should warn if a non-array is used for classNameBindings', function() { - expectAssertion(function() { + expectAssertion(() => { Component.extend({ elementId: 'test', classNameBindings: computed(function() { @@ -114,7 +114,7 @@ QUnit.module('Ember.Component - Actions', { }, teardown() { - run(function() { + run(() => { component.destroy(); controller.destroy(); }); @@ -146,7 +146,7 @@ QUnit.test('Calling sendAction on a component with a function calls the function QUnit.test('Calling sendAction on a component with a function calls the function with arguments', function() { expect(1); - var argument = {}; + let argument = {}; set(component, 'action', function(actualArgument) { equal(actualArgument, argument, 'argument is passed'); }); @@ -155,7 +155,7 @@ QUnit.test('Calling sendAction on a component with a function calls the function }); QUnit.test('Calling sendAction on a component with a mut attr calls the function with arguments', function() { - var mut = { + let mut = { value: 'didStartPlaying', [MUTABLE_CELL]: true }; @@ -192,19 +192,15 @@ QUnit.test('Calling sendAction when the action name is not a string raises an ex set(component, 'action', {}); set(component, 'playing', {}); - expectAssertion(function() { - component.sendAction(); - }); + expectAssertion(() => component.sendAction()); - expectAssertion(function() { - component.sendAction('playing'); - }); + expectAssertion(() => component.sendAction('playing')); }); QUnit.test('Calling sendAction on a component with a context', function() { set(component, 'playing', 'didStartPlaying'); - var testContext = { song: 'She Broke My Ember' }; + let testContext = { song: 'She Broke My Ember' }; component.sendAction('playing', testContext); @@ -214,8 +210,8 @@ QUnit.test('Calling sendAction on a component with a context', function() { QUnit.test('Calling sendAction on a component with multiple parameters', function() { set(component, 'playing', 'didStartPlaying'); - var firstContext = { song: 'She Broke My Ember' }; - var secondContext = { song: 'My Achey Breaky Ember' }; + let firstContext = { song: 'She Broke My Ember' }; + let secondContext = { song: 'My Achey Breaky Ember' }; component.sendAction('playing', firstContext, secondContext); @@ -233,8 +229,8 @@ QUnit.test('services can be injected into components', function() { owner.register('service:profiler', Service.extend()); - var appComponent = owner.lookup('component:application'); - var profilerService = owner.lookup('service:profiler'); + let appComponent = owner.lookup('component:application'); + let profilerService = owner.lookup('service:profiler'); equal(profilerService, appComponent.get('profilerService'), 'service.profiler is injected'); }); @@ -244,7 +240,7 @@ QUnit.module('Ember.Component - subscribed and sent actions trigger errors'); QUnit.test('something', function() { expect(2); - var appComponent = Component.extend({ + let appComponent = Component.extend({ actions: { foo(message) { equal('bar', message); @@ -254,22 +250,20 @@ QUnit.test('something', function() { appComponent.send('foo', 'bar'); - throws(function() { - appComponent.send('baz', 'bar'); - }, /had no action handler for: baz/, 'asdf'); + throws(() => appComponent.send('baz', 'bar'), /had no action handler for: baz/, 'asdf'); }); QUnit.test('component with target', function() { expect(2); - var target = { + let target = { send(message, payload) { equal('foo', message); equal('baz', payload); } }; - var appComponent = Component.create({ + let appComponent = Component.create({ target: target }); diff --git a/packages/ember-views/tests/views/instrumentation_test.js b/packages/ember-views/tests/views/instrumentation_test.js index 8c6d83cb402..08d5328f6e6 100644 --- a/packages/ember-views/tests/views/instrumentation_test.js +++ b/packages/ember-views/tests/views/instrumentation_test.js @@ -5,7 +5,7 @@ import { import run from 'ember-metal/run_loop'; import EmberView from 'ember-views/views/view'; -var view, beforeCalls, afterCalls; +let view, beforeCalls, afterCalls; function confirmPayload(payload, view) { equal(payload && payload.object, view.toString(), 'payload object equals view.toString()'); @@ -44,7 +44,7 @@ QUnit.module('EmberView#instrumentation', { }); QUnit.test('generates the proper instrumentation details when called directly', function() { - var payload = {}; + let payload = {}; view.instrumentDetails(payload); diff --git a/packages/ember-views/tests/views/text_area_test.js b/packages/ember-views/tests/views/text_area_test.js index 7e59a9c4129..41f9276ce40 100644 --- a/packages/ember-views/tests/views/text_area_test.js +++ b/packages/ember-views/tests/views/text_area_test.js @@ -4,16 +4,14 @@ import TextArea from 'ember-htmlbars/components/text_area'; import { get } from 'ember-metal/property_get'; import { set as o_set } from 'ember-metal/property_set'; -var textArea, TestObject; +let textArea, TestObject; function set(object, key, value) { - run(function() { o_set(object, key, value); }); + run(() => o_set(object, key, value)); } function append() { - run(function() { - textArea.appendTo('#qunit-fixture'); - }); + run(() => textArea.appendTo('#qunit-fixture')); } QUnit.module('TextArea', { @@ -26,9 +24,7 @@ QUnit.module('TextArea', { }, teardown() { - run(function() { - textArea.destroy(); - }); + run(() => textArea.destroy()); TestObject = window.TestObject = textArea = null; } @@ -45,43 +41,43 @@ QUnit.test('should become disabled if the disabled attribute is true', function( append(); ok(textArea.$().is(':not(:disabled)')); - run(function() { textArea.set('disabled', true); }); + run(() => textArea.set('disabled', true)); ok(textArea.$().is(':disabled')); - run(function() { textArea.set('disabled', false); }); + run(() => textArea.set('disabled', false)); ok(textArea.$().is(':not(:disabled)')); }); ['placeholder', 'name', 'title', 'maxlength', 'rows', 'cols', 'tabindex'].forEach(function(attributeName) { QUnit.test(`text area ${attributeName} is updated when setting ${attributeName} property of view`, function() { - run(function() { + run(() => { set(textArea, attributeName, '1'); textArea.append(); }); equal(textArea.$().attr(attributeName), '1', 'renders text area with ' + attributeName); - run(function() { set(textArea, attributeName, '2'); }); + run(() => set(textArea, attributeName, '2')); equal(textArea.$().attr(attributeName), '2', `updates text area after ${attributeName} changes`); }); }); QUnit.test('text area value is updated when setting value property of view', function() { - run(function() { + run(() => { set(textArea, 'value', 'foo'); textArea.append(); }); equal(textArea.$().val(), 'foo', 'renders text area with value'); - run(function() { set(textArea, 'value', 'bar'); }); + run(() => set(textArea, 'value', 'bar')); equal(textArea.$().val(), 'bar', 'updates text area after value changes'); }); QUnit.test('value binding works properly for inputs that haven\'t been created', function() { - run(function() { + run(() => { textArea.destroy(); // destroy existing textarea let deprecationMessage = '`Ember.Binding` is deprecated. Since you' + @@ -97,26 +93,22 @@ QUnit.test('value binding works properly for inputs that haven\'t been created', equal(get(textArea, 'value'), null, 'precond - default value is null'); equal(textArea.$(), undefined, 'precond - view doesn\'t have its layer created yet, thus no input element'); - run(function() { - set(TestObject, 'value', 'ohai'); - }); + run(() => set(TestObject, 'value', 'ohai')); equal(get(textArea, 'value'), 'ohai', 'value property was properly updated'); - run(function() { textArea.append(); }); + run(() => textArea.append()); equal(get(textArea, 'value'), 'ohai', 'value property remains the same once the view has been appended'); equal(textArea.$().val(), 'ohai', 'value is reflected in the input element once it is created'); }); -['cut', 'paste', 'input'].forEach(function(eventName) { +['cut', 'paste', 'input'].forEach(eventName => { QUnit.test('should update the value on ' + eventName + ' events', function() { - run(function() { - textArea.append(); - }); + run(() => textArea.append()); textArea.$().val('new value'); - run(function() { + run(() => { textArea.trigger(eventName, EmberObject.create({ type: eventName })); @@ -127,12 +119,12 @@ QUnit.test('value binding works properly for inputs that haven\'t been created', }); QUnit.test('should call the insertNewline method when return key is pressed', function() { - var wasCalled; - var event = EmberObject.create({ + let wasCalled; + let event = EmberObject.create({ keyCode: 13 }); - run(function() { textArea.append(); }); + run(() => textArea.append()); textArea.insertNewline = function() { wasCalled = true; @@ -143,12 +135,12 @@ QUnit.test('should call the insertNewline method when return key is pressed', fu }); QUnit.test('should call the cancel method when escape key is pressed', function() { - var wasCalled; - var event = EmberObject.create({ + let wasCalled; + let event = EmberObject.create({ keyCode: 27 }); - run(function() { textArea.append(); }); + run(() => textArea.append()); textArea.cancel = function() { wasCalled = true; diff --git a/packages/ember-views/tests/views/text_field_test.js b/packages/ember-views/tests/views/text_field_test.js index aceb166b5af..ae8beb7d4ad 100644 --- a/packages/ember-views/tests/views/text_field_test.js +++ b/packages/ember-views/tests/views/text_field_test.js @@ -8,23 +8,23 @@ import jQuery from 'ember-views/system/jquery'; function K() { return this; } -var textField; -var TestObject; +let textField; +let TestObject; -var view; +let view; -var appendView = function(view) { +function appendView(view) { run(view, 'appendTo', '#qunit-fixture'); -}; +} -var caretPosition = function(element) { - var ctrl = element[0]; - var caretPos = 0; +function caretPosition(element) { + let ctrl = element[0]; + let caretPos = 0; // IE Support if (document.selection) { ctrl.focus(); - var selection = document.selection.createRange(); + let selection = document.selection.createRange(); selection.moveStart('character', -ctrl.value.length); @@ -35,31 +35,29 @@ var caretPosition = function(element) { } return caretPos; -}; +} -var setCaretPosition = function(element, pos) { - var ctrl = element[0]; +function setCaretPosition(element, pos) { + let ctrl = element[0]; if (ctrl.setSelectionRange) { ctrl.focus(); ctrl.setSelectionRange(pos, pos); } else if (ctrl.createTextRange) { - var range = ctrl.createTextRange(); + let range = ctrl.createTextRange(); range.collapse(true); range.moveEnd('character', pos); range.moveStart('character', pos); range.select(); } -}; +} function set(object, key, value) { - run(function() { o_set(object, key, value); }); + run(() => o_set(object, key, value)); } function append() { - run(function() { - textField.appendTo('#qunit-fixture'); - }); + run(() => textField.appendTo('#qunit-fixture')); } QUnit.module('Ember.TextField', { @@ -72,9 +70,7 @@ QUnit.module('Ember.TextField', { }, teardown() { - run(function() { - textField.destroy(); - }); + run(() => textField.destroy()); TestObject = window.TestObject = textField = null; } }); @@ -90,43 +86,43 @@ QUnit.test('should become disabled if the disabled attribute is true', function( append(); ok(textField.$().is(':not(:disabled)')); - run(function() { textField.set('disabled', true); }); + run(() => textField.set('disabled', true)); ok(textField.$().is(':disabled')); - run(function() { textField.set('disabled', false); }); + run(() => textField.set('disabled', false)); ok(textField.$().is(':not(:disabled)')); }); ['placeholder', 'name', 'title', 'size', 'maxlength', 'tabindex'].forEach(function(attributeName) { QUnit.test(`text field ${attributeName} is updated when setting ${attributeName} property of view`, function() { - run(function() { + run(() => { set(textField, attributeName, '1'); textField.append(); }); equal(textField.$().attr(attributeName), '1', `renders text field with ${attributeName}`); - run(function() { set(textField, attributeName, '2'); }); + run(() => set(textField, attributeName, '2')); equal(textField.$().attr(attributeName), '2', `updates text field after ${attributeName} changes`); }); }); QUnit.test('input value is updated when setting value property of view', function() { - run(function() { + run(() => { set(textField, 'value', 'foo'); textField.append(); }); equal(textField.$().val(), 'foo', 'renders text field with value'); - run(function() { set(textField, 'value', 'bar'); }); + run(() => set(textField, 'value', 'bar')); equal(textField.$().val(), 'bar', 'updates text field after value changes'); }); QUnit.test('input type is configurable when creating view', function() { - run(function() { + run(() => { set(textField, 'type', 'password'); textField.append(); }); @@ -135,7 +131,7 @@ QUnit.test('input type is configurable when creating view', function() { }); QUnit.test('value binding works properly for inputs that haven\'t been created', function() { - run(function() { + run(() => { textField.destroy(); // destroy existing textField let deprecationMessage = '`Ember.Binding` is deprecated. Since you' + @@ -151,20 +147,18 @@ QUnit.test('value binding works properly for inputs that haven\'t been created', equal(get(textField, 'value'), null, 'precond - default value is null'); equal(textField.$(), undefined, 'precond - view doesn\'t have its layer created yet, thus no input element'); - run(function() { - set(TestObject, 'value', 'ohai'); - }); + run(() => set(TestObject, 'value', 'ohai')); equal(get(textField, 'value'), 'ohai', 'value property was properly updated'); - run(function() { textField.append(); }); + run(() => textField.append()); equal(get(textField, 'value'), 'ohai', 'value property remains the same once the view has been appended'); equal(textField.$().val(), 'ohai', 'value is reflected in the input element once it is created'); }); QUnit.test('value binding sets value on the element', function() { - run(function() { + run(() => { textField.destroy(); // destroy existing textField let deprecationMessage = '`Ember.Binding` is deprecated. Since you' + @@ -180,7 +174,7 @@ QUnit.test('value binding sets value on the element', function() { }); // Set the value via the DOM - run(function() { + run(() => { textField.$().val('via dom'); // Trigger lets the view know we changed this value (like a real user editing) textField.trigger('input', EmberObject.create({ @@ -192,21 +186,19 @@ QUnit.test('value binding sets value on the element', function() { equal(textField.$().val(), 'via dom', 'dom property was properly updated via dom'); // Now, set it via the binding - run(function() { - set(TestObject, 'value', 'via view'); - }); + run(() => set(TestObject, 'value', 'via view')); equal(get(textField, 'value'), 'via view', 'value property was properly updated via view'); equal(textField.$().val(), 'via view', 'dom property was properly updated via view'); }); QUnit.test('should call the insertNewline method when return key is pressed', function() { - var wasCalled; - var event = EmberObject.create({ + let wasCalled; + let event = EmberObject.create({ keyCode: 13 }); - run(function() { textField.append(); }); + run(() => textField.append()); textField.insertNewline = function() { wasCalled = true; @@ -217,12 +209,12 @@ QUnit.test('should call the insertNewline method when return key is pressed', fu }); QUnit.test('should call the cancel method when escape key is pressed', function() { - var wasCalled; - var event = EmberObject.create({ + let wasCalled; + let event = EmberObject.create({ keyCode: 27 }); - run(function() { textField.append(); }); + run(() => textField.append()); textField.cancel = function() { wasCalled = true; @@ -235,7 +227,7 @@ QUnit.test('should call the cancel method when escape key is pressed', function( QUnit.test('should send an action if one is defined when the return key is pressed', function() { expect(2); - var StubController = EmberObject.extend({ + let StubController = EmberObject.extend({ send(actionName, value, sender) { equal(actionName, 'didTriggerAction', 'text field sent correct action name'); equal(value, 'textFieldValue', 'text field sent its current value as first argument'); @@ -246,9 +238,9 @@ QUnit.test('should send an action if one is defined when the return key is press textField.set('value', 'textFieldValue'); textField.set('targetObject', StubController.create()); - run(function() { textField.append(); }); + run(() => textField.append()); - var event = { + let event = { keyCode: 13, stopPropagation: K }; @@ -259,7 +251,7 @@ QUnit.test('should send an action if one is defined when the return key is press QUnit.test('should send an action on keyPress if one is defined with onEvent=keyPress', function() { expect(2); - var StubController = EmberObject.extend({ + let StubController = EmberObject.extend({ send(actionName, value, sender) { equal(actionName, 'didTriggerAction', 'text field sent correct action name'); equal(value, 'textFieldValue', 'text field sent its current value as first argument'); @@ -271,9 +263,9 @@ QUnit.test('should send an action on keyPress if one is defined with onEvent=key textField.set('value', 'textFieldValue'); textField.set('targetObject', StubController.create()); - run(function() { textField.append(); }); + run(() => textField.append()); - var event = { + let event = { keyCode: 48, stopPropagation: K }; @@ -292,8 +284,8 @@ QUnit.test('bubbling of handled actions can be enabled via bubbles property', fu append(); - var stopPropagationCount = 0; - var event = { + let stopPropagationCount = 0; + let event = { keyCode: 13, stopPropagation() { stopPropagationCount++; @@ -309,7 +301,7 @@ QUnit.test('bubbling of handled actions can be enabled via bubbles property', fu }); -var dispatcher, StubController; +let dispatcher, StubController; QUnit.module('Ember.TextField - Action events', { setup() { dispatcher = EventDispatcher.create(); @@ -323,7 +315,7 @@ QUnit.module('Ember.TextField - Action events', { }, teardown() { - run(function() { + run(() => { dispatcher.destroy(); if (textField) { @@ -347,9 +339,7 @@ QUnit.test('when the text field is blurred, the `focus-out` action is sent to th append(); - run(function() { - textField.$().blur(); - }); + run(() => textField.$().blur()); }); QUnit.test('when the text field is focused, the `focus-in` action is sent to the controller', function() { @@ -362,9 +352,7 @@ QUnit.test('when the text field is focused, the `focus-in` action is sent to the append(); - run(function() { - textField.$().focusin(); - }); + run(() => textField.$().focusin()); }); QUnit.test('when the user presses a key, the `key-press` action is sent to the controller', function() { @@ -377,8 +365,8 @@ QUnit.test('when the user presses a key, the `key-press` action is sent to the c append(); - run(function() { - var event = jQuery.Event('keypress'); + run(() => { + let event = jQuery.Event('keypress'); event.keyCode = event.which = 13; textField.$().trigger(event); }); @@ -394,8 +382,8 @@ QUnit.test('when the user inserts a new line, the `insert-newline` action is sen append(); - run(function() { - var event = jQuery.Event('keyup'); + run(() => { + let event = jQuery.Event('keyup'); event.keyCode = event.which = 13; textField.$().trigger(event); }); @@ -412,8 +400,8 @@ QUnit.test('when the user presses the `enter` key, the `enter` action is sent to append(); - run(function() { - var event = jQuery.Event('keyup'); + run(() => { + let event = jQuery.Event('keyup'); event.keyCode = event.which = 13; textField.$().trigger(event); }); @@ -429,8 +417,8 @@ QUnit.test('when the user hits escape, the `escape-press` action is sent to the append(); - run(function() { - var event = jQuery.Event('keyup'); + run(() => { + let event = jQuery.Event('keyup'); event.keyCode = event.which = 27; textField.$().trigger(event); }); @@ -438,7 +426,7 @@ QUnit.test('when the user hits escape, the `escape-press` action is sent to the QUnit.test('when the user presses a key, the `key-down` action is sent to the controller', function() { expect(3); - var event; + let event; textField = TextField.create({ 'key-down': 'doSomething', @@ -453,7 +441,7 @@ QUnit.test('when the user presses a key, the `key-down` action is sent to the co append(); - run(function() { + run(() => { event = jQuery.Event('keydown'); event.keyCode = event.which = 65; textField.$().val('foo'); @@ -463,7 +451,7 @@ QUnit.test('when the user presses a key, the `key-down` action is sent to the co QUnit.test('when the user releases a key, the `key-up` action is sent to the controller', function() { expect(3); - var event; + let event; textField = TextField.create({ 'key-up': 'doSomething', @@ -478,7 +466,7 @@ QUnit.test('when the user releases a key, the `key-up` action is sent to the con append(); - run(function() { + run(() => { event = jQuery.Event('keyup'); event.keyCode = event.which = 65; textField.$().val('bar'); @@ -495,7 +483,7 @@ QUnit.test('should not reset cursor position when text field receives keyUp even setCaretPosition(view.$(), 5); - run(function() { + run(() => { view.trigger('keyUp', {}); }); diff --git a/packages/ember-views/tests/views/view/actions_test.js b/packages/ember-views/tests/views/view/actions_test.js index 85075183cac..f1d8cfd3927 100644 --- a/packages/ember-views/tests/views/view/actions_test.js +++ b/packages/ember-views/tests/views/view/actions_test.js @@ -4,11 +4,11 @@ import Controller from 'ember-runtime/controllers/controller'; import EmberObject from 'ember-runtime/system/object'; import View from 'ember-views/views/view'; -var view; +let view; QUnit.module('View action handling', { teardown() { - run(function() { + run(() => { if (view) { view.destroy(); } }); } @@ -49,7 +49,7 @@ QUnit.test('A handled action can be bubbled to the target for continued processi QUnit.test('Action can be handled by a superclass\' actions object', function() { expect(4); - var SuperView = View.extend({ + let SuperView = View.extend({ actions: { foo() { ok(true, 'foo'); @@ -60,7 +60,7 @@ QUnit.test('Action can be handled by a superclass\' actions object', function() } }); - var BarViewMixin = Mixin.create({ + let BarViewMixin = Mixin.create({ actions: { bar(msg) { equal(msg, 'HELLO'); @@ -69,7 +69,7 @@ QUnit.test('Action can be handled by a superclass\' actions object', function() } }); - var IndexView = SuperView.extend(BarViewMixin, { + let IndexView = SuperView.extend(BarViewMixin, { actions: { baz() { ok(true, 'baz'); @@ -84,7 +84,7 @@ QUnit.test('Action can be handled by a superclass\' actions object', function() }); QUnit.test('Actions cannot be provided at create time', function() { - expectAssertion(function() { + expectAssertion(() => { view = View.create({ actions: { foo() { @@ -98,5 +98,3 @@ QUnit.test('Actions cannot be provided at create time', function() { actions: ['foo'] }); }); - - diff --git a/packages/ember-views/tests/views/view/append_to_test.js b/packages/ember-views/tests/views/view/append_to_test.js index bdb1911a4be..831bb8d0289 100644 --- a/packages/ember-views/tests/views/view/append_to_test.js +++ b/packages/ember-views/tests/views/view/append_to_test.js @@ -10,7 +10,7 @@ import { runAppend, runDestroy } from 'ember-runtime/tests/utils'; import buildOwner from 'container/tests/test-helpers/build-owner'; import { OWNER } from 'container/owner'; -var owner, View, view, otherView, willDestroyCalled; +let owner, View, view, otherView, willDestroyCalled; function commonSetup() { owner = buildOwner(); @@ -32,7 +32,7 @@ QUnit.module('EmberView - append() and appendTo()', { }); QUnit.test('can call `appendTo` for multiple views #11109', function() { - var elem; + let elem; jQuery('#qunit-fixture').html('
'); view = View.create(); @@ -41,7 +41,7 @@ QUnit.test('can call `appendTo` for multiple views #11109', function() { ok(!get(view, 'element'), 'precond - should not have an element'); ok(!get(otherView, 'element'), 'precond - should not have an element'); - run(function() { + run(() => { view.appendTo('#menu'); otherView.appendTo('#other-menu'); }); @@ -60,11 +60,9 @@ QUnit.test('should be added to the specified element when calling appendTo()', f ok(!get(view, 'element'), 'precond - should not have an element'); - run(function() { - view.appendTo('#menu'); - }); + run(() => view.appendTo('#menu')); - var viewElem = jQuery('#menu').children(); + let viewElem = jQuery('#menu').children(); ok(viewElem.length > 0, 'creates and appends the view\'s element'); }); @@ -75,21 +73,17 @@ QUnit.test('should be added to the document body when calling append()', functio ok(!get(view, 'element'), 'precond - should not have an element'); - run(function() { - view.append(); - }); + run(() => view.append()); - var viewElem = jQuery(document.body).find(':contains("foo bar baz")'); + let viewElem = jQuery(document.body).find(':contains("foo bar baz")'); ok(viewElem.length > 0, 'creates and appends the view\'s element'); }); QUnit.test('raises an assert when a target does not exist in the DOM', function() { view = View.create(); - expectAssertion(function() { - run(function() { - view.appendTo('does-not-exist-in-dom'); - }); + expectAssertion(() => { + run(() => view.appendTo('does-not-exist-in-dom')); }); }); @@ -105,15 +99,11 @@ QUnit.test('remove removes an element from the DOM', function() { ok(!get(view, 'element'), 'precond - should not have an element'); - run(function() { - view.append(); - }); + run(() => view.append()); ok(jQuery('#' + get(view, 'elementId')).length === 1, 'precond - element was inserted'); - run(function() { - view.remove(); - }); + run(() => view.remove()); ok(jQuery('#' + get(view, 'elementId')).length === 0, 'remove removes an element from the DOM'); ok(EmberView.views[get(view, 'elementId')] === undefined, 'remove does not remove the view from the view hash'); @@ -132,15 +122,11 @@ QUnit.test('destroy more forcibly removes the view', function() { ok(!get(view, 'element'), 'precond - should not have an element'); - run(function() { - view.append(); - }); + run(() => view.append()); ok(jQuery('#' + get(view, 'elementId')).length === 1, 'precond - element was inserted'); - run(function() { - view.destroy(); - }); + run(() => view.destroy()); ok(jQuery('#' + get(view, 'elementId')).length === 0, 'destroy removes an element from the DOM'); ok(EmberView.views[get(view, 'elementId')] === undefined, 'destroy removes a view from the global views hash'); @@ -175,11 +161,9 @@ QUnit.test('should be added to the specified element when calling appendTo()', f ok(!get(view, 'element'), 'precond - should not have an element'); - run(function() { - view.appendTo('#menu'); - }); + run(() => view.appendTo('#menu')); - var viewElem = jQuery('#menu #child'); + let viewElem = jQuery('#menu #child'); ok(viewElem.length > 0, 'creates and appends the view\'s element'); }); @@ -192,6 +176,6 @@ QUnit.test('should be added to the document body when calling append()', functio runAppend(view); - var viewElem = jQuery('#child'); + let viewElem = jQuery('#child'); ok(viewElem.length > 0, 'creates and appends the view\'s element'); }); diff --git a/packages/ember-views/tests/views/view/class_name_bindings_test.js b/packages/ember-views/tests/views/view/class_name_bindings_test.js index b55add5f755..058527bec66 100644 --- a/packages/ember-views/tests/views/view/class_name_bindings_test.js +++ b/packages/ember-views/tests/views/view/class_name_bindings_test.js @@ -2,18 +2,16 @@ import run from 'ember-metal/run_loop'; import { isWatching } from 'ember-metal/watching'; import EmberView from 'ember-views/views/view'; -var view; +let view; QUnit.module('EmberView - Class Name Bindings', { teardown() { - run(function() { - view.destroy(); - }); + run(() => view.destroy()); } }); QUnit.skip('classNameBindings lifecycle test', function() { - run(function() { + run(() => { view = EmberView.create({ classNameBindings: ['priority'], priority: 'high' @@ -22,14 +20,12 @@ QUnit.skip('classNameBindings lifecycle test', function() { equal(isWatching(view, 'priority'), false); - run(function() { - view.createElement(); - }); + run(() => view.createElement()); equal(view.$().attr('class'), 'ember-view high'); equal(isWatching(view, 'priority'), true); - run(function() { + run(() => { view.remove(); view.set('priority', 'low'); }); diff --git a/packages/ember-views/tests/views/view/create_child_view_test.js b/packages/ember-views/tests/views/view/create_child_view_test.js index 980f259ab07..cd033324791 100644 --- a/packages/ember-views/tests/views/view/create_child_view_test.js +++ b/packages/ember-views/tests/views/view/create_child_view_test.js @@ -6,7 +6,7 @@ import { observer } from 'ember-metal/mixin'; import { getOwner, OWNER } from 'container/owner'; -var view, myViewClass, newView, owner; +let view, myViewClass, newView, owner; QUnit.module('EmberView#createChildView', { setup() { @@ -19,7 +19,7 @@ QUnit.module('EmberView#createChildView', { }, teardown() { - run(function() { + run(() => { view.destroy(); if (newView) { newView.destroy(); } }); @@ -27,7 +27,7 @@ QUnit.module('EmberView#createChildView', { }); QUnit.test('should create view from class with any passed attributes', function() { - var attrs = { + let attrs = { foo: 'baz' }; @@ -68,7 +68,7 @@ QUnit.test('should set newView.parentView to receiver', function() { }); QUnit.test('should create property on parentView to a childView instance if provided a viewName', function() { - var attrs = { + let attrs = { viewName: 'someChildView' }; @@ -79,11 +79,11 @@ QUnit.test('should create property on parentView to a childView instance if prov }); QUnit.test('should update a view instances attributes, including the parentView and container properties', function() { - var attrs = { + let attrs = { foo: 'baz' }; - var myView = myViewClass.create(); + let myView = myViewClass.create(); newView = view.createChildView(myView, attrs); equal(getOwner(newView), owner, 'expects to share container with parent'); @@ -94,8 +94,8 @@ QUnit.test('should update a view instances attributes, including the parentView }); QUnit.test('should create from string via container lookup', function() { - var ChildViewClass = EmberView.extend(); - var fullName = 'view:bro'; + let ChildViewClass = EmberView.extend(); + let fullName = 'view:bro'; owner._lookupFactory = function(viewName) { equal(fullName, viewName); @@ -112,7 +112,5 @@ QUnit.test('should create from string via container lookup', function() { QUnit.test('should assert when trying to create childView from string, but no such view is registered', function() { owner._lookupFactory = function() {}; - expectAssertion(function() { - view.createChildView('bro'); - }); + expectAssertion(() => view.createChildView('bro')); }); diff --git a/packages/ember-views/tests/views/view/create_element_test.js b/packages/ember-views/tests/views/view/create_element_test.js index b25e552fcd9..ad6558c4976 100644 --- a/packages/ember-views/tests/views/view/create_element_test.js +++ b/packages/ember-views/tests/views/view/create_element_test.js @@ -3,7 +3,7 @@ import run from 'ember-metal/run_loop'; import EmberView from 'ember-views/views/view'; import { compile } from 'ember-htmlbars-template-compiler'; -var view; +let view; QUnit.module('Ember.View#createElement', { teardown() { @@ -14,13 +14,9 @@ QUnit.module('Ember.View#createElement', { }); QUnit.test('returns the receiver', function() { - var ret; - view = EmberView.create(); - run(function() { - ret = view.createElement(); - }); + let ret = run(() => view.createElement()); equal(ret, view, 'returns receiver'); }); @@ -32,11 +28,10 @@ QUnit.test('calls render and turns resultant string into element', function() { }); equal(get(view, 'element'), null, 'precondition - has no element'); - run(function() { - view.createElement(); - }); - var elem = get(view, 'element'); + run(() => view.createElement()); + + let elem = get(view, 'element'); ok(elem, 'has element now'); equal(elem.innerHTML, 'foo', 'has innerHTML from context'); equal(elem.tagName.toString().toLowerCase(), 'span', 'has tagName from view'); diff --git a/packages/ember-views/tests/views/view/destroy_element_test.js b/packages/ember-views/tests/views/view/destroy_element_test.js index 1c0ced9065d..9cf9bf38a8d 100644 --- a/packages/ember-views/tests/views/view/destroy_element_test.js +++ b/packages/ember-views/tests/views/view/destroy_element_test.js @@ -2,36 +2,32 @@ import { get } from 'ember-metal/property_get'; import run from 'ember-metal/run_loop'; import EmberView from 'ember-views/views/view'; -var view; +let view; QUnit.module('EmberView#destroyElement', { teardown() { - run(function() { - view.destroy(); - }); + run(() => view.destroy()); } }); QUnit.test('if it has no element, does nothing', function() { - var callCount = 0; + let callCount = 0; view = EmberView.create({ willDestroyElement() { callCount++; } }); ok(!get(view, 'element'), 'precond - does NOT have element'); - run(function() { - view.destroyElement(); - }); + run(() => view.destroyElement()); equal(callCount, 0, 'did not invoke callback'); }); QUnit.test('returns receiver', function() { - var ret; + let ret; view = EmberView.create(); - run(function() { + run(() => { view.createElement(); ret = view.destroyElement(); }); @@ -42,17 +38,13 @@ QUnit.test('returns receiver', function() { QUnit.test('removes element from parentNode if in DOM', function() { view = EmberView.create(); - run(function() { - view.append(); - }); + run(() => view.append()); - var parent = view.$().parent(); + let parent = view.$().parent(); ok(get(view, 'element'), 'precond - has element'); - run(function() { - view.destroyElement(); - }); + run(() => view.destroyElement()); equal(view.$(), undefined, 'view has no selector'); ok(!parent.find('#' + view.get('elementId')).length, 'element no longer in parent node'); diff --git a/packages/ember-views/tests/views/view/destroy_test.js b/packages/ember-views/tests/views/view/destroy_test.js index b37547f74e8..0e568cee62f 100644 --- a/packages/ember-views/tests/views/view/destroy_test.js +++ b/packages/ember-views/tests/views/view/destroy_test.js @@ -5,20 +5,16 @@ import EmberView from 'ember-views/views/view'; QUnit.module('Ember.View#destroy'); QUnit.test('should teardown viewName on parentView when childView is destroyed', function() { - var viewName = 'someChildView'; - var parentView = EmberView.create(); - var childView = parentView.createChildView(EmberView, { viewName: viewName }); + let viewName = 'someChildView'; + let parentView = EmberView.create(); + let childView = parentView.createChildView(EmberView, { viewName: viewName }); equal(get(parentView, viewName), childView, 'Precond - child view was registered on parent'); - run(function() { - childView.destroy(); - }); + run(() => childView.destroy()); equal(get(parentView, viewName), null, 'viewName reference was removed on parent'); - run(function() { - parentView.destroy(); - }); + run(() => parentView.destroy()); }); diff --git a/packages/ember-views/tests/views/view/element_test.js b/packages/ember-views/tests/views/view/element_test.js index 607cf232f08..6eaac2d50a6 100644 --- a/packages/ember-views/tests/views/view/element_test.js +++ b/packages/ember-views/tests/views/view/element_test.js @@ -6,11 +6,11 @@ import run from 'ember-metal/run_loop'; import EmberView from 'ember-views/views/view'; -var parentView, view; +let parentView, view; QUnit.module('Ember.View#element', { teardown() { - run(function() { + run(() => { if (parentView) { parentView.destroy(); } view.destroy(); }); @@ -27,7 +27,7 @@ QUnit.test('returns element if you set the value', function() { view = EmberView.create(); equal(get(view, 'element'), null, 'precond- has no element'); - var dom = document.createElement('div'); + let dom = document.createElement('div'); set(view, 'element', dom); equal(get(view, 'element'), dom, 'now has set element'); @@ -39,13 +39,9 @@ if (EmberDev && !EmberDev.runningProdBuild) { elementId: 'one' }); - run(function() { - view.appendTo('#qunit-fixture'); - }); + run(() => view.appendTo('#qunit-fixture')); - throws(function() { - view.set('elementId', 'two'); - }, 'raises elementId changed exception'); + throws(() => view.set('elementId', 'two'), 'raises elementId changed exception'); equal(view.get('elementId'), 'one', 'elementId is still "one"'); }); diff --git a/packages/ember-views/tests/views/view/evented_test.js b/packages/ember-views/tests/views/view/evented_test.js index 65daec71a8b..7bfc7566eb0 100644 --- a/packages/ember-views/tests/views/view/evented_test.js +++ b/packages/ember-views/tests/views/view/evented_test.js @@ -2,18 +2,16 @@ import run from 'ember-metal/run_loop'; import EmberObject from 'ember-runtime/system/object'; import EmberView from 'ember-views/views/view'; -var view; +let view; QUnit.module('EmberView evented helpers', { teardown() { - run(function() { - view.destroy(); - }); + run(() => view.destroy()); } }); QUnit.test('fire should call method sharing event name if it exists on the view', function() { - var eventFired = false; + let eventFired = false; view = EmberView.create({ fireMyEvent() { @@ -25,15 +23,13 @@ QUnit.test('fire should call method sharing event name if it exists on the view' } }); - run(function() { - view.fireMyEvent(); - }); + run(() => view.fireMyEvent()); equal(eventFired, true, 'fired the view method sharing the event name'); }); QUnit.test('fire does not require a view method with the same name', function() { - var eventFired = false; + let eventFired = false; view = EmberView.create({ fireMyEvent() { @@ -41,7 +37,7 @@ QUnit.test('fire does not require a view method with the same name', function() } }); - var listenObject = EmberObject.create({ + let listenObject = EmberObject.create({ onMyEvent() { eventFired = true; } @@ -49,14 +45,10 @@ QUnit.test('fire does not require a view method with the same name', function() view.on('myEvent', listenObject, 'onMyEvent'); - run(function() { - view.fireMyEvent(); - }); + run(() => view.fireMyEvent()); equal(eventFired, true, 'fired the event without a view method sharing its name'); - run(function() { - listenObject.destroy(); - }); + run(() => listenObject.destroy()); }); diff --git a/packages/ember-views/tests/views/view/inject_test.js b/packages/ember-views/tests/views/view/inject_test.js index 2a43f622875..c7e0a532dce 100644 --- a/packages/ember-views/tests/views/view/inject_test.js +++ b/packages/ember-views/tests/views/view/inject_test.js @@ -14,8 +14,8 @@ QUnit.test('services can be injected into views', function() { owner.register('service:profiler', Service.extend()); - var appView = owner.lookup('view:application'); - var profilerService = owner.lookup('service:profiler'); + let appView = owner.lookup('view:application'); + let profilerService = owner.lookup('service:profiler'); equal(profilerService, appView.get('profilerService'), 'service.profiler is injected'); }); diff --git a/packages/ember-views/tests/views/view/is_visible_test.js b/packages/ember-views/tests/views/view/is_visible_test.js index f512b61fc28..a45330cc6e2 100644 --- a/packages/ember-views/tests/views/view/is_visible_test.js +++ b/packages/ember-views/tests/views/view/is_visible_test.js @@ -5,8 +5,8 @@ import run from 'ember-metal/run_loop'; import { computed } from 'ember-metal/computed'; import EmberView from 'ember-views/views/view'; -var view; -var warnings, originalWarn; +let view; +let warnings, originalWarn; QUnit.module('EmberView#isVisible', { setup() { @@ -21,7 +21,7 @@ QUnit.module('EmberView#isVisible', { teardown() { if (view) { - run(function() { view.destroy(); }); + run(() => view.destroy()); } setDebugFunction('warn', originalWarn); } @@ -32,20 +32,14 @@ QUnit.test('should hide views when isVisible is false', function() { isVisible: false }); - run(function() { - view.append(); - }); + run(() => view.append()); ok(view.$().is(':hidden'), 'the view is hidden'); - run(function() { - set(view, 'isVisible', true); - }); + run(() => set(view, 'isVisible', true)); ok(view.$().is(':visible'), 'the view is visible'); - run(function() { - view.remove(); - }); + run(() => view.remove()); deepEqual(warnings, [], 'no warnings were triggered'); }); @@ -57,31 +51,21 @@ QUnit.test('should hide element if isVisible is false before element is created' ok(!get(view, 'isVisible'), 'precond - view is not visible'); - set(view, 'template', function() { return 'foo'; }); + set(view, 'template', () => 'foo'); - run(function() { - view.append(); - }); + run(() => view.append()); ok(view.$().is(':hidden'), 'should be hidden'); - run(function() { - view.remove(); - }); + run(() => view.remove()); - run(function() { - set(view, 'isVisible', true); - }); + run(() => set(view, 'isVisible', true)); - run(function() { - view.append(); - }); + run(() => view.append()); ok(view.$().is(':visible'), 'view should be visible'); - run(function() { - view.remove(); - }); + run(() => view.remove()); deepEqual(warnings, [], 'no warnings were triggered'); }); @@ -93,20 +77,14 @@ QUnit.test('should hide views when isVisible is a CP returning false', function( }) }).create(); - run(function() { - view.append(); - }); + run(() => view.append()); ok(view.$().is(':hidden'), 'the view is hidden'); - run(function() { - set(view, 'isVisible', true); - }); + run(() => set(view, 'isVisible', true)); ok(view.$().is(':visible'), 'the view is visible'); - run(function() { - view.remove(); - }); + run(() => view.remove()); deepEqual(warnings, [], 'no warnings were triggered'); }); @@ -118,9 +96,7 @@ QUnit.test('doesn\'t overwrite existing style attribute bindings', function() { style: 'color: blue;' }); - run(function() { - view.append(); - }); + run(() => view.append()); equal(view.$().attr('style'), 'color: blue; display: none;', 'has concatenated style attribute'); }); diff --git a/packages/ember-views/tests/views/view/jquery_test.js b/packages/ember-views/tests/views/view/jquery_test.js index 906a3224ea3..f066ad6d7ec 100644 --- a/packages/ember-views/tests/views/view/jquery_test.js +++ b/packages/ember-views/tests/views/view/jquery_test.js @@ -3,7 +3,7 @@ import EmberView from 'ember-views/views/view'; import { runAppend, runDestroy } from 'ember-runtime/tests/utils'; import { compile } from 'ember-htmlbars-template-compiler'; -var view; +let view; QUnit.module('EmberView#$', { setup() { view = EmberView.extend({ @@ -19,7 +19,7 @@ QUnit.module('EmberView#$', { }); QUnit.test('returns undefined if no element', function() { - var view = EmberView.create(); + let view = EmberView.create(); ok(!get(view, 'element'), 'precond - should have no element'); equal(view.$(), undefined, 'should return undefined'); equal(view.$('span'), undefined, 'should undefined if filter passed'); @@ -30,7 +30,7 @@ QUnit.test('returns undefined if no element', function() { QUnit.test('returns jQuery object selecting element if provided', function() { ok(get(view, 'element'), 'precond - should have element'); - var jquery = view.$(); + let jquery = view.$(); equal(jquery.length, 1, 'view.$() should have one element'); equal(jquery[0], get(view, 'element'), 'element should be element'); }); @@ -38,7 +38,7 @@ QUnit.test('returns jQuery object selecting element if provided', function() { QUnit.test('returns jQuery object selecting element inside element if provided', function() { ok(get(view, 'element'), 'precond - should have element'); - var jquery = view.$('span'); + let jquery = view.$('span'); equal(jquery.length, 1, 'view.$() should have one element'); equal(jquery[0].parentNode, get(view, 'element'), 'element should be in element'); }); @@ -46,6 +46,6 @@ QUnit.test('returns jQuery object selecting element inside element if provided', QUnit.test('returns empty jQuery object if filter passed that does not match item in parent', function() { ok(get(view, 'element'), 'precond - should have element'); - var jquery = view.$('body'); // would normally work if not scoped to view + let jquery = view.$('body'); // would normally work if not scoped to view equal(jquery.length, 0, 'view.$(body) should have no elements'); }); diff --git a/packages/ember-views/tests/views/view/remove_test.js b/packages/ember-views/tests/views/view/remove_test.js index d0fe7255e32..88fe70dad74 100644 --- a/packages/ember-views/tests/views/view/remove_test.js +++ b/packages/ember-views/tests/views/view/remove_test.js @@ -3,15 +3,15 @@ import run from 'ember-metal/run_loop'; import jQuery from 'ember-views/system/jquery'; import View from 'ember-views/views/view'; -var parentView, child; +let parentView, child; -var view; +let view; // ....................................................... // removeFromParent() // QUnit.module('View#removeFromParent', { teardown() { - run(function() { + run(() => { if (parentView) { parentView.destroy(); } if (child) { child.destroy(); } if (view) { view.destroy(); } @@ -27,31 +27,25 @@ QUnit.test('does nothing if not in parentView', function() { child.removeFromParent(); - run(function() { - child.destroy(); - }); + run(() => child.destroy()); }); QUnit.test('the DOM element is gone after doing append and remove in two separate runloops', function() { view = View.create(); - run(function() { - view.append(); - }); - run(function() { - view.remove(); - }); + run(() => view.append()); + run(() => view.remove()); - var viewElem = jQuery('#' + get(view, 'elementId')); + let viewElem = jQuery('#' + get(view, 'elementId')); ok(viewElem.length === 0, 'view\'s element doesn\'t exist in DOM'); }); QUnit.test('the DOM element is gone after doing append and remove in a single runloop', function() { view = View.create(); - run(function() { + run(() => { view.append(); view.remove(); }); - var viewElem = jQuery('#' + get(view, 'elementId')); + let viewElem = jQuery('#' + get(view, 'elementId')); ok(viewElem.length === 0, 'view\'s element doesn\'t exist in DOM'); }); diff --git a/packages/ember-views/tests/views/view/render_to_element_test.js b/packages/ember-views/tests/views/view/render_to_element_test.js index 121a2a82382..ac028b0c341 100644 --- a/packages/ember-views/tests/views/view/render_to_element_test.js +++ b/packages/ember-views/tests/views/view/render_to_element_test.js @@ -4,7 +4,7 @@ import EmberView from 'ember-views/views/view'; import { compile } from 'ember-htmlbars-template-compiler'; -var View, view; +let View, view; QUnit.module('EmberView - renderToElement()', { setup() { @@ -14,7 +14,7 @@ QUnit.module('EmberView - renderToElement()', { }, teardown() { - run(function() { + run(() => { if (!view.isDestroyed) { view.destroy(); } }); } @@ -25,11 +25,7 @@ QUnit.test('should render into and return a body element', function() { ok(!get(view, 'element'), 'precond - should not have an element'); - var element; - - run(function() { - element = view.renderToElement(); - }); + let element = run(() => view.renderToElement()); equal(element.tagName, 'BODY', 'returns a body element'); equal(element.firstChild.tagName, 'DIV', 'renders the view div'); @@ -42,11 +38,7 @@ QUnit.test('should create and render into an element with a provided tagName', f ok(!get(view, 'element'), 'precond - should not have an element'); - var element; - - run(function() { - element = view.renderToElement('div'); - }); + let element = run(() => view.renderToElement('div')); equal(element.tagName, 'DIV', 'returns a body element'); equal(element.firstChild.tagName, 'DIV', 'renders the view div'); diff --git a/packages/ember-views/tests/views/view/view_lifecycle_test.js b/packages/ember-views/tests/views/view/view_lifecycle_test.js index 216a6fd9bfb..83712a046b9 100644 --- a/packages/ember-views/tests/views/view/view_lifecycle_test.js +++ b/packages/ember-views/tests/views/view/view_lifecycle_test.js @@ -5,8 +5,8 @@ import EmberView from 'ember-views/views/view'; import { compile } from 'ember-template-compiler'; import { registerHelper } from 'ember-htmlbars/helpers'; -var originalLookup = context.lookup; -var lookup, view; +const originalLookup = context.lookup; +let lookup, view; import { test, testModule } from 'internal-test-helpers/tests/skip-if-glimmer'; @@ -17,26 +17,20 @@ QUnit.module('views/view/view_lifecycle_test - pre-render', { teardown() { if (view) { - run(function() { - view.destroy(); - }); + run(() => view.destroy()); } context.lookup = originalLookup; } }); QUnit.test('should throw an exception if trying to append a child before rendering has begun', function() { - run(function() { - view = EmberView.create(); - }); + view = run(() => EmberView.create()); - throws(function() { - view.appendChild(EmberView, {}); - }, null, 'throws an error when calling appendChild()'); + throws(() => view.appendChild(EmberView, {}), null, 'throws an error when calling appendChild()'); }); test('should not affect rendering if rerender is called before initial render happens', function() { - run(function() { + run(() => { view = EmberView.create({ template: compile('Rerender me!') }); @@ -49,7 +43,7 @@ test('should not affect rendering if rerender is called before initial render ha }); test('should not affect rendering if destroyElement is called before initial render happens', function() { - run(function() { + run(() => { view = EmberView.create({ template: compile('Don\'t destroy me!') }); @@ -64,9 +58,7 @@ test('should not affect rendering if destroyElement is called before initial ren testModule('views/view/view_lifecycle_test - in render', { teardown() { if (view) { - run(function() { - view.destroy(); - }); + run(() => view.destroy()); } } }); @@ -78,10 +70,7 @@ test('rerender of top level view during rendering should throw', function() { view = EmberView.create({ template: compile('{{throw}}') }); - throws( - function() { - run(view, view.appendTo, '#qunit-fixture'); - }, + throws(() => run(view, view.appendTo, '#qunit-fixture'), /Something you did caused a view to re-render after it rendered but before it was inserted into the DOM./, 'expected error was not raised' ); @@ -91,38 +80,34 @@ test('rerender of top level view during rendering should throw', function() { QUnit.module('views/view/view_lifecycle_test - hasElement', { teardown() { if (view) { - run(function() { - view.destroy(); - }); + run(() => view.destroy()); } } }); QUnit.test('createElement puts the view into the hasElement state', function() { - var hasCalledInsertElement = false; + let hasCalledInsertElement = false; view = EmberView.create({ didInsertElement() { hasCalledInsertElement = true; } }); - run(function() { - view.createElement(); - }); + run(() => view.createElement()); ok(!hasCalledInsertElement, 'didInsertElement is not called'); equal(view.element.tagName, 'DIV', 'content is rendered'); }); QUnit.test('trigger rerender on a view in the hasElement state doesn\'t change its state to inDOM', function() { - var hasCalledInsertElement = false; + let hasCalledInsertElement = false; view = EmberView.create({ didInsertElement() { hasCalledInsertElement = true; } }); - run(function() { + run(() => { view.createElement(); view.rerender(); }); @@ -135,15 +120,13 @@ QUnit.test('trigger rerender on a view in the hasElement state doesn\'t change i QUnit.module('views/view/view_lifecycle_test - in DOM', { teardown() { if (view) { - run(function() { - view.destroy(); - }); + run(() => view.destroy()); } } }); QUnit.test('should throw an exception when calling appendChild when DOM element exists', function() { - run(function() { + run(() => { view = EmberView.create({ template: compile('Wait for the kick') }); @@ -151,7 +134,7 @@ QUnit.test('should throw an exception when calling appendChild when DOM element view.append(); }); - throws(function() { + throws(() => { view.appendChild(EmberView, { template: compile('Ah ah ah! You didn\'t say the magic word!') }); @@ -159,7 +142,7 @@ QUnit.test('should throw an exception when calling appendChild when DOM element }); test('should replace DOM representation if rerender() is called after element is created', function() { - run(function() { + run(() => { view = EmberView.extend({ rerender() { this._super(...arguments); @@ -181,16 +164,14 @@ test('should replace DOM representation if rerender() is called after element is equal(view.$().text(), 'Do not taunt happy fun sphere', 'precond - keeps DOM element'); - run(function() { - view.rerender(); - }); + run(() => view.rerender()); equal(view.$().text(), 'Do not taunt happy fun ball', 'rerenders DOM element when rerender() is called'); }); QUnit.test('should destroy DOM representation when destroyElement is called', function() { - run(function() { + run(() => { view = EmberView.create({ template: compile('Don\'t fear the reaper') }); @@ -200,15 +181,13 @@ QUnit.test('should destroy DOM representation when destroyElement is called', fu ok(view.get('element'), 'precond - generates a DOM element'); - run(function() { - view.destroyElement(); - }); + run(() => view.destroyElement()); ok(!view.get('element'), 'destroys view when destroyElement() is called'); }); QUnit.test('should destroy DOM representation when destroy is called', function() { - run(function() { + run(() => { view = EmberView.create({ template: compile('
Don\'t fear the reaper
') }); @@ -218,15 +197,13 @@ QUnit.test('should destroy DOM representation when destroy is called', function( ok(view.get('element'), 'precond - generates a DOM element'); - run(function() { - view.destroy(); - }); + run(() => view.destroy()); ok(jQuery('#warning').length === 0, 'destroys element when destroy() is called'); }); QUnit.test('should throw an exception if trying to append an element that is already in DOM', function() { - run(function() { + run(() => { view = EmberView.create({ template: compile('Broseidon, King of the Brocean') }); @@ -236,17 +213,15 @@ QUnit.test('should throw an exception if trying to append an element that is alr ok(view.get('element'), 'precond - creates DOM element'); - throws(function() { - run(function() { - view.append(); - }); + throws(() => { + run(() => view.append()); }, null, 'raises an exception on second append'); }); QUnit.module('views/view/view_lifecycle_test - destroyed'); QUnit.test('should throw an exception when calling appendChild after view is destroyed', function() { - run(function() { + run(() => { view = EmberView.create({ template: compile('Wait for the kick') }); @@ -254,11 +229,9 @@ QUnit.test('should throw an exception when calling appendChild after view is des view.append(); }); - run(function() { - view.destroy(); - }); + run(() => view.destroy()); - throws(function() { + throws(() => { view.appendChild(EmberView, { template: compile('Ah ah ah! You didn\'t say the magic word!') }); @@ -266,7 +239,7 @@ QUnit.test('should throw an exception when calling appendChild after view is des }); QUnit.test('should throw an exception when rerender is called after view is destroyed', function() { - run(function() { + run(() => { view = EmberView.create({ template: compile('foo') }); @@ -274,17 +247,13 @@ QUnit.test('should throw an exception when rerender is called after view is dest view.append(); }); - run(function() { - view.destroy(); - }); + run(() => view.destroy()); - throws(function() { - view.rerender(); - }, null, 'throws an exception when calling rerender'); + throws(() => view.rerender(), null, 'throws an exception when calling rerender'); }); QUnit.test('should throw an exception when destroyElement is called after view is destroyed', function() { - run(function() { + run(() => { view = EmberView.create({ template: compile('foo') }); @@ -292,17 +261,13 @@ QUnit.test('should throw an exception when destroyElement is called after view i view.append(); }); - run(function() { - view.destroy(); - }); + run(() => view.destroy()); - throws(function() { - view.destroyElement(); - }, null, 'throws an exception when calling destroyElement'); + throws(() => view.destroyElement(), null, 'throws an exception when calling destroyElement'); }); QUnit.test('trigger rerender on a view in the inDOM state keeps its state as inDOM', function() { - run(function() { + run(() => { view = EmberView.create({ template: compile('foo') }); @@ -310,13 +275,9 @@ QUnit.test('trigger rerender on a view in the inDOM state keeps its state as inD view.append(); }); - run(function() { - view.rerender(); - }); + run(() => view.rerender()); equal(view._currentState, view._states.inDOM, 'the view is still in the inDOM state'); - run(function() { - view.destroy(); - }); + run(() => view.destroy()); }); diff --git a/packages/ember/tests/application_lifecycle_test.js b/packages/ember/tests/application_lifecycle_test.js index ae8d446d981..de6d2227022 100644 --- a/packages/ember/tests/application_lifecycle_test.js +++ b/packages/ember/tests/application_lifecycle_test.js @@ -7,7 +7,7 @@ import { compile } from 'ember-template-compiler/tests/utils/helpers'; import { getTemplates, setTemplates } from 'ember-templates/template_registry'; import controllerFor from 'ember-routing/system/controller_for'; -var App, TEMPLATES, appInstance, router; +let App, TEMPLATES, appInstance, router; function setupApp(klass) { run(function() { @@ -130,7 +130,7 @@ QUnit.test('initializers can augment an applications customEvents hash', functio run(App, 'destroy'); - var ApplicationSubclass = Application.extend(); + let ApplicationSubclass = Application.extend(); ApplicationSubclass.initializer({ name: 'customize-things', @@ -154,9 +154,7 @@ QUnit.test('initializers can augment an applications customEvents hash', functio run(App, 'advanceReadiness'); - run(function() { - jQuery('#wowza-thingy').trigger('wowza'); - }); + run(() => jQuery('#wowza-thingy').trigger('wowza')); }); QUnit.test('instanceInitializers can augment an the customEvents hash', function(assert) { @@ -164,7 +162,7 @@ QUnit.test('instanceInitializers can augment an the customEvents hash', function run(App, 'destroy'); - var ApplicationSubclass = Application.extend(); + let ApplicationSubclass = Application.extend(); ApplicationSubclass.instanceInitializer({ name: 'customize-things', @@ -188,7 +186,5 @@ QUnit.test('instanceInitializers can augment an the customEvents hash', function run(App, 'advanceReadiness'); - run(function() { - jQuery('#herky-thingy').trigger('herky'); - }); + run(() => jQuery('#herky-thingy').trigger('herky')); }); diff --git a/packages/ember/tests/component_registration_test.js b/packages/ember/tests/component_registration_test.js index 5f626fb917e..f8357ad7710 100644 --- a/packages/ember/tests/component_registration_test.js +++ b/packages/ember/tests/component_registration_test.js @@ -20,10 +20,10 @@ if (isEnabled('ember-glimmer')) { OutletView = require('ember-htmlbars/views/outlet').OutletView; } -var App, appInstance; -var originalHelpers; +let App, appInstance; +let originalHelpers; -const keys = Object.keys; +const { keys } = Object; function prepare() { setTemplate('components/expand-it', compile('

hello {{yield}}

')); @@ -33,7 +33,7 @@ function prepare() { } function cleanup() { - run(function() { + run(() => { try { if (App) { App.destroy(); @@ -47,10 +47,10 @@ function cleanup() { } function cleanupHelpers() { - var included; + let included; keys(helpers). - forEach((name) => { + forEach(name => { if (isEnabled('ember-runtime-enumerable-includes')) { included = originalHelpers.includes(name); } else { @@ -69,7 +69,7 @@ QUnit.module('Application Lifecycle - Component Registration', { }); function boot(callback, startURL='/') { - run(function() { + run(() => { App = Application.create({ name: 'App', rootElement: '#qunit-fixture' @@ -86,12 +86,10 @@ function boot(callback, startURL='/') { if (callback) { callback(); } }); - var router = appInstance.lookup('router:main'); + let router = appInstance.lookup('router:main'); run(App, 'advanceReadiness'); - run(function() { - router.handleURL(startURL); - }); + run(() => router.handleURL(startURL)); } QUnit.test('The helper becomes the body of the component', function() { @@ -100,7 +98,7 @@ QUnit.test('The helper becomes the body of the component', function() { }); QUnit.test('If a component is registered, it is used', function() { - boot(function() { + boot(() => { appInstance.register('component:expand-it', Component.extend({ classNames: 'testing123' })); @@ -112,7 +110,7 @@ QUnit.test('If a component is registered, it is used', function() { QUnit.test('Late-registered components can be rendered with custom `layout` property', function() { setTemplate('application', compile('
there goes {{my-hero}}
')); - boot(function() { + boot(() => { appInstance.register('component:my-hero', Component.extend({ classNames: 'testing123', layout: compile('watch him as he GOES') @@ -126,7 +124,7 @@ QUnit.test('Late-registered components can be rendered with custom `layout` prop QUnit.test('Late-registered components can be rendered with template registered on the container', function() { setTemplate('application', compile('
hello world {{sally-rutherford}}-{{#sally-rutherford}}!!!{{/sally-rutherford}}
')); - boot(function() { + boot(() => { appInstance.register('template:components/sally-rutherford', compile('funkytowny{{yield}}')); appInstance.register('component:sally-rutherford', Component); }); @@ -138,7 +136,7 @@ QUnit.test('Late-registered components can be rendered with template registered QUnit.test('Late-registered components can be rendered with ONLY the template registered on the container', function() { setTemplate('application', compile('
hello world {{borf-snorlax}}-{{#borf-snorlax}}!!!{{/borf-snorlax}}
')); - boot(function() { + boot(() => { appInstance.register('template:components/borf-snorlax', compile('goodfreakingTIMES{{yield}}')); }); @@ -149,7 +147,7 @@ QUnit.test('Late-registered components can be rendered with ONLY the template re test('Component-like invocations are treated as bound paths if neither template nor component are registered on the container', function() { setTemplate('application', compile('
{{user-name}} hello {{api-key}} world
')); - boot(function() { + boot(() => { appInstance.register('controller:application', Controller.extend({ 'user-name': 'machty' })); @@ -164,7 +162,7 @@ QUnit.test('Assigning layoutName to a component should setup the template as a l setTemplate('application', compile('
{{#my-component}}{{text}}{{/my-component}}
')); setTemplate('foo-bar-baz', compile('{{text}}-{{yield}}')); - boot(function() { + boot(() => { appInstance.register('controller:application', Controller.extend({ 'text': 'outer' })); @@ -184,7 +182,7 @@ QUnit.test('Assigning layoutName and layout to a component should use the `layou setTemplate('application', compile('
{{#my-component}}{{text}}{{/my-component}}
')); setTemplate('foo-bar-baz', compile('No way!')); - boot(function() { + boot(() => { appInstance.register('controller:application', Controller.extend({ 'text': 'outer' })); @@ -204,8 +202,8 @@ QUnit.test('Assigning defaultLayout to a component should set it up as a layout setTemplate('application', compile('
{{#my-component}}{{text}}{{/my-component}}
')); - expectDeprecation(function() { - boot(function() { + expectDeprecation(() => { + boot(() => { appInstance.register('controller:application', Controller.extend({ 'text': 'outer' })); @@ -226,8 +224,8 @@ QUnit.test('Assigning defaultLayout to a component should set it up as a layout setTemplate('application', compile('
{{#my-component}}{{text}}{{/my-component}}
')); setTemplate('components/my-component', compile('{{text}}-{{yield}}')); - expectDeprecation(function() { - boot(function() { + expectDeprecation(() => { + boot(() => { appInstance.register('controller:application', Controller.extend({ 'text': 'outer' })); @@ -245,9 +243,7 @@ QUnit.test('Assigning defaultLayout to a component should set it up as a layout QUnit.test('Using name of component that does not exist', function () { setTemplate('application', compile('
{{#no-good}} {{/no-good}}
')); - expectAssertion(function () { - boot(); - }, /.* named "no-good" .*/); + expectAssertion(() => boot(), /.* named "no-good" .*/); }); QUnit.module('Application Lifecycle - Component Context', { @@ -259,7 +255,7 @@ QUnit.test('Components with a block should have the proper content when a templa setTemplate('application', compile('
{{#my-component}}{{text}}{{/my-component}}
')); setTemplate('components/my-component', compile('{{text}}-{{yield}}')); - boot(function() { + boot(() => { appInstance.register('controller:application', Controller.extend({ 'text': 'outer' })); @@ -275,7 +271,7 @@ QUnit.test('Components with a block should have the proper content when a templa QUnit.test('Components with a block should yield the proper content without a template provided', function() { setTemplate('application', compile('
{{#my-component}}{{text}}{{/my-component}}
')); - boot(function() { + boot(() => { appInstance.register('controller:application', Controller.extend({ 'text': 'outer' })); @@ -292,7 +288,7 @@ QUnit.test('Components without a block should have the proper content when a tem setTemplate('application', compile('
{{my-component}}
')); setTemplate('components/my-component', compile('{{text}}')); - boot(function() { + boot(() => { appInstance.register('controller:application', Controller.extend({ 'text': 'outer' })); @@ -308,7 +304,7 @@ QUnit.test('Components without a block should have the proper content when a tem QUnit.test('Components without a block should have the proper content', function() { setTemplate('application', compile('
{{my-component}}
')); - boot(function() { + boot(() => { appInstance.register('controller:application', Controller.extend({ 'text': 'outer' })); @@ -327,7 +323,7 @@ QUnit.test('Components without a block should have the proper content', function QUnit.test('properties of a component without a template should not collide with internal structures [DEPRECATED]', function() { setTemplate('application', compile('
{{my-component data=foo}}
')); - boot(function() { + boot(() => { appInstance.register('controller:application', Controller.extend({ 'text': 'outer', 'foo': 'Some text inserted by jQuery' @@ -346,7 +342,7 @@ QUnit.test('properties of a component without a template should not collide with test('attrs property of a component without a template should not collide with internal structures', function() { setTemplate('application', compile('
{{my-component attrs=foo}}
')); - boot(function() { + boot(() => { appInstance.register('controller:application', Controller.extend({ 'text': 'outer', 'foo': 'Some text inserted by jQuery' @@ -366,7 +362,7 @@ test('attrs property of a component without a template should not collide with i QUnit.test('Components trigger actions in the parents context when called from within a block', function() { setTemplate('application', compile('
{{#my-component}}Fizzbuzz{{/my-component}}
')); - boot(function() { + boot(() => { appInstance.register('controller:application', Controller.extend({ actions: { fizzbuzz() { @@ -378,7 +374,7 @@ QUnit.test('Components trigger actions in the parents context when called from w appInstance.register('component:my-component', Component.extend()); }); - run(function() { + run(() => { jQuery('#fizzbuzz', '#wrapper').click(); }); }); @@ -387,7 +383,7 @@ QUnit.test('Components trigger actions in the components context when called fro setTemplate('application', compile('
{{#my-component}}{{text}}{{/my-component}}
')); setTemplate('components/my-component', compile('Fizzbuzz')); - boot(function() { + boot(() => { appInstance.register('controller:application', Controller.extend({ actions: { fizzbuzz() { @@ -415,7 +411,7 @@ QUnit.test('Components receive the top-level view as their ownerView', function( let component; - boot(function() { + boot(() => { appInstance.register('component:my-component', Component.extend({ init() { this._super(); diff --git a/packages/ember/tests/controller_test.js b/packages/ember/tests/controller_test.js index 0990c187cd1..21c66d4c2d6 100644 --- a/packages/ember/tests/controller_test.js +++ b/packages/ember/tests/controller_test.js @@ -15,11 +15,11 @@ import { setTemplates, set as setTemplate } from 'ember-templates/template_regis from the runtime up to the templating layer. */ -var App, $fixture; +let App, $fixture; QUnit.module('Template scoping examples', { setup() { - run(function() { + run(() => { App = Application.create({ name: 'App', rootElement: '#qunit-fixture' @@ -37,9 +37,7 @@ QUnit.module('Template scoping examples', { }, teardown() { - run(function() { - App.destroy(); - }); + run(() => App.destroy()); App = null; diff --git a/packages/ember/tests/default_initializers_test.js b/packages/ember/tests/default_initializers_test.js index e60ecb6d087..4b00075e2ea 100644 --- a/packages/ember/tests/default_initializers_test.js +++ b/packages/ember/tests/default_initializers_test.js @@ -4,11 +4,11 @@ import Checkbox from 'ember-templates/components/checkbox'; import run from 'ember-metal/run_loop'; -var App; +let App; QUnit.module('Default Registry', { setup() { - run(function() { + run(() => { App = Application.create({ rootElement: '#qunit-fixture' }); @@ -31,7 +31,5 @@ QUnit.test('Default objects are registered', function(assert) { } }); - run(function() { - App.advanceReadiness(); - }); + run(() => App.advanceReadiness()); }); diff --git a/packages/ember/tests/global-api-test.js b/packages/ember/tests/global-api-test.js index bdfdecdfd38..4c20fa3d6c2 100644 --- a/packages/ember/tests/global-api-test.js +++ b/packages/ember/tests/global-api-test.js @@ -5,7 +5,7 @@ QUnit.module('Global API Tests'); function confirmExport(property, internal) { QUnit.test('confirm ' + property + ' is exported', function() { - var theExport = get(window, property); + let theExport = get(window, property); ok(theExport + ' is exported'); if (internal !== undefined) { equal(theExport, internal, theExport + ' is exported properly'); diff --git a/packages/ember/tests/helpers/helper_registration_test.js b/packages/ember/tests/helpers/helper_registration_test.js index 9bb85516b5f..aa823bdcd83 100644 --- a/packages/ember/tests/helpers/helper_registration_test.js +++ b/packages/ember/tests/helpers/helper_registration_test.js @@ -9,11 +9,11 @@ import jQuery from 'ember-views/system/jquery'; import inject from 'ember-runtime/inject'; import { setTemplates, set as setTemplate } from 'ember-templates/template_registry'; -var App, appInstance; +let App, appInstance; QUnit.module('Application Lifecycle - Helper Registration', { teardown() { - run(function() { + run(() => { if (App) { App.destroy(); } @@ -24,8 +24,8 @@ QUnit.module('Application Lifecycle - Helper Registration', { } }); -var boot = function(callback) { - run(function() { +function boot(callback) { + run(() => { App = Application.create({ name: 'App', rootElement: '#qunit-fixture' @@ -42,19 +42,15 @@ var boot = function(callback) { if (callback) { callback(); } }); - var router = appInstance.lookup('router:main'); + let router = appInstance.lookup('router:main'); run(App, 'advanceReadiness'); - run(function() { - router.handleURL('/'); - }); -}; + run(() => router.handleURL('/')); +} QUnit.test('Unbound dashed helpers registered on the container can be late-invoked', function() { setTemplate('application', compile('
{{x-borf}} {{x-borf \'YES\'}}
')); - let myHelper = helper(function(params) { - return params[0] || 'BORF'; - }); + let myHelper = helper(params => params[0] || 'BORF'); boot(() => { App.register('helper:x-borf', myHelper); @@ -66,7 +62,7 @@ QUnit.test('Unbound dashed helpers registered on the container can be late-invok QUnit.test('Bound helpers registered on the container can be late-invoked', function() { setTemplate('application', compile('
{{x-reverse}} {{x-reverse foo}}
')); - boot(function() { + boot(() => { appInstance.register('controller:application', Controller.extend({ foo: 'alex' })); @@ -82,14 +78,10 @@ QUnit.test('Bound helpers registered on the container can be late-invoked', func QUnit.test('Undashed helpers registered on the container can be invoked', function() { setTemplate('application', compile('
{{omg}}|{{yorp \'boo\'}}|{{yorp \'ya\'}}
')); - boot(function() { - appInstance.register('helper:omg', helper(function() { - return 'OMG'; - })); + boot(() => { + appInstance.register('helper:omg', helper(() => 'OMG')); - appInstance.register('helper:yorp', helper(function([ value ]) { - return value; - })); + appInstance.register('helper:yorp', helper(([ value ]) => value)); }); equal(jQuery('#wrapper').text(), 'OMG|boo|ya', 'The helper was invoked from the container'); @@ -98,8 +90,8 @@ QUnit.test('Undashed helpers registered on the container can be invoked', functi QUnit.test('Helpers can receive injections', function() { setTemplate('application', compile('
{{full-name}}
')); - var serviceCalled = false; - boot(function() { + let serviceCalled = false; + boot(() => { appInstance.register('service:name-builder', Service.extend({ build() { serviceCalled = true; diff --git a/packages/ember/tests/helpers/link_to_test.js b/packages/ember/tests/helpers/link_to_test.js index 99e878243a6..93ec8d6cbe3 100644 --- a/packages/ember/tests/helpers/link_to_test.js +++ b/packages/ember/tests/helpers/link_to_test.js @@ -19,7 +19,7 @@ import { OWNER } from 'container/owner'; import { compile } from 'ember-template-compiler/tests/utils/helpers'; import { setTemplates, set as setTemplate } from 'ember-templates/template_registry'; -var Router, App, router, appInstance; +let Router, App, router, appInstance; function bootApplication() { router = appInstance.lookup('router:main'); @@ -40,11 +40,11 @@ function shouldBeActive(selector) { } function checkActive(selector, active) { - var classList = jQuery(selector, '#qunit-fixture')[0].className; + let classList = jQuery(selector, '#qunit-fixture')[0].className; equal(classList.indexOf('active') > -1, active, selector + ' active should be ' + active.toString()); } -var updateCount, replaceCount; +let updateCount, replaceCount; function sharedSetup() { App = Application.create({ @@ -74,7 +74,7 @@ function sharedSetup() { } function sharedTeardown() { - run(function() { App.destroy(); }); + run(() => App.destroy()); setTemplates({}); reset(); } @@ -83,7 +83,7 @@ import { test } from 'internal-test-helpers/tests/skip-if-glimmer'; QUnit.module('The {{link-to}} helper', { setup() { - run(function() { + run(() => { sharedSetup(); setTemplate('app', compile('{{outlet}}')); @@ -116,9 +116,7 @@ test('Using {{link-to}} does not cause an exception if it is rendered before the let router = appInstance.lookup('router:main'); router.setupRouter(); - run(function() { - component.appendTo('#qunit-fixture'); - }); + run(() => component.appendTo('#qunit-fixture')); assert.strictEqual(component.$('a').length, 1, 'the link is rendered'); }); @@ -131,9 +129,7 @@ test('Using {{link-to}} does not cause an exception if it is rendered without a layout: compile('{{#link-to "nonexistent"}}Does not work.{{/link-to}}') }).create(); - run(function() { - component.appendTo('#qunit-fixture'); - }); + run(() => component.appendTo('#qunit-fixture')); assert.strictEqual(component.$('a').length, 1, 'the link is rendered'); }); @@ -145,17 +141,13 @@ QUnit.test('The {{link-to}} helper moves into the named route', function() { bootApplication(); - run(function() { - router.handleURL('/'); - }); + run(() => router.handleURL('/')); equal(jQuery('h3:contains(Home)', '#qunit-fixture').length, 1, 'The home template was rendered'); equal(jQuery('#self-link.active', '#qunit-fixture').length, 1, 'The self-link was rendered with active class'); equal(jQuery('#about-link:not(.active)', '#qunit-fixture').length, 1, 'The other link was rendered without active class'); - run(function() { - jQuery('#about-link', '#qunit-fixture').click(); - }); + run(() => jQuery('#about-link', '#qunit-fixture').click()); equal(jQuery('h3:contains(About)', '#qunit-fixture').length, 1, 'The about template was rendered'); equal(jQuery('#self-link.active', '#qunit-fixture').length, 1, 'The self-link was rendered with active class'); @@ -171,9 +163,7 @@ if (isEnabled('ember-improved-instrumentation')) { bootApplication(); - run(function() { - router.handleURL('/'); - }); + run(() => router.handleURL('/')); subscribe('interaction.link-to', { before() { @@ -195,9 +185,7 @@ if (isEnabled('ember-improved-instrumentation')) { bootApplication(); - run(function() { - router.handleURL('/'); - }); + run(() => router.handleURL('/')); subscribe('interaction.link-to', { before(name, timestamp, { routeName }) { @@ -219,9 +207,7 @@ if (isEnabled('ember-improved-instrumentation')) { bootApplication(); - run(function() { - router.handleURL('/'); - }); + run(() => router.handleURL('/')); subscribe('interaction.link-to', { before() {}, @@ -243,16 +229,12 @@ QUnit.test('The {{link-to}} helper supports URL replacement', function() { bootApplication(); - run(function() { - router.handleURL('/'); - }); + run(() => router.handleURL('/')); equal(updateCount, 0, 'precond: setURL has not been called'); equal(replaceCount, 0, 'precond: replaceURL has not been called'); - run(function() { - jQuery('#about-link', '#qunit-fixture').click(); - }); + run(() => jQuery('#about-link', '#qunit-fixture').click()); equal(updateCount, 0, 'setURL should not be called'); equal(replaceCount, 1, 'replaceURL should be called once'); @@ -271,16 +253,12 @@ QUnit.test('The {{link-to}} helper supports URL replacement via replace=boundTru bootApplication(); - run(function() { - router.handleURL('/'); - }); + run(() => router.handleURL('/')); equal(updateCount, 0, 'precond: setURL has not been called'); equal(replaceCount, 0, 'precond: replaceURL has not been called'); - run(function() { - jQuery('#about-link', '#qunit-fixture').click(); - }); + run(() => jQuery('#about-link', '#qunit-fixture').click()); equal(updateCount, 0, 'setURL should not be called'); equal(replaceCount, 1, 'replaceURL should be called once'); @@ -299,16 +277,12 @@ QUnit.test('The {{link-to}} helper supports setting replace=boundFalseyThing', f bootApplication(); - run(function() { - router.handleURL('/'); - }); + run(() => router.handleURL('/')); equal(updateCount, 0, 'precond: setURL has not been called'); equal(replaceCount, 0, 'precond: replaceURL has not been called'); - run(function() { - jQuery('#about-link', '#qunit-fixture').click(); - }); + run(() => jQuery('#about-link', '#qunit-fixture').click()); equal(updateCount, 1, 'setURL should be called'); equal(replaceCount, 0, 'replaceURL should not be called'); @@ -325,9 +299,7 @@ QUnit.test("the {{link-to}} helper doesn't add an href when the tagName isn't 'a bootApplication(); - run(function() { - router.handleURL('/'); - }); + run(() => router.handleURL('/')); equal(jQuery('#about-link').attr('href'), undefined, 'there is no href attribute'); }); @@ -350,16 +322,12 @@ QUnit.test("the {{link-to}} applies a 'disabled' class when disabled", function bootApplication(); - run(function() { - router.handleURL('/'); - }); + run(() => router.handleURL('/')); equal(jQuery('#about-link-static.disabled', '#qunit-fixture').length, 1, 'The static link is disabled when its disabledWhen is true'); equal(jQuery('#about-link-dynamic.disabled', '#qunit-fixture').length, 1, 'The dynamic link is disabled when its disabledWhen is true'); - run(function() { - set(appInstance.lookup('controller:index'), 'dynamicDisabledWhen', false); - }); + run(() => set(appInstance.lookup('controller:index'), 'dynamicDisabledWhen', false)); equal(jQuery('#about-link-dynamic.disabled', '#qunit-fixture').length, 0, 'The dynamic link is re-enabled when its disabledWhen becomes false'); }); @@ -373,9 +341,7 @@ QUnit.test("the {{link-to}} doesn't apply a 'disabled' class if disabledWhen is bootApplication(); - run(function() { - router.handleURL('/'); - }); + run(() => router.handleURL('/')); ok(!jQuery('#about-link', '#qunit-fixture').hasClass('disabled'), 'The link is not disabled if disabledWhen not provided'); }); @@ -389,9 +355,7 @@ QUnit.test('the {{link-to}} helper supports a custom disabledClass', function () bootApplication(); - run(function() { - router.handleURL('/'); - }); + run(() => router.handleURL('/')); equal(jQuery('#about-link.do-not-want', '#qunit-fixture').length, 1, 'The link can apply a custom disabled class'); }); @@ -409,9 +373,7 @@ QUnit.test('the {{link-to}} helper supports a custom disabledClass set via bound bootApplication(); - run(function() { - router.handleURL('/'); - }); + run(() => router.handleURL('/')); equal(jQuery('#about-link.do-not-want', '#qunit-fixture').length, 1, 'The link can apply a custom disabled class via bound param'); }); @@ -425,13 +387,9 @@ QUnit.test('the {{link-to}} helper does not respond to clicks when disabled', fu bootApplication(); - run(function() { - router.handleURL('/'); - }); + run(() => router.handleURL('/')); - run(function() { - jQuery('#about-link', '#qunit-fixture').click(); - }); + run(() => jQuery('#about-link', '#qunit-fixture').click()); equal(jQuery('h3:contains(About)', '#qunit-fixture').length, 0, 'Transitioning did not occur'); }); @@ -449,22 +407,14 @@ QUnit.test('the {{link-to}} helper responds to clicks according to its disabledW bootApplication(); - run(function() { - router.handleURL('/'); - }); + run(() => router.handleURL('/')); - run(function() { - jQuery('#about-link', '#qunit-fixture').click(); - }); + run(() => jQuery('#about-link', '#qunit-fixture').click()); equal(jQuery('h3:contains(About)', '#qunit-fixture').length, 0, 'Transitioning did not occur'); - run(function() { - set(appInstance.lookup('controller:index'), 'disabledWhen', false); - }); - run(function() { - jQuery('#about-link', '#qunit-fixture').click(); - }); + run(() => set(appInstance.lookup('controller:index'), 'disabledWhen', false)); + run(() => jQuery('#about-link', '#qunit-fixture').click()); equal(jQuery('h3:contains(About)', '#qunit-fixture').length, 1, 'Transitioning did occur when disabledWhen became false'); }); @@ -478,9 +428,7 @@ QUnit.test('The {{link-to}} helper supports a custom activeClass', function() { bootApplication(); - run(function() { - router.handleURL('/'); - }); + run(() => router.handleURL('/')); equal(jQuery('h3:contains(Home)', '#qunit-fixture').length, 1, 'The home template was rendered'); equal(jQuery('#self-link.zomg-active', '#qunit-fixture').length, 1, 'The self-link was rendered with active class'); @@ -500,9 +448,7 @@ QUnit.test('The {{link-to}} helper supports a custom activeClass from a bound pa bootApplication(); - run(function() { - router.handleURL('/'); - }); + run(() => router.handleURL('/')); equal(jQuery('h3:contains(Home)', '#qunit-fixture').length, 1, 'The home template was rendered'); equal(jQuery('#self-link.zomg-active', '#qunit-fixture').length, 1, 'The self-link was rendered with active class'); @@ -522,16 +468,13 @@ test("The {{link-to}} helper supports 'classNameBindings' with custom values [GH bootApplication(); - run(function() { - router.handleURL('/'); - }); + run(() => router.handleURL('/')); equal(jQuery('#about-link.foo-is-false', '#qunit-fixture').length, 1, 'The about-link was rendered with the falsy class'); - var controller = appInstance.lookup('controller:index'); - run(function() { - controller.set('foo', true); - }); + let controller = appInstance.lookup('controller:index'); + + run(() => controller.set('foo', true)); equal(jQuery('#about-link.foo-is-true', '#qunit-fixture').length, 1, 'The about-link was rendered with the truthy class after toggling the property'); }); @@ -570,9 +513,7 @@ QUnit.test('The {{link-to}} helper supports currentWhen (DEPRECATED)', function( bootApplication(); - run(function() { - router.handleURL('/about'); - }); + run(() => router.handleURL('/about')); equal(jQuery('#other-link.active', '#qunit-fixture').length, 1, 'The link is active since current-when is a parent route'); }); @@ -591,9 +532,7 @@ QUnit.test('The {{link-to}} helper supports custom, nested, current-when', funct bootApplication(); - run(function() { - router.handleURL('/about'); - }); + run(() => router.handleURL('/about')); equal(jQuery('#other-link.active', '#qunit-fixture').length, 1, 'The link is active since current-when is a parent route'); }); @@ -614,9 +553,7 @@ QUnit.test('The {{link-to}} helper does not disregard current-when when it is gi bootApplication(); - run(function() { - router.handleURL('/about'); - }); + run(() => router.handleURL('/about')); equal(jQuery('#other-link.active', '#qunit-fixture').length, 1, 'The link is active when current-when is given for explicitly for a route'); }); @@ -641,9 +578,7 @@ QUnit.test('The {{link-to}} helper does not disregard current-when when it is se bootApplication(); - run(function() { - router.handleURL('/about'); - }); + run(() => router.handleURL('/about')); equal(jQuery('#other-link.active', '#qunit-fixture').length, 1, 'The link is active when current-when is given for explicitly for a route'); }); @@ -664,21 +599,15 @@ QUnit.test('The {{link-to}} helper supports multiple current-when routes', funct bootApplication(); - run(function() { - router.handleURL('/about'); - }); + run(() => router.handleURL('/about')); equal(jQuery('#link1.active', '#qunit-fixture').length, 1, 'The link is active since current-when contains the parent route'); - run(function() { - router.handleURL('/item'); - }); + run(() => router.handleURL('/item')); equal(jQuery('#link2.active', '#qunit-fixture').length, 1, 'The link is active since you are on the active route'); - run(function() { - router.handleURL('/foo'); - }); + run(() => router.handleURL('/foo')); equal(jQuery('#link3.active', '#qunit-fixture').length, 0, 'The link is not active since current-when does not contain the active route'); }); @@ -693,7 +622,7 @@ QUnit.test('The {{link-to}} helper defaults to bubbling', function() { }); }); - var hidden = 0; + let hidden = 0; App.AboutRoute = Route.extend({ actions: { @@ -705,13 +634,9 @@ QUnit.test('The {{link-to}} helper defaults to bubbling', function() { bootApplication(); - run(function() { - router.handleURL('/about'); - }); + run(() => router.handleURL('/about')); - run(function() { - jQuery('#about-contact', '#qunit-fixture').click(); - }); + run(() => jQuery('#about-contact', '#qunit-fixture').click()); equal(jQuery('#contact', '#qunit-fixture').text(), 'Contact', 'precond - the link worked'); @@ -728,7 +653,7 @@ QUnit.test('The {{link-to}} helper supports bubbles=false', function() { }); }); - var hidden = 0; + let hidden = 0; App.AboutRoute = Route.extend({ actions: { @@ -740,13 +665,9 @@ QUnit.test('The {{link-to}} helper supports bubbles=false', function() { bootApplication(); - run(function() { - router.handleURL('/about'); - }); + run(() => router.handleURL('/about')); - run(function() { - jQuery('#about-contact', '#qunit-fixture').click(); - }); + run(() => jQuery('#about-contact', '#qunit-fixture').click()); equal(jQuery('#contact', '#qunit-fixture').text(), 'Contact', 'precond - the link worked'); @@ -767,7 +688,7 @@ QUnit.test('The {{link-to}} helper supports bubbles=boundFalseyThing', function( }); }); - var hidden = 0; + let hidden = 0; App.AboutRoute = Route.extend({ actions: { @@ -779,13 +700,8 @@ QUnit.test('The {{link-to}} helper supports bubbles=boundFalseyThing', function( bootApplication(); - run(function() { - router.handleURL('/about'); - }); - - run(function() { - jQuery('#about-contact', '#qunit-fixture').click(); - }); + run(() => router.handleURL('/about')); + run(() => jQuery('#about-contact', '#qunit-fixture').click()); equal(jQuery('#contact', '#qunit-fixture').text(), 'Contact', 'precond - the link worked'); @@ -812,30 +728,24 @@ QUnit.test('The {{link-to}} helper moves into the named route with context', fun bootApplication(); - run(function() { - router.handleURL('/about'); - }); + run(() => router.handleURL('/about')); equal(jQuery('h3:contains(List)', '#qunit-fixture').length, 1, 'The home template was rendered'); equal(normalizeUrl(jQuery('#home-link').attr('href')), '/', 'The home link points back at /'); - run(function() { - jQuery('li a:contains(Yehuda)', '#qunit-fixture').click(); - }); + run(() => jQuery('li a:contains(Yehuda)', '#qunit-fixture').click()); equal(jQuery('h3:contains(Item)', '#qunit-fixture').length, 1, 'The item template was rendered'); equal(jQuery('p', '#qunit-fixture').text(), 'Yehuda Katz', 'The name is correct'); - run(function() { jQuery('#home-link').click(); }); - run(function() { jQuery('#about-link').click(); }); + run(() => jQuery('#home-link').click()); + run(() => jQuery('#about-link').click()); equal(normalizeUrl(jQuery('li a:contains(Yehuda)').attr('href')), '/item/yehuda'); equal(normalizeUrl(jQuery('li a:contains(Tom)').attr('href')), '/item/tom'); equal(normalizeUrl(jQuery('li a:contains(Erik)').attr('href')), '/item/erik'); - run(function() { - jQuery('li a:contains(Erik)', '#qunit-fixture').click(); - }); + run(() => jQuery('li a:contains(Erik)', '#qunit-fixture').click()); equal(jQuery('h3:contains(Item)', '#qunit-fixture').length, 1, 'The item template was rendered'); equal(jQuery('p', '#qunit-fixture').text(), 'Erik Brynroflsson', 'The name is correct'); @@ -845,11 +755,9 @@ QUnit.test('The {{link-to}} helper binds some anchor html tag common attributes' setTemplate('index', compile("

Home

{{#link-to 'index' id='self-link' title='title-attr' rel='rel-attr' tabindex='-1'}}Self{{/link-to}}")); bootApplication(); - run(function() { - router.handleURL('/'); - }); + run(() => router.handleURL('/')); - var link = jQuery('#self-link', '#qunit-fixture'); + let link = jQuery('#self-link', '#qunit-fixture'); equal(link.attr('title'), 'title-attr', 'The self-link contains title attribute'); equal(link.attr('rel'), 'rel-attr', 'The self-link contains rel attribute'); equal(link.attr('tabindex'), '-1', 'The self-link contains tabindex attribute'); @@ -859,11 +767,9 @@ QUnit.test('The {{link-to}} helper supports `target` attribute', function() { setTemplate('index', compile("

Home

{{#link-to 'index' id='self-link' target='_blank'}}Self{{/link-to}}")); bootApplication(); - run(function() { - router.handleURL('/'); - }); + run(() => router.handleURL('/')); - var link = jQuery('#self-link', '#qunit-fixture'); + let link = jQuery('#self-link', '#qunit-fixture'); equal(link.attr('target'), '_blank', 'The self-link contains `target` attribute'); }); @@ -876,11 +782,9 @@ QUnit.test('The {{link-to}} helper supports `target` attribute specified as a bo bootApplication(); - run(function() { - router.handleURL('/'); - }); + run(() => router.handleURL('/')); - var link = jQuery('#self-link', '#qunit-fixture'); + let link = jQuery('#self-link', '#qunit-fixture'); equal(link.attr('target'), '_blank', 'The self-link contains `target` attribute'); }); @@ -888,11 +792,9 @@ QUnit.test('The {{link-to}} helper does not call preventDefault if `target` attr setTemplate('index', compile("

Home

{{#link-to 'index' id='self-link' target='_blank'}}Self{{/link-to}}")); bootApplication(); - run(function() { - router.handleURL('/'); - }); + run(() => router.handleURL('/')); - var event = jQuery.Event('click'); + let event = jQuery.Event('click'); jQuery('#self-link', '#qunit-fixture').trigger(event); equal(event.isDefaultPrevented(), false, 'should not preventDefault when target attribute is specified'); @@ -902,11 +804,9 @@ QUnit.test('The {{link-to}} helper should preventDefault when `target = _self`', setTemplate('index', compile("

Home

{{#link-to 'index' id='self-link' target='_self'}}Self{{/link-to}}")); bootApplication(); - run(function() { - router.handleURL('/'); - }); + run(() => router.handleURL('/')); - var event = jQuery.Event('click'); + let event = jQuery.Event('click'); jQuery('#self-link', '#qunit-fixture').trigger(event); equal(event.isDefaultPrevented(), true, 'should preventDefault when target attribute is `_self`'); @@ -921,13 +821,8 @@ QUnit.test('The {{link-to}} helper should not transition if target is not equal bootApplication(); - run(function() { - router.handleURL('/'); - }); - - run(function() { - jQuery('#about-link', '#qunit-fixture').click(); - }); + run(() => router.handleURL('/')); + run(() => jQuery('#about-link', '#qunit-fixture').click()); notEqual(appInstance.lookup('controller:application').get('currentRouteName'), 'about', 'link-to should not transition if target is not equal to _self or empty'); }); @@ -950,7 +845,7 @@ QUnit.test('The {{link-to}} helper accepts string/numeric arguments', function() bootApplication(); - run(function() { router.handleURL('/filters/popular'); }); + run(() => router.handleURL('/filters/popular')); equal(normalizeUrl(jQuery('#link', '#qunit-fixture').attr('href')), '/filters/unpopular'); equal(normalizeUrl(jQuery('#path-link', '#qunit-fixture').attr('href')), '/filters/unpopular'); @@ -1006,10 +901,8 @@ QUnit.test('Quoteless route param performs property lookup', function() { assertEquality('/'); - var controller = appInstance.lookup('controller:index'); - run(function() { - controller.set('foo', 'about'); - }); + let controller = appInstance.lookup('controller:index'); + run(() => controller.set('foo', 'about')); assertEquality('/about'); }); @@ -1017,12 +910,12 @@ QUnit.test('Quoteless route param performs property lookup', function() { QUnit.test('link-to with null/undefined dynamic parameters are put in a loading state', function() { expect(19); - var oldWarn = Logger.warn; - var warnCalled = false; + let oldWarn = Logger.warn; + let warnCalled = false; Logger.warn = function() { warnCalled = true; }; setTemplate('index', compile("{{#link-to destinationRoute routeContext loadingClass='i-am-loading' id='context-link'}}string{{/link-to}}{{#link-to secondRoute loadingClass=loadingClass id='static-link'}}string{{/link-to}}")); - var thing = EmberObject.create({ id: 123 }); + let thing = EmberObject.create({ id: 123 }); App.IndexController = Controller.extend({ destinationRoute: null, @@ -1055,14 +948,14 @@ QUnit.test('link-to with null/undefined dynamic parameters are put in a loading } } - var $contextLink = jQuery('#context-link', '#qunit-fixture'); - var $staticLink = jQuery('#static-link', '#qunit-fixture'); - var controller = appInstance.lookup('controller:index'); + let $contextLink = jQuery('#context-link', '#qunit-fixture'); + let $staticLink = jQuery('#static-link', '#qunit-fixture'); + let controller = appInstance.lookup('controller:index'); assertLinkStatus($contextLink); assertLinkStatus($staticLink); - run(function() { + run(() => { warnCalled = false; $contextLink.click(); ok(warnCalled, 'Logger.warn was called from clicking loading link'); @@ -1088,7 +981,7 @@ QUnit.test('link-to with null/undefined dynamic parameters are put in a loading run(controller, 'set', 'destinationRoute', null); assertLinkStatus($contextLink); - run(function() { + run(() => { warnCalled = false; $staticLink.click(); ok(warnCalled, 'Logger.warn was called from clicking loading link'); @@ -1108,27 +1001,27 @@ QUnit.test('The {{link-to}} helper refreshes href element when one of params cha this.route('post', { path: '/posts/:post_id' }); }); - var post = EmberObject.create({ id: '1' }); - var secondPost = EmberObject.create({ id: '2' }); + let post = EmberObject.create({ id: '1' }); + let secondPost = EmberObject.create({ id: '2' }); setTemplate('index', compile('{{#link-to "post" post id="post"}}post{{/link-to}}')); App.IndexController = Controller.extend(); - var indexController = appInstance.lookup('controller:index'); + let indexController = appInstance.lookup('controller:index'); - run(function() { indexController.set('post', post); }); + run(() => indexController.set('post', post)); bootApplication(); - run(function() { router.handleURL('/'); }); + run(() => router.handleURL('/')); equal(normalizeUrl(jQuery('#post', '#qunit-fixture').attr('href')), '/posts/1', 'precond - Link has rendered href attr properly'); - run(function() { indexController.set('post', secondPost); }); + run(() => indexController.set('post', secondPost)); equal(jQuery('#post', '#qunit-fixture').attr('href'), '/posts/2', 'href attr was updated after one of the params had been changed'); - run(function() { indexController.set('post', null); }); + run(() => indexController.set('post', null)); equal(jQuery('#post', '#qunit-fixture').attr('href'), '#', 'href attr becomes # when one of the arguments in nullified'); }); @@ -1178,9 +1071,9 @@ QUnit.test("The {{link-to}} helper works in an #each'd array of string route nam function linksEqual($links, expected) { equal($links.length, expected.length, 'Has correct number of links'); - var idx; + let idx; for (idx = 0; idx < $links.length; idx++) { - var href = jQuery($links[idx]).attr('href'); + let href = jQuery($links[idx]).attr('href'); // Old IE includes the whole hostname as well equal(href.slice(-expected[idx].length), expected[idx], `Expected link to be '${expected[idx]}', but was '${href}'`); } @@ -1188,7 +1081,7 @@ QUnit.test("The {{link-to}} helper works in an #each'd array of string route nam linksEqual(jQuery('a', '#qunit-fixture'), ['/foo', '/bar', '/rar', '/foo', '/bar', '/rar', '/bar', '/foo']); - var indexController = appInstance.lookup('controller:index'); + let indexController = appInstance.lookup('controller:index'); run(indexController, 'set', 'route1', 'rar'); linksEqual(jQuery('a', '#qunit-fixture'), ['/foo', '/bar', '/rar', '/foo', '/bar', '/rar', '/rar', '/foo']); @@ -1209,9 +1102,7 @@ QUnit.test('The non-block form {{link-to}} helper moves into the named route', f bootApplication(); - run(function() { - jQuery('#contact-link', '#qunit-fixture').click(); - }); + run(() => jQuery('#contact-link', '#qunit-fixture').click()); equal(jQuery('h3:contains(Contact)', '#qunit-fixture').length, 1, 'The contact template was rendered'); equal(jQuery('#self-link.active', '#qunit-fixture').length, 1, 'The self-link was rendered with active class'); @@ -1233,34 +1124,27 @@ QUnit.test('The non-block form {{link-to}} helper updates the link text when it bootApplication(); - run(function() { - router.handleURL('/'); - }); - var controller = appInstance.lookup('controller:index'); + run(() => router.handleURL('/')); + + let controller = appInstance.lookup('controller:index'); equal(jQuery('#contact-link:contains(Jane)', '#qunit-fixture').length, 1, 'The link title is correctly resolved'); - run(function() { - controller.set('contactName', 'Joe'); - }); + run(() => controller.set('contactName', 'Joe')); + equal(jQuery('#contact-link:contains(Joe)', '#qunit-fixture').length, 1, 'The link title is correctly updated when the bound property changes'); - run(function() { - controller.set('contactName', 'Robert'); - }); + run(() => controller.set('contactName', 'Robert')); + equal(jQuery('#contact-link:contains(Robert)', '#qunit-fixture').length, 1, 'The link title is correctly updated when the bound property changes a second time'); - run(function() { - jQuery('#contact-link', '#qunit-fixture').click(); - }); + run(() => jQuery('#contact-link', '#qunit-fixture').click()); equal(jQuery('h3:contains(Contact)', '#qunit-fixture').length, 1, 'The contact template was rendered'); equal(jQuery('#self-link.active', '#qunit-fixture').length, 1, 'The self-link was rendered with active class'); equal(jQuery('#home-link:not(.active)', '#qunit-fixture').length, 1, 'The other link was rendered without active class'); - run(function() { - jQuery('#home-link', '#qunit-fixture').click(); - }); + run(() => jQuery('#home-link', '#qunit-fixture').click()); equal(jQuery('h3:contains(Home)', '#qunit-fixture').length, 1, 'The index template was rendered'); equal(jQuery('#contact-link:contains(Robert)', '#qunit-fixture').length, 1, 'The link title is correctly updated when the route changes'); @@ -1288,14 +1172,12 @@ QUnit.test('The non-block form {{link-to}} helper moves into the named route wit bootApplication(); - run(function() { - jQuery('li a:contains(Yehuda)', '#qunit-fixture').click(); - }); + run(() => jQuery('li a:contains(Yehuda)', '#qunit-fixture').click()); equal(jQuery('h3:contains(Item)', '#qunit-fixture').length, 1, 'The item template was rendered'); equal(jQuery('p', '#qunit-fixture').text(), 'Yehuda Katz', 'The name is correct'); - run(function() { jQuery('#home-link').click(); }); + run(() => jQuery('#home-link').click()); equal(normalizeUrl(jQuery('li a:contains(Yehuda)').attr('href')), '/item/yehuda'); equal(normalizeUrl(jQuery('li a:contains(Tom)').attr('href')), '/item/tom'); @@ -1324,10 +1206,8 @@ QUnit.test('The non-block form {{link-to}} performs property lookup', function() assertEquality('/'); - var controller = appInstance.lookup('controller:index'); - run(function() { - controller.set('foo', 'about'); - }); + let controller = appInstance.lookup('controller:index'); + run(() => controller.set('foo', 'about')); assertEquality('/about'); }); @@ -1343,12 +1223,10 @@ QUnit.test('The non-block form {{link-to}} protects against XSS', function() { run(router, 'handleURL', '/'); - var controller = appInstance.lookup('controller:application'); + let controller = appInstance.lookup('controller:application'); equal(jQuery('#link', '#qunit-fixture').text(), 'blahzorz'); - run(function() { - controller.set('display', 'BLAMMO'); - }); + run(() => controller.set('display', 'BLAMMO')); equal(jQuery('#link', '#qunit-fixture').text(), 'BLAMMO'); equal(jQuery('b', '#qunit-fixture').length, 0); @@ -1363,7 +1241,7 @@ QUnit.test('the {{link-to}} helper calls preventDefault', function() { run(router, 'handleURL', '/'); - var event = jQuery.Event('click'); + let event = jQuery.Event('click'); jQuery('#about-link', '#qunit-fixture').trigger(event); equal(event.isDefaultPrevented(), true, 'should preventDefault'); @@ -1380,7 +1258,7 @@ QUnit.test('the {{link-to}} helper does not call preventDefault if `preventDefau run(router, 'handleURL', '/'); - var event = jQuery.Event('click'); + let event = jQuery.Event('click'); jQuery('#about-link', '#qunit-fixture').trigger(event); equal(event.isDefaultPrevented(), false, 'should not preventDefault'); @@ -1401,7 +1279,7 @@ QUnit.test('the {{link-to}} helper does not call preventDefault if `preventDefau run(router, 'handleURL', '/'); - var event = jQuery.Event('click'); + let event = jQuery.Event('click'); jQuery('#about-link', '#qunit-fixture').trigger(event); equal(event.isDefaultPrevented(), false, 'should not preventDefault'); @@ -1429,13 +1307,8 @@ QUnit.test('the {{link-to}} helper does not throw an error if its route has exit run(router, 'handleURL', '/'); - run(function() { - jQuery('#default-post-link', '#qunit-fixture').click(); - }); - - run(function() { - jQuery('#home-link', '#qunit-fixture').click(); - }); + run(() => jQuery('#default-post-link', '#qunit-fixture').click()); + run(() => jQuery('#home-link', '#qunit-fixture').click()); }); QUnit.test('{{link-to}} active property respects changing parent route context', function() { @@ -1624,9 +1497,8 @@ QUnit.test('{{link-to}} with only query-params and a block updates when route ch bootApplication(); equal(jQuery('#the-link').attr('href'), '/?bar=NAW&foo=456', 'link has right href'); - run(function() { - router.handleURL('/about'); - }); + run(() => router.handleURL('/about')); + equal(jQuery('#the-link').attr('href'), '/about?bar=NAW&foo=456', 'link has right href'); }); @@ -1658,9 +1530,8 @@ QUnit.test('Block-less {{link-to}} with only query-params updates when route cha bootApplication(); equal(jQuery('#the-link').attr('href'), '/?bar=NAW&foo=456', 'link has right href'); - run(function() { - router.handleURL('/about'); - }); + run(() => router.handleURL('/about')); + equal(jQuery('#the-link').attr('href'), '/about?bar=NAW&foo=456', 'link has right href'); }); @@ -1693,15 +1564,13 @@ QUnit.test('The {{link-to}} helper can use dynamic params', function() { bootApplication(); - run(function() { - router.handleURL('/'); - }); + run(() => router.handleURL('/')); let link = jQuery('#dynamic-link', '#qunit-fixture'); equal(link.attr('href'), '/foo/one/two'); - run(function() { + run(() => { controller.set('dynamicLinkParams', [ 'bar', 'one', diff --git a/packages/ember/tests/helpers/link_to_test/link_to_transitioning_classes_test.js b/packages/ember/tests/helpers/link_to_test/link_to_transitioning_classes_test.js index 6b592cce45d..2ab5059fbab 100644 --- a/packages/ember/tests/helpers/link_to_test/link_to_transitioning_classes_test.js +++ b/packages/ember/tests/helpers/link_to_test/link_to_transitioning_classes_test.js @@ -8,9 +8,9 @@ import jQuery from 'ember-views/system/jquery'; import NoneLocation from 'ember-routing/location/none_location'; import { setTemplates, set as setTemplate } from 'ember-templates/template_registry'; -var Router, App, router, registry, container; +let Router, App, router, registry, container; -var aboutDefer, otherDefer; +let aboutDefer, otherDefer; function bootApplication() { router = container.lookup('router:main'); @@ -18,16 +18,16 @@ function bootApplication() { } function assertHasClass(className) { - var i = 1; + let i = 1; while (i < arguments.length) { - var $a = arguments[i]; - var shouldHaveClass = arguments[i + 1]; + let $a = arguments[i]; + let shouldHaveClass = arguments[i + 1]; equal($a.hasClass(className), shouldHaveClass, $a.attr('id') + ' should ' + (shouldHaveClass ? '' : 'not ') + 'have class ' + className); i += 2; } } -var updateCount, replaceCount; +let updateCount, replaceCount; function sharedSetup() { App = Application.create({ @@ -58,14 +58,14 @@ function sharedSetup() { } function sharedTeardown() { - run(function() { App.destroy(); }); + run(() => App.destroy()); setTemplates({}); } QUnit.module('The {{link-to}} helper: .transitioning-in .transitioning-out CSS classes', { setup() { - run(function() { + run(() => { sharedSetup(); registry.unregister('router:main'); @@ -104,9 +104,9 @@ QUnit.test('while a transition is underway', function() { expect(18); bootApplication(); - var $index = jQuery('#index-link'); - var $about = jQuery('#about-link'); - var $other = jQuery('#other-link'); + let $index = jQuery('#index-link'); + let $about = jQuery('#about-link'); + let $other = jQuery('#other-link'); run($about, 'click'); @@ -160,9 +160,9 @@ QUnit.test('while a transition is underway with nested link-to\'s', function() { bootApplication(); - var $index = jQuery('#index-link'); - var $about = jQuery('#about-link'); - var $other = jQuery('#other-link'); + let $index = jQuery('#index-link'); + let $about = jQuery('#about-link'); + let $other = jQuery('#other-link'); run($about, 'click'); diff --git a/packages/ember/tests/helpers/link_to_test/link_to_with_query_params_test.js b/packages/ember/tests/helpers/link_to_test/link_to_with_query_params_test.js index 925603281f2..e449c467249 100644 --- a/packages/ember/tests/helpers/link_to_test/link_to_with_query_params_test.js +++ b/packages/ember/tests/helpers/link_to_test/link_to_with_query_params_test.js @@ -9,7 +9,7 @@ import jQuery from 'ember-views/system/jquery'; import NoneLocation from 'ember-routing/location/none_location'; import { setTemplates, set as setTemplate } from 'ember-templates/template_registry'; -var Router, App, router, registry, container; +let Router, App, router, registry, container; function bootApplication() { router = container.lookup('router:main'); @@ -26,11 +26,11 @@ function shouldBeActive(selector) { } function checkActive(selector, active) { - var classList = jQuery(selector, '#qunit-fixture')[0].className; + let classList = jQuery(selector, '#qunit-fixture')[0].className; equal(classList.indexOf('active') > -1, active, selector + ' active should be ' + active.toString()); } -var updateCount, replaceCount; +let updateCount, replaceCount; function sharedSetup() { App = Application.create({ @@ -61,14 +61,14 @@ function sharedSetup() { } function sharedTeardown() { - run(function() { App.destroy(); }); + run(() => App.destroy()); setTemplates({}); } if (isEnabled('ember-routing-route-configured-query-params')) { QUnit.module('The {{link-to}} helper: invoking with query params when defined on a route', { setup() { - run(function() { + run(() => { sharedSetup(); App.IndexController = Controller.extend({ boundThing: 'OMG' @@ -114,7 +114,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); run(jQuery('#the-link'), 'click'); - var indexController = container.lookup('controller:index'); + let indexController = container.lookup('controller:index'); deepEqual(indexController.getProperties('foo', 'bar'), { foo: '123', bar: 'abc' }, 'controller QP properties not'); }); @@ -123,7 +123,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); run(jQuery('#the-link'), 'click'); - var indexController = container.lookup('controller:index'); + let indexController = container.lookup('controller:index'); deepEqual(indexController.getProperties('foo', 'bar'), { foo: '123', bar: 'abc' }, 'controller QP properties not'); }); @@ -139,7 +139,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); run(jQuery('#the-link'), 'click'); - var indexController = container.lookup('controller:index'); + let indexController = container.lookup('controller:index'); deepEqual(indexController.getProperties('foo', 'bar'), { foo: '123', bar: 'abc' }, 'controller QP properties not'); }); @@ -148,7 +148,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); run(jQuery('#the-link'), 'click'); - var indexController = container.lookup('controller:index'); + let indexController = container.lookup('controller:index'); deepEqual(indexController.getProperties('foo', 'bar'), { foo: '456', bar: 'abc' }, 'controller QP properties updated'); }); @@ -157,7 +157,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); run(jQuery('#the-link'), 'click'); - var indexController = container.lookup('controller:index'); + let indexController = container.lookup('controller:index'); deepEqual(indexController.getProperties('foo', 'bar'), { foo: '456', bar: 'abc' }, 'controller QP properties updated'); }); @@ -171,7 +171,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { equal(jQuery('#the-link').attr('href'), '/about?baz=lol'); run(jQuery('#the-link'), 'click'); - var aboutController = container.lookup('controller:about'); + let aboutController = container.lookup('controller:about'); deepEqual(aboutController.getProperties('baz', 'bat'), { baz: 'lol', bat: 'borf' }, 'about controller QP properties updated'); equal(container.lookup('controller:application').get('currentPath'), 'about'); @@ -181,7 +181,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { setTemplate('index', compile("{{#link-to (query-params foo=boundThing) id='the-link'}}Index{{/link-to}}")); bootApplication(); - var indexController = container.lookup('controller:index'); + let indexController = container.lookup('controller:index'); equal(jQuery('#the-link').attr('href'), '/?foo=OMG'); @@ -190,7 +190,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { }); QUnit.test('supplied QP properties can be bound (booleans)', function() { - var indexController = container.lookup('controller:index'); + let indexController = container.lookup('controller:index'); setTemplate('index', compile("{{#link-to (query-params abool=boundThing) id='the-link'}}Index{{/link-to}}")); bootApplication(); @@ -209,7 +209,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); - var indexController = container.lookup('controller:index'); + let indexController = container.lookup('controller:index'); equal(jQuery('#the-link').attr('href'), '/?foo=lol'); run(indexController, 'set', 'bar', 'BORF'); @@ -245,23 +245,21 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); - run(function() { - router.handleURL('/cars/create'); - }); + run(() => router.handleURL('/cars/create')); - run(function() { + run(() => { equal(router.currentRouteName, 'cars.create'); jQuery('#close-link').click(); }); - run(function() { + run(() => { equal(router.currentRouteName, 'cars.index'); equal(router.get('url'), '/cars'); equal(container.lookup('controller:cars').get('page'), 1, 'The page query-param is 1'); jQuery('#page2-link').click(); }); - run(function() { + run(() => { equal(router.currentRouteName, 'cars.index', 'The active route is still cars'); equal(router.get('url'), '/cars?page=2', 'The url has been updated'); equal(container.lookup('controller:cars').get('page'), 2, 'The query params have been updated'); @@ -338,23 +336,21 @@ if (isEnabled('ember-routing-route-configured-query-params')) { shouldBeActive('#change-nothing'); //Multiple params - run(function() { - router.handleURL('/search?search=same'); - }); + run(() => router.handleURL('/search?search=same')); + shouldBeActive('#same-search'); shouldNotBeActive('#change-search'); shouldNotBeActive('#same-search-add-archive'); shouldNotBeActive('#only-add-archive'); shouldNotBeActive('#remove-one'); - run(function() { - router.handleURL('/search?search=same&archive=true'); - }); + run(() => router.handleURL('/search?search=same&archive=true')); + shouldBeActive('#both-same'); shouldNotBeActive('#change-one'); //Nested Controllers - run(function() { + run(() => { // Note: this is kind of a strange case; sort's default value is 'title', // so this URL shouldn't have been generated in the first place, but // we should also be able to gracefully handle these cases. @@ -489,7 +485,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { equal(jQuery('#parent-link').attr('href'), '/parent'); shouldBeActive('#parent-link'); - var parentController = container.lookup('controller:parent'); + let parentController = container.lookup('controller:parent'); equal(parentController.get('page'), 2); run(parentController, 'set', 'page', 3); equal(router.get('location.path'), '/parent?page=3'); @@ -502,10 +498,9 @@ if (isEnabled('ember-routing-route-configured-query-params')) { } else { QUnit.module('The {{link-to}} helper: invoking with query params', { setup() { - run(function() { + run(() => { sharedSetup(); - App.IndexController = Controller.extend({ queryParams: ['foo', 'bar', 'abool'], foo: '123', @@ -533,7 +528,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); run(jQuery('#the-link'), 'click'); - var indexController = container.lookup('controller:index'); + let indexController = container.lookup('controller:index'); deepEqual(indexController.getProperties('foo', 'bar'), { foo: '123', bar: 'abc' }, 'controller QP properties not'); }); @@ -542,15 +537,13 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); run(jQuery('#the-link'), 'click'); - var indexController = container.lookup('controller:index'); + let indexController = container.lookup('controller:index'); deepEqual(indexController.getProperties('foo', 'bar'), { foo: '123', bar: 'abc' }, 'controller QP properties not'); }); QUnit.test('link-to with no params throws', function() { setTemplate('index', compile("{{#link-to id='the-link'}}Index{{/link-to}}")); - expectAssertion(function() { - bootApplication(); - }, /one or more/); + expectAssertion(() => bootApplication(), /one or more/); }); QUnit.test("doesn't update controller QP properties on current route when invoked (empty query-params obj, inferred route)", function() { @@ -558,7 +551,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); run(jQuery('#the-link'), 'click'); - var indexController = container.lookup('controller:index'); + let indexController = container.lookup('controller:index'); deepEqual(indexController.getProperties('foo', 'bar'), { foo: '123', bar: 'abc' }, 'controller QP properties not'); }); @@ -567,7 +560,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); run(jQuery('#the-link'), 'click'); - var indexController = container.lookup('controller:index'); + let indexController = container.lookup('controller:index'); deepEqual(indexController.getProperties('foo', 'bar'), { foo: '456', bar: 'abc' }, 'controller QP properties updated'); }); @@ -576,7 +569,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); run(jQuery('#the-link'), 'click'); - var indexController = container.lookup('controller:index'); + let indexController = container.lookup('controller:index'); deepEqual(indexController.getProperties('foo', 'bar'), { foo: '456', bar: 'abc' }, 'controller QP properties updated'); }); @@ -590,14 +583,14 @@ if (isEnabled('ember-routing-route-configured-query-params')) { equal(jQuery('#the-link').attr('href'), '/about?baz=lol'); run(jQuery('#the-link'), 'click'); - var aboutController = container.lookup('controller:about'); + let aboutController = container.lookup('controller:about'); deepEqual(aboutController.getProperties('baz', 'bat'), { baz: 'lol', bat: 'borf' }, 'about controller QP properties updated'); equal(container.lookup('controller:application').get('currentPath'), 'about'); }); QUnit.test('supplied QP properties can be bound', function() { - var indexController = container.lookup('controller:index'); + let indexController = container.lookup('controller:index'); setTemplate('index', compile("{{#link-to (query-params foo=boundThing) id='the-link'}}Index{{/link-to}}")); bootApplication(); @@ -608,7 +601,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { }); QUnit.test('supplied QP properties can be bound (booleans)', function() { - var indexController = container.lookup('controller:index'); + let indexController = container.lookup('controller:index'); setTemplate('index', compile("{{#link-to (query-params abool=boundThing) id='the-link'}}Index{{/link-to}}")); bootApplication(); @@ -626,7 +619,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { setTemplate('index', compile("{{#link-to (query-params foo='lol') id='the-link'}}Index{{/link-to}}")); bootApplication(); - var indexController = container.lookup('controller:index'); + let indexController = container.lookup('controller:index'); equal(jQuery('#the-link').attr('href'), '/?foo=lol'); run(indexController, 'set', 'bar', 'BORF'); @@ -661,25 +654,23 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); - var carsController = container.lookup('controller:cars'); + let carsController = container.lookup('controller:cars'); - run(function() { - router.handleURL('/cars/create'); - }); + run(() => router.handleURL('/cars/create')); - run(function() { + run(() => { equal(router.currentRouteName, 'cars.create'); jQuery('#close-link').click(); }); - run(function() { + run(() => { equal(router.currentRouteName, 'cars.index'); equal(router.get('url'), '/cars'); equal(carsController.get('page'), 1, 'The page query-param is 1'); jQuery('#page2-link').click(); }); - run(function() { + run(() => { equal(router.currentRouteName, 'cars.index', 'The active route is still cars'); equal(router.get('url'), '/cars?page=2', 'The url has been updated'); equal(carsController.get('page'), 2, 'The query params have been updated'); @@ -746,23 +737,20 @@ if (isEnabled('ember-routing-route-configured-query-params')) { shouldBeActive('#change-nothing'); //Multiple params - run(function() { - router.handleURL('/search?search=same'); - }); + run(() => router.handleURL('/search?search=same')); shouldBeActive('#same-search'); shouldNotBeActive('#change-search'); shouldNotBeActive('#same-search-add-archive'); shouldNotBeActive('#only-add-archive'); shouldNotBeActive('#remove-one'); - run(function() { - router.handleURL('/search?search=same&archive=true'); - }); + run(() => router.handleURL('/search?search=same&archive=true')); + shouldBeActive('#both-same'); shouldNotBeActive('#change-one'); //Nested Controllers - run(function() { + run(() => { // Note: this is kind of a strange case; sort's default value is 'title', // so this URL shouldn't have been generated in the first place, but // we should also be able to gracefully handle these cases. @@ -878,7 +866,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { equal(jQuery('#parent-link').attr('href'), '/parent'); shouldBeActive('#parent-link'); - var parentController = container.lookup('controller:parent'); + let parentController = container.lookup('controller:parent'); equal(parentController.get('page'), 2); run(parentController, 'set', 'page', 3); equal(router.get('location.path'), '/parent?page=3'); @@ -889,4 +877,3 @@ if (isEnabled('ember-routing-route-configured-query-params')) { equal(router.get('location.path'), '/parent'); }); } - diff --git a/packages/ember/tests/homepage_example_test.js b/packages/ember/tests/homepage_example_test.js index 64f0c3ffcf1..fec615add72 100644 --- a/packages/ember/tests/homepage_example_test.js +++ b/packages/ember/tests/homepage_example_test.js @@ -8,7 +8,7 @@ import jQuery from 'ember-views/system/jquery'; import { A as emberA } from 'ember-runtime/system/native_array'; import { setTemplates, set as setTemplate } from 'ember-templates/template_registry'; -var App, $fixture; +let App, $fixture; function setupExample() { // setup templates @@ -26,7 +26,7 @@ function setupExample() { App.IndexRoute = Route.extend({ model() { - var people = emberA([ + let people = emberA([ App.Person.create({ firstName: 'Tom', lastName: 'Dale' @@ -43,7 +43,7 @@ function setupExample() { QUnit.module('Homepage Example', { setup() { - run(function() { + run(() => { App = Application.create({ name: 'App', rootElement: '#qunit-fixture' @@ -62,9 +62,7 @@ QUnit.module('Homepage Example', { }, teardown() { - run(function() { - App.destroy(); - }); + run(() => App.destroy()); App = null; diff --git a/packages/ember/tests/integration/multiple-app-test.js b/packages/ember/tests/integration/multiple-app-test.js index 60592b22996..0f1763ab750 100644 --- a/packages/ember/tests/integration/multiple-app-test.js +++ b/packages/ember/tests/integration/multiple-app-test.js @@ -4,12 +4,12 @@ import Application from 'ember-application/system/application'; import Component from 'ember-templates/component'; import jQuery from 'ember-views/system/jquery'; -var App1, App2, actions; +let App1, App2, actions; function startApp(rootElement) { - var application; + let application; - run(function() { + run(() => { application = Application.create({ rootElement }); @@ -19,11 +19,11 @@ function startApp(rootElement) { location: 'none' }); - var registry = application.__registry__; + let registry = application.__registry__; registry.register('component:special-button', Component.extend({ actions: { - doStuff: function() { + doStuff() { actions.push(rootElement); } } @@ -37,7 +37,7 @@ function startApp(rootElement) { } function handleURL(application, path) { - var router = application.__container__.lookup('router:main'); + let router = application.__container__.lookup('router:main'); return run(router, 'handleURL', path); } diff --git a/packages/ember/tests/routing/basic_test.js b/packages/ember/tests/routing/basic_test.js index 0441fdf0df6..c118f0d1ed1 100644 --- a/packages/ember/tests/routing/basic_test.js +++ b/packages/ember/tests/routing/basic_test.js @@ -24,9 +24,9 @@ import { addObserver } from 'ember-metal/observer'; import { setTemplates, set as setTemplate } from 'ember-templates/template_registry'; import { test, asyncTest } from 'internal-test-helpers/tests/skip-if-glimmer'; -var trim = jQuery.trim; +let trim = jQuery.trim; -var Router, App, router, registry, container, originalLoggerError; +let Router, App, router, registry, container, originalLoggerError; function bootApplication() { router = container.lookup('router:main'); @@ -34,7 +34,7 @@ function bootApplication() { } function handleURL(path) { - return run(function() { + return run(() => { return router.handleURL(path).then(function(value) { ok(true, 'url: `' + path + '` was handled'); return value; @@ -46,7 +46,7 @@ function handleURL(path) { } function handleURLAborts(path) { - run(function() { + run(() => { router.handleURL(path).then(function(value) { ok(false, 'url: `' + path + '` was NOT to be handled'); }, function(reason) { @@ -56,7 +56,7 @@ function handleURLAborts(path) { } function handleURLRejectsWith(path, expectedReason) { - run(function() { + run(() => { router.handleURL(path).then(function(value) { ok(false, 'expected handleURLing: `' + path + '` to fail'); }, function(reason) { @@ -67,7 +67,7 @@ function handleURLRejectsWith(path, expectedReason) { QUnit.module('Basic Routing', { setup() { - run(function() { + run(() => { App = Application.create({ name: 'App', rootElement: '#qunit-fixture' @@ -97,7 +97,7 @@ QUnit.module('Basic Routing', { }, teardown() { - run(function() { + run(() => { App.destroy(); App = null; @@ -112,14 +112,10 @@ QUnit.test('warn on URLs not included in the route set', function () { this.route('home', { path: '/' }); }); - bootApplication(); - expectAssertion(function() { - run(function() { - router.handleURL('/what-is-this-i-dont-even'); - }); - }, 'The URL \'/what-is-this-i-dont-even\' did not match any routes in your application'); + expectAssertion(() => run(() => router.handleURL('/what-is-this-i-dont-even')), + 'The URL \'/what-is-this-i-dont-even\' did not match any routes in your application'); }); QUnit.test('The Homepage', function() { @@ -130,7 +126,7 @@ QUnit.test('The Homepage', function() { App.HomeRoute = Route.extend({ }); - var currentPath; + let currentPath; App.ApplicationController = Controller.extend({ currentPathDidChange: observer('currentPath', function() { @@ -159,7 +155,7 @@ QUnit.test('The Home page and the Camelot page with multiple Router.map calls', App.CamelotRoute = Route.extend({ }); - var currentPath; + let currentPath; App.ApplicationController = Controller.extend({ currentPathDidChange: observer('currentPath', function() { @@ -367,9 +363,7 @@ QUnit.test('defining templateName allows other templates to be rendered', functi equal(jQuery('p', '#qunit-fixture').text(), 'THIS IS THE REAL HOME', 'The homepage template was rendered'); - run(function() { - router.send('showAlert'); - }); + run(() => router.send('showAlert')); equal(jQuery('.alert-box', '#qunit-fixture').text(), 'Invader!', 'Template for alert was render into outlet'); }); @@ -642,7 +636,7 @@ QUnit.test('The Special Page returning a promise puts the app into a loading sta this.route('special', { path: '/specials/:menu_item_id' }); }); - var menuItem, resolve; + let menuItem, resolve; App.MenuItem = EmberObject.extend(); App.MenuItem.reopenClass({ @@ -681,9 +675,7 @@ QUnit.test('The Special Page returning a promise puts the app into a loading sta equal(jQuery('p', '#qunit-fixture').text(), 'LOADING!', 'The app is in the loading state'); - run(function() { - resolve(menuItem); - }); + run(() => resolve(menuItem)); equal(jQuery('p', '#qunit-fixture').text(), '1', 'The app is now in the specials state'); }); @@ -737,7 +729,7 @@ asyncTest("The Special page returning an error fires the error hook on SpecialRo this.route("special", { path: "/specials/:menu_item_id" }); }); - var menuItem; + let menuItem; App.MenuItem = Ember.Object.extend(); App.MenuItem.reopenClass({ @@ -772,7 +764,7 @@ test('The Special page returning an error invokes SpecialRoute\'s error handler' this.route('special', { path: '/specials/:menu_item_id' }); }); - var menuItem, promise, resolve; + let menuItem, promise, resolve; App.MenuItem = EmberObject.extend(); App.MenuItem.reopenClass({ @@ -802,9 +794,7 @@ test('The Special page returning an error invokes SpecialRoute\'s error handler' handleURLRejectsWith('/specials/1', 'Setup error'); - run(function() { - resolve(menuItem); - }); + run(() => resolve(menuItem)); }); let testOverridableErrorHandler = function(handlersName) { @@ -815,7 +805,7 @@ let testOverridableErrorHandler = function(handlersName) { this.route('special', { path: '/specials/:menu_item_id' }); }); - var menuItem, resolve; + let menuItem, resolve; App.MenuItem = EmberObject.extend(); App.MenuItem.reopenClass({ @@ -827,7 +817,7 @@ let testOverridableErrorHandler = function(handlersName) { } }); - var attrs = {}; + let attrs = {}; attrs[handlersName] = { error(reason) { equal(reason, 'Setup error', 'error was correctly passed to custom ApplicationRoute handler'); @@ -847,9 +837,7 @@ let testOverridableErrorHandler = function(handlersName) { handleURLRejectsWith('/specials/1', 'Setup error'); - run(function() { - resolve(menuItem); - }); + run(() => resolve(menuItem)); }; test('ApplicationRoute\'s default error handler can be overridden', function() { @@ -884,16 +872,14 @@ QUnit.asyncTest('Moving from one page to another triggers the correct callbacks' registry.register('controller:special', Controller.extend()); - var transition = handleURL('/'); + let transition = handleURL('/'); - run(function() { + run(() => { transition.then(function() { equal(jQuery('h3', '#qunit-fixture').text(), 'Home', 'The app is now in the initial state'); - var promiseContext = App.MenuItem.create({ id: 1 }); - run.later(function() { - RSVP.resolve(promiseContext); - }, 1); + let promiseContext = App.MenuItem.create({ id: 1 }); + run.later(() => RSVP.resolve(promiseContext), 1); return router.transitionTo('special', promiseContext); }).then(function(result) { @@ -955,7 +941,7 @@ QUnit.asyncTest('Nested callbacks are not exited when moving to siblings', funct }); } - var currentPath; + let currentPath; App.ApplicationController = Controller.extend({ currentPathDidChange: observer('currentPath', function() { @@ -963,7 +949,7 @@ QUnit.asyncTest('Nested callbacks are not exited when moving to siblings', funct }) }); - var menuItem; + let menuItem; App.MenuItem = EmberObject.extend(); App.MenuItem.reopenClass({ @@ -999,10 +985,10 @@ QUnit.asyncTest('Nested callbacks are not exited when moving to siblings', funct '

LOADING!

' )); - var rootSetup = 0; - var rootRender = 0; - var rootModel = 0; - var rootSerialize = 0; + let rootSetup = 0; + let rootRender = 0; + let rootModel = 0; + let rootSerialize = 0; bootApplication(); @@ -1016,11 +1002,9 @@ QUnit.asyncTest('Nested callbacks are not exited when moving to siblings', funct router = container.lookup('router:main'); - run(function() { - var menuItem = App.MenuItem.create({ id: 1 }); - run.later(function() { - RSVP.resolve(menuItem); - }, 1); + run(() => { + let menuItem = App.MenuItem.create({ id: 1 }); + run.later(() => RSVP.resolve(menuItem), 1); router.transitionTo('special', menuItem).then(function(result) { equal(rootSetup, 1, 'The root setup was not triggered again'); @@ -1043,8 +1027,8 @@ asyncTest('Events are triggered on the controller if a matching action name is i this.route('home', { path: '/' }); }); - var model = { name: 'Tom Dale' }; - var stateIsNotCalled = true; + let model = { name: 'Tom Dale' }; + let stateIsNotCalled = true; App.HomeRoute = Route.extend({ model() { @@ -1062,7 +1046,7 @@ asyncTest('Events are triggered on the controller if a matching action name is i '{{name}}' )); - var controller = Controller.extend({ + let controller = Controller.extend({ actions: { showStuff(context) { ok(stateIsNotCalled, 'an event on the state is not triggered'); @@ -1076,9 +1060,9 @@ asyncTest('Events are triggered on the controller if a matching action name is i bootApplication(); - var actionId = jQuery('#qunit-fixture a').data('ember-action'); - var [ action ] = ActionManager.registeredActions[actionId]; - var event = new jQuery.Event('click'); + let actionId = jQuery('#qunit-fixture a').data('ember-action'); + let [ action ] = ActionManager.registeredActions[actionId]; + let event = new jQuery.Event('click'); action.handler(event); }); @@ -1087,7 +1071,7 @@ asyncTest('Events are triggered on the current state when defined in `actions` o this.route('home', { path: '/' }); }); - var model = { name: 'Tom Dale' }; + let model = { name: 'Tom Dale' }; App.HomeRoute = Route.extend({ model() { @@ -1110,9 +1094,9 @@ asyncTest('Events are triggered on the current state when defined in `actions` o bootApplication(); - var actionId = jQuery('#qunit-fixture a').data('ember-action'); - var [ action ] = ActionManager.registeredActions[actionId]; - var event = new jQuery.Event('click'); + let actionId = jQuery('#qunit-fixture a').data('ember-action'); + let [ action ] = ActionManager.registeredActions[actionId]; + let event = new jQuery.Event('click'); action.handler(event); }); @@ -1123,7 +1107,7 @@ asyncTest('Events defined in `actions` object are triggered on the current state }); }); - var model = { name: 'Tom Dale' }; + let model = { name: 'Tom Dale' }; App.RootRoute = Route.extend({ actions: { @@ -1148,9 +1132,9 @@ asyncTest('Events defined in `actions` object are triggered on the current state bootApplication(); - var actionId = jQuery('#qunit-fixture a').data('ember-action'); - var [ action ] = ActionManager.registeredActions[actionId]; - var event = new jQuery.Event('click'); + let actionId = jQuery('#qunit-fixture a').data('ember-action'); + let [ action ] = ActionManager.registeredActions[actionId]; + let event = new jQuery.Event('click'); action.handler(event); }); @@ -1197,8 +1181,8 @@ asyncTest('Actions are not triggered on the controller if a matching action name this.route('home', { path: '/' }); }); - var model = { name: 'Tom Dale' }; - var stateIsNotCalled = true; + let model = { name: 'Tom Dale' }; + let stateIsNotCalled = true; App.HomeRoute = Route.extend({ model() { @@ -1218,7 +1202,7 @@ asyncTest('Actions are not triggered on the controller if a matching action name '{{name}}' )); - var controller = Controller.extend({ + let controller = Controller.extend({ showStuff(context) { stateIsNotCalled = false; ok(stateIsNotCalled, 'an event on the state is not triggered'); @@ -1229,9 +1213,9 @@ asyncTest('Actions are not triggered on the controller if a matching action name bootApplication(); - var actionId = jQuery('#qunit-fixture a').data('ember-action'); - var [ action ] = ActionManager.registeredActions[actionId]; - var event = new jQuery.Event('click'); + let actionId = jQuery('#qunit-fixture a').data('ember-action'); + let [ action ] = ActionManager.registeredActions[actionId]; + let event = new jQuery.Event('click'); action.handler(event); }); @@ -1242,8 +1226,8 @@ asyncTest('actions can be triggered with multiple arguments', function() { }); }); - var model1 = { name: 'Tilde' }; - var model2 = { name: 'Tom Dale' }; + let model1 = { name: 'Tilde' }; + let model2 = { name: 'Tom Dale' }; App.RootRoute = Route.extend({ actions: { @@ -1268,9 +1252,9 @@ asyncTest('actions can be triggered with multiple arguments', function() { bootApplication(); - var actionId = jQuery('#qunit-fixture a').data('ember-action'); - var [ action ] = ActionManager.registeredActions[actionId]; - var event = new jQuery.Event('click'); + let actionId = jQuery('#qunit-fixture a').data('ember-action'); + let [ action ] = ActionManager.registeredActions[actionId]; + let event = new jQuery.Event('click'); action.handler(event); }); @@ -1283,7 +1267,7 @@ QUnit.test('transitioning multiple times in a single run loop only sets the URL bootApplication(); - var urlSetCount = 0; + let urlSetCount = 0; router.get('location').setURL = function(path) { urlSetCount++; @@ -1312,20 +1296,18 @@ QUnit.test('navigating away triggers a url property change', function() { bootApplication(); - run(function() { + run(() => { addObserver(router, 'url', function() { ok(true, 'url change event was fired'); }); }); - ['foo', 'bar', '/foo'].forEach(function(destination) { - run(router, 'transitionTo', destination); - }); + ['foo', 'bar', '/foo'].forEach(destination => run(router, 'transitionTo', destination)); }); QUnit.test('using replaceWith calls location.replaceURL if available', function() { - var setCount = 0; - var replaceCount = 0; + let setCount = 0; + let replaceCount = 0; Router.reopen({ location: NoneLocation.create({ @@ -1351,9 +1333,7 @@ QUnit.test('using replaceWith calls location.replaceURL if available', function( equal(setCount, 0); equal(replaceCount, 0); - run(function() { - router.replaceWith('foo'); - }); + run(() => router.replaceWith('foo')); equal(setCount, 0, 'should not call setURL'); equal(replaceCount, 1, 'should call replaceURL once'); @@ -1361,7 +1341,7 @@ QUnit.test('using replaceWith calls location.replaceURL if available', function( }); QUnit.test('using replaceWith calls setURL if location.replaceURL is not defined', function() { - var setCount = 0; + let setCount = 0; Router.reopen({ location: NoneLocation.create({ @@ -1381,9 +1361,7 @@ QUnit.test('using replaceWith calls setURL if location.replaceURL is not defined equal(setCount, 0); - run(function() { - router.replaceWith('foo'); - }); + run(() => router.replaceWith('foo')); equal(setCount, 1, 'should call setURL once'); equal(router.get('location').getURL(), '/foo'); @@ -1402,20 +1380,20 @@ QUnit.test('Route inherits model from parent route', function() { }); }); - var post1 = {}; - var post2 = {}; - var post3 = {}; - var currentPost; - var share1 = {}; - var share2 = {}; - var share3 = {}; + let post1 = {}; + let post2 = {}; + let post3 = {}; + let currentPost; + let share1 = {}; + let share2 = {}; + let share3 = {}; - var posts = { + let posts = { 1: post1, 2: post2, 3: post3 }; - var shares = { + let shares = { 1: share1, 2: share2, 3: share3 @@ -1429,7 +1407,7 @@ QUnit.test('Route inherits model from parent route', function() { App.ThePostCommentsRoute = Route.extend({ afterModel(post, transition) { - var parent_model = this.modelFor('thePost'); + let parent_model = this.modelFor('thePost'); equal(post, parent_model); } @@ -1443,7 +1421,7 @@ QUnit.test('Route inherits model from parent route', function() { App.SharesShareRoute = Route.extend({ afterModel(share, transition) { - var parent_model = this.modelFor('shares'); + let parent_model = this.modelFor('shares'); equal(share, parent_model); } @@ -1474,12 +1452,12 @@ QUnit.test('Routes with { resetNamespace: true } inherits model from parent rout }); }); - var post1 = {}; - var post2 = {}; - var post3 = {}; - var currentPost; + let post1 = {}; + let post2 = {}; + let post3 = {}; + let currentPost; - var posts = { + let posts = { 1: post1, 2: post2, 3: post3 @@ -1493,7 +1471,7 @@ QUnit.test('Routes with { resetNamespace: true } inherits model from parent rout App.CommentsRoute = Route.extend({ afterModel(post, transition) { - var parent_model = this.modelFor('thePost'); + let parent_model = this.modelFor('thePost'); equal(post, parent_model); } @@ -1520,12 +1498,12 @@ QUnit.test('It is possible to get the model from a parent route', function() { }); }); - var post1 = {}; - var post2 = {}; - var post3 = {}; - var currentPost; + let post1 = {}; + let post2 = {}; + let post3 = {}; + let currentPost; - var posts = { + let posts = { 1: post1, 2: post2, 3: post3 @@ -1563,8 +1541,8 @@ QUnit.test('A redirection hook is provided', function() { this.route('home'); }); - var chooseFollowed = 0; - var destination; + let chooseFollowed = 0; + let destination; App.ChooseRoute = Route.extend({ redirect() { @@ -1634,7 +1612,7 @@ QUnit.test('Redirecting to the current target in the middle of a route does not }); }); - var successCount = 0; + let successCount = 0; App.BarRoute = Route.extend({ redirect() { this.transitionTo('bar.baz').then(function() { @@ -1673,9 +1651,9 @@ QUnit.test('Redirecting to the current target with a different context aborts th }); }); - var model = { id: 2 }; + let model = { id: 2 }; - var count = 0; + let count = 0; App.BarRoute = Route.extend({ afterModel(context) { @@ -1721,15 +1699,13 @@ QUnit.test('Transitioning from a parent event does not prevent currentPath from bootApplication(); - var applicationController = getOwner(router).lookup('controller:application'); + let applicationController = getOwner(router).lookup('controller:application'); handleURL('/foo/bar/baz'); equal(applicationController.get('currentPath'), 'foo.bar.baz'); - run(function() { - router.send('goToQux'); - }); + run(() => router.send('goToQux')); equal(applicationController.get('currentPath'), 'foo.qux'); equal(router.get('location').getURL(), '/foo/qux'); @@ -1853,8 +1829,8 @@ QUnit.test('Rendering into specified template with slash notation', function() { }); QUnit.test('Parent route context change', function() { - var editCount = 0; - var editedPostIds = emberA(); + let editCount = 0; + let editedPostIds = emberA(); setTemplate('application', compile('{{outlet}}')); setTemplate('posts', compile('{{outlet}}')); @@ -1892,7 +1868,7 @@ QUnit.test('Parent route context change', function() { App.PostEditRoute = Route.extend({ model(params) { - var postId = this.modelFor('post').id; + let postId = this.modelFor('post').id; editedPostIds.push(postId); return null; }, @@ -1906,26 +1882,18 @@ QUnit.test('Parent route context change', function() { handleURL('/posts/1'); - run(function() { - router.send('editPost'); - }); - - run(function() { - router.send('showPost', { id: '2' }); - }); - - run(function() { - router.send('editPost'); - }); + run(() => router.send('editPost')); + run(() => router.send('showPost', { id: '2' })); + run(() => router.send('editPost')); equal(editCount, 2, 'set up the edit route twice without failure'); deepEqual(editedPostIds, ['1', '2'], 'modelFor posts.post returns the right context'); }); test('Router accounts for rootURL on page load when using history location', function() { - var rootURL = window.location.pathname + '/app'; - var postsTemplateRendered = false; - var setHistory, HistoryTestLocation; + let rootURL = window.location.pathname + '/app'; + let postsTemplateRendered = false; + let setHistory, HistoryTestLocation; setHistory = function(obj, path) { obj.set('history', { state: { path: path } }); @@ -1935,7 +1903,7 @@ test('Router accounts for rootURL on page load when using history location', fun // and set current location to rootURL + '/posts' HistoryTestLocation = HistoryLocation.extend({ initState() { - var path = rootURL + '/posts'; + let path = rootURL + '/posts'; setHistory(this, path); this.set('location', { @@ -1979,8 +1947,8 @@ test('Router accounts for rootURL on page load when using history location', fun QUnit.test('The rootURL is passed properly to the location implementation', function() { expect(1); - var rootURL = '/blahzorz'; - var HistoryTestLocation; + let rootURL = '/blahzorz'; + let HistoryTestLocation; HistoryTestLocation = HistoryLocation.extend({ rootURL: 'this is not the URL you are looking for', @@ -2036,7 +2004,7 @@ QUnit.test('Generating a URL should not affect currentModel', function() { this.route('post', { path: '/posts/:post_id' }); }); - var posts = { + let posts = { 1: { id: 1 }, 2: { id: 2 } }; @@ -2051,10 +2019,10 @@ QUnit.test('Generating a URL should not affect currentModel', function() { handleURL('/posts/1'); - var route = container.lookup('route:post'); + let route = container.lookup('route:post'); equal(route.modelFor('post'), posts[1]); - var url = router.generate('post', posts[2]); + let url = router.generate('post', posts[2]); equal(url, '/posts/2'); equal(route.modelFor('post'), posts[1]); @@ -2062,7 +2030,7 @@ QUnit.test('Generating a URL should not affect currentModel', function() { QUnit.test('Generated route should be an instance of App.Route if provided', function() { - var generatedRoute; + let generatedRoute; Router.map(function() { this.route('posts'); @@ -2088,9 +2056,7 @@ QUnit.test('Nested index route is not overriden by parent\'s implicit index rout bootApplication(); - run(function() { - router.transitionTo('posts', { category: 'emberjs' }); - }); + run(() => router.transitionTo('posts', { category: 'emberjs' })); deepEqual(router.location.path, '/posts/emberjs'); }); @@ -2113,10 +2079,9 @@ if (isEnabled('ember-route-serializers')) { bootApplication(); - run(function() { - expectDeprecation(function() { - router.transitionTo('posts', { category: 'emberjs' }); - }, 'Defining a serialize function on route \'posts.index\' is deprecated. Instead, define it in the router\'s map as an option.'); + run(() => { + expectDeprecation(() => router.transitionTo('posts', { category: 'emberjs' }), + 'Defining a serialize function on route \'posts.index\' is deprecated. Instead, define it in the router\'s map as an option.'); }); deepEqual(router.location.path, '/posts/emberjs'); @@ -2175,7 +2140,7 @@ test('The template is not re-rendered when the route\'s context changes', functi } }); - var insertionCount = 0; + let insertionCount = 0; App.FooBarComponent = Component.extend({ didInsertElement() { insertionCount += 1; @@ -2198,9 +2163,7 @@ test('The template is not re-rendered when the route\'s context changes', functi equal(jQuery('p', '#qunit-fixture').text(), 'second'); equal(insertionCount, 1, 'view should have inserted only once'); - run(function() { - router.transitionTo('page', EmberObject.create({ name: 'third' })); - }); + run(() => router.transitionTo('page', EmberObject.create({ name: 'third' }))); equal(jQuery('p', '#qunit-fixture').text(), 'third'); equal(insertionCount, 1, 'view should still have inserted only once'); @@ -2258,7 +2221,7 @@ test('The template is not re-rendered when two routes present the exact same tem equal(insertionCount, 1, 'expected one assertion'); // Then transition directly by route name - run(function() { + run(() => { router.transitionTo('third').then(function(value) { ok(true, 'expected transition'); }, function(reason) { @@ -2277,8 +2240,8 @@ test('The template is not re-rendered when two routes present the exact same tem }); QUnit.test('ApplicationRoute with model does not proxy the currentPath', function() { - var model = {}; - var currentPath; + let model = {}; + let currentPath; App.ApplicationRoute = Route.extend({ model() { return model; } @@ -2299,7 +2262,7 @@ QUnit.test('ApplicationRoute with model does not proxy the currentPath', functio QUnit.test('Promises encountered on app load put app into loading state until resolved', function() { expect(2); - var deferred = RSVP.defer(); + let deferred = RSVP.defer(); App.IndexRoute = Route.extend({ model() { @@ -2373,9 +2336,7 @@ QUnit.test('Route will assert if you try to explicitly render {into: ...} a miss } }); - expectAssertion(function() { - bootApplication(); - }, 'You attempted to render into \'nonexistent\' but it was not found'); + expectAssertion(() => bootApplication(), 'You attempted to render into \'nonexistent\' but it was not found'); }); test('Route supports clearing outlet explicitly', function() { @@ -2423,21 +2384,21 @@ test('Route supports clearing outlet explicitly', function() { handleURL('/posts'); equal(jQuery('div.posts-index:contains(postsIndex)', '#qunit-fixture').length, 1, 'The posts/index template was rendered'); - run(function() { - router.send('showModal'); - }); + + run(() => router.send('showModal')); + equal(jQuery('div.posts-modal:contains(postsModal)', '#qunit-fixture').length, 1, 'The posts/modal template was rendered'); - run(function() { - router.send('showExtra'); - }); + + run(() => router.send('showExtra')); + equal(jQuery('div.posts-extra:contains(postsExtra)', '#qunit-fixture').length, 1, 'The posts/extra template was rendered'); - run(function() { - router.send('hideModal'); - }); + + run(() => router.send('hideModal')); + equal(jQuery('div.posts-modal:contains(postsModal)', '#qunit-fixture').length, 0, 'The posts/modal template was removed'); - run(function() { - router.send('hideExtra'); - }); + + run(() => router.send('hideExtra')); + equal(jQuery('div.posts-extra:contains(postsExtra)', '#qunit-fixture').length, 0, 'The posts/extra template was removed'); run(function() { router.send('showModal'); @@ -2486,13 +2447,13 @@ test('Route supports clearing outlet using string parameter', function() { handleURL('/posts'); equal(jQuery('div.posts-index:contains(postsIndex)', '#qunit-fixture').length, 1, 'The posts/index template was rendered'); - run(function() { - router.send('showModal'); - }); + + run(() => router.send('showModal')); + equal(jQuery('div.posts-modal:contains(postsModal)', '#qunit-fixture').length, 1, 'The posts/modal template was rendered'); - run(function() { - router.send('hideModal'); - }); + + run(() => router.send('hideModal')); + equal(jQuery('div.posts-modal:contains(postsModal)', '#qunit-fixture').length, 0, 'The posts/modal template was removed'); handleURL('/users'); @@ -2530,9 +2491,9 @@ test('Route silently fails when cleaning an outlet from an inactive view', funct handleURL('/posts'); - run(function() { router.send('showModal'); }); - run(function() { router.send('hideSelf'); }); - run(function() { router.send('hideModal'); }); + run(() => router.send('showModal')); + run(() => router.send('hideSelf')); + run(() => router.send('hideModal')); }); QUnit.test('Router `willTransition` hook passes in cancellable transition', function() { @@ -2589,7 +2550,7 @@ QUnit.test('Aborting/redirecting the transition in `willTransition` prevents Loa this.route('about'); }); - var redirect = false; + let redirect = false; App.IndexRoute = Route.extend({ actions: { @@ -2605,7 +2566,7 @@ QUnit.test('Aborting/redirecting the transition in `willTransition` prevents Loa } }); - var deferred = null; + let deferred = null; App.LoadingRoute = Route.extend({ activate() { @@ -2692,7 +2653,7 @@ QUnit.test('`didTransition` can be reopened', function() { QUnit.test('`activate` event fires on the route', function() { expect(2); - var eventFired = 0; + let eventFired = 0; Router.map(function() { this.route('nork'); @@ -2720,7 +2681,7 @@ QUnit.test('`activate` event fires on the route', function() { QUnit.test('`deactivate` event fires on the route', function() { expect(2); - var eventFired = 0; + let eventFired = 0; Router.map(function() { this.route('nork'); @@ -2792,13 +2753,9 @@ QUnit.test('transitionTo returns Transition when passed a route name', function( this.route('bar'); }); - var transition = null; - bootApplication(); - run(function() { - transition = router.transitionTo('bar'); - }); + let transition = run(() => router.transitionTo('bar')); equal(transition instanceof Transition, true); }); @@ -2812,13 +2769,9 @@ QUnit.test('transitionTo returns Transition when passed a url', function() { }); }); - var transition = null; - bootApplication(); - run(function() { - transition = router.transitionTo('/bar/baz'); - }); + let transition = run(() => router.transitionTo('/bar/baz')); equal(transition instanceof Transition, true); }); @@ -2840,7 +2793,7 @@ QUnit.test('currentRouteName is a property installed on ApplicationController th bootApplication(); - var appController = getOwner(router).lookup('controller:application'); + let appController = getOwner(router).lookup('controller:application'); function transitionAndCheck(path, expectedPath, expectedRouteName) { if (path) { run(router, 'transitionTo', path); } @@ -2864,7 +2817,7 @@ QUnit.test('currentRouteName is a property installed on ApplicationController th }); QUnit.test('Route model hook finds the same model as a manual find', function() { - var Post; + let Post; App.Post = EmberObject.extend(); App.Post.reopenClass({ find() { @@ -2891,14 +2844,14 @@ QUnit.test('Routes can refresh themselves causing their model hooks to be re-run }); }); - var appcount = 0; + let appcount = 0; App.ApplicationRoute = Route.extend({ model() { ++appcount; } }); - var parentcount = 0; + let parentcount = 0; App.ParentRoute = Route.extend({ model(params) { equal(params.parent_id, '123'); @@ -2911,7 +2864,7 @@ QUnit.test('Routes can refresh themselves causing their model hooks to be re-run } }); - var childcount = 0; + let childcount = 0; App.ParentChildRoute = Route.extend({ model() { ++childcount; @@ -2994,8 +2947,8 @@ QUnit.test('Redirecting with null model doesn\'t error out', function() { QUnit.test('rejecting the model hooks promise with a non-error prints the `message` property', function() { expect(5); - var rejectedMessage = 'OMG!! SOOOOOO BAD!!!!'; - var rejectedStack = 'Yeah, buddy: stack gets printed too.'; + let rejectedMessage = 'OMG!! SOOOOOO BAD!!!!'; + let rejectedStack = 'Yeah, buddy: stack gets printed too.'; Router.map(function() { this.route('yippie', { path: '/' }); @@ -3023,8 +2976,8 @@ QUnit.test('rejecting the model hooks promise with a non-error prints the `messa QUnit.test('rejecting the model hooks promise with an error with `errorThrown` property prints `errorThrown.message` property', function() { expect(5); - var rejectedMessage = 'OMG!! SOOOOOO BAD!!!!'; - var rejectedStack = 'Yeah, buddy: stack gets printed too.'; + let rejectedMessage = 'OMG!! SOOOOOO BAD!!!!'; + let rejectedStack = 'Yeah, buddy: stack gets printed too.'; Router.map(function() { this.route('yippie', { path: '/' }); @@ -3044,9 +2997,7 @@ QUnit.test('rejecting the model hooks promise with an error with `errorThrown` p } }); - throws(function() { - bootApplication(); - }, function(err) { + throws(() => bootApplication(), function(err) { equal(err.message, rejectedMessage); return true; }, 'expected an exception'); @@ -3072,8 +3023,8 @@ QUnit.test('rejecting the model hooks promise with no reason still logs error', QUnit.test('rejecting the model hooks promise with a string shows a good error', function() { expect(3); - var originalLoggerError = Logger.error; - var rejectedMessage = 'Supercalifragilisticexpialidocious'; + let originalLoggerError = Logger.error; + let rejectedMessage = 'Supercalifragilisticexpialidocious'; Router.map(function() { this.route('yondo', { path: '/' }); @@ -3090,9 +3041,7 @@ QUnit.test('rejecting the model hooks promise with a string shows a good error', } }); - throws(function() { - bootApplication(); - }, rejectedMessage, 'expected an exception'); + throws(() => bootApplication(), rejectedMessage, 'expected an exception'); Logger.error = originalLoggerError; }); @@ -3128,7 +3077,7 @@ QUnit.test('willLeave, willChangeContext, willChangeModel actions don\'t fire un QUnit.test('Errors in transitionTo within redirect hook are logged', function() { expect(4); - var actual = []; + let actual = []; Router.map(function() { this.route('yondo', { path: '/' }); @@ -3146,9 +3095,7 @@ QUnit.test('Errors in transitionTo within redirect hook are logged', function() actual.push(arguments); }; - throws(function() { - bootApplication(); - }, /More context objects were passed/); + throws(() => bootApplication(), /More context objects were passed/); equal(actual.length, 1, 'the error is only logged once'); equal(actual[0][0], 'Error while processing route: yondo', 'source route is printed'); @@ -3169,9 +3116,7 @@ QUnit.test('Errors in transition show error template if available', function() { } }); - throws(function() { - bootApplication(); - }, /More context objects were passed/); + throws(() => bootApplication(), /More context objects were passed/); equal(jQuery('#error').length, 1, 'Error template was rendered.'); }); @@ -3187,9 +3132,9 @@ QUnit.test('Route#resetController gets fired when changing models and exiting ro this.route('out'); }); - var calls = []; + let calls = []; - var SpyRoute = Route.extend({ + let SpyRoute = Route.extend({ setupController(controller, model, transition) { calls.push(['setup', this.routeName]); }, @@ -3229,9 +3174,7 @@ QUnit.test('Exception during initialization of non-initial route is not swallowe } }); bootApplication(); - throws(function() { - run(router, 'transitionTo', 'boom'); - }, /\bboom\b/); + throws(() => run(router, 'transitionTo', 'boom'), /\bboom\b/); }); @@ -3239,7 +3182,7 @@ QUnit.test('Exception during load of non-initial route is not swallowed', functi Router.map(function() { this.route('boom'); }); - var lookup = container.lookup; + let lookup = container.lookup; container.lookup = function() { if (arguments[0] === 'route:boom') { throw new Error('boom!'); @@ -3252,9 +3195,7 @@ QUnit.test('Exception during load of non-initial route is not swallowed', functi } }); bootApplication(); - throws(function() { - run(router, 'transitionTo', 'boom'); - }); + throws(() => run(router, 'transitionTo', 'boom')); }); QUnit.test('Exception during initialization of initial route is not swallowed', function() { @@ -3266,16 +3207,14 @@ QUnit.test('Exception during initialization of initial route is not swallowed', throw new Error('boom!'); } }); - throws(function() { - bootApplication(); - }, /\bboom\b/); + throws(() => bootApplication(), /\bboom\b/); }); QUnit.test('Exception during load of initial route is not swallowed', function() { Router.map(function() { this.route('boom', { path: '/' }); }); - var lookup = container.lookup; + let lookup = container.lookup; container.lookup = function() { if (arguments[0] === 'route:boom') { throw new Error('boom!'); @@ -3287,9 +3226,7 @@ QUnit.test('Exception during load of initial route is not swallowed', function() throw new Error('boom!'); } }); - throws(function() { - bootApplication(); - }, /\bboom\b/); + throws(() => bootApplication(), /\bboom\b/); }); QUnit.test('{{outlet}} works when created after initial render', function() { @@ -3307,9 +3244,7 @@ QUnit.test('{{outlet}} works when created after initial render', function() { equal(jQuery('#qunit-fixture').text(), 'HiBye', 'initial render'); - run(function() { - container.lookup('controller:sample').set('showTheThing', true); - }); + run(() => container.lookup('controller:sample').set('showTheThing', true)); equal(jQuery('#qunit-fixture').text(), 'HiYayBye', 'second render'); @@ -3432,7 +3367,7 @@ QUnit.test('Can render routes with no \'main\' outlet and their children', funct }); App.AppRoute = Route.extend({ - renderTemplate : function() { + renderTemplate() { this.render('app', { outlet: 'app', into: 'application' @@ -3445,7 +3380,7 @@ QUnit.test('Can render routes with no \'main\' outlet and their children', funct }); App.SubRoute = Route.extend({ - renderTemplate : function() { + renderTemplate() { this.render('sub', { outlet: 'sub', into: 'app' @@ -3467,13 +3402,13 @@ test('Tolerates stacked renders', function() { setTemplate('layer', compile('layer')); App.ApplicationRoute = Route.extend({ actions: { - openLayer: function() { + openLayer() { this.render('layer', { into: 'application', outlet: 'modal' }); }, - close: function() { + close() { this.disconnectOutlet({ outlet: 'modal', parentView: 'application' @@ -3524,7 +3459,7 @@ test('Allows any route to disconnectOutlet another route\'s templates', function setTemplate('layer', compile('layer')); App.ApplicationRoute = Route.extend({ actions: { - openLayer: function() { + openLayer() { this.render('layer', { into: 'application', outlet: 'modal' @@ -3534,7 +3469,7 @@ test('Allows any route to disconnectOutlet another route\'s templates', function }); App.IndexRoute = Route.extend({ actions: { - close: function() { + close() { this.disconnectOutlet({ parentView: 'application', outlet: 'modal' @@ -3561,7 +3496,7 @@ test('Can this.render({into:...}) the render helper', function() { this.render({ into: 'foo' }); }, actions: { - changeToBar: function() { + changeToBar() { this.disconnectOutlet({ parentView: 'foo', outlet: 'main' @@ -3615,7 +3550,7 @@ test('Can this.render({into:...}) the render helper\'s children', function() { this.render('other', { into: 'index' }); }, actions: { - changeToBar: function() { + changeToBar() { this.disconnectOutlet({ parentView: 'index', outlet: 'main' @@ -3643,7 +3578,7 @@ test('Can disconnect from the render helper\'s children', function() { this.render('other', { into: 'index' }); }, actions: { - disconnect: function() { + disconnect() { this.disconnectOutlet({ parentView: 'index', outlet: 'main' @@ -3666,11 +3601,11 @@ test('Can this.render({into:...}) nested render helpers', function() { setTemplate('baz', compile('baz')); App.IndexRoute = Route.extend({ - renderTemplate: function() { + renderTemplate() { this.render({ into: 'bar' }); }, actions: { - changeToBaz: function() { + changeToBaz() { this.disconnectOutlet({ parentView: 'bar', outlet: 'main' @@ -3693,11 +3628,11 @@ test('Can disconnect from nested render helpers', function() { setTemplate('index', compile('other')); App.IndexRoute = Route.extend({ - renderTemplate: function() { + renderTemplate() { this.render({ into: 'bar' }); }, actions: { - disconnect: function() { + disconnect() { this.disconnectOutlet({ parentView: 'bar', outlet: 'main' @@ -3715,9 +3650,9 @@ test('Can disconnect from nested render helpers', function() { QUnit.test('Components inside an outlet have their didInsertElement hook invoked when the route is displayed', function(assert) { setTemplate('index', compile('{{#if showFirst}}{{my-component}}{{else}}{{other-component}}{{/if}}')); - var myComponentCounter = 0; - var otherComponentCounter = 0; - var indexController; + let myComponentCounter = 0; + let otherComponentCounter = 0; + let indexController; App.IndexController = Controller.extend({ showFirst: true @@ -3746,9 +3681,7 @@ QUnit.test('Components inside an outlet have their didInsertElement hook invoked assert.strictEqual(myComponentCounter, 1, 'didInsertElement invoked on displayed component'); assert.strictEqual(otherComponentCounter, 0, 'didInsertElement not invoked on displayed component'); - run(function() { - indexController.set('showFirst', false); - }); + run(() => indexController.set('showFirst', false)); assert.strictEqual(myComponentCounter, 1, 'didInsertElement not invoked on displayed component'); assert.strictEqual(otherComponentCounter, 1, 'didInsertElement invoked on displayed component'); @@ -3775,23 +3708,21 @@ QUnit.test('Doesnt swallow exception thrown from willTransition', function() { bootApplication(); - throws(function() { - run(function() { - router.handleURL('/other'); - }); + throws(() => { + run(() => router.handleURL('/other')); }, /boom/, 'expected an exception that didnt happen'); }); QUnit.test('Exception if outlet name is undefined in render and disconnectOutlet', function(assert) { App.ApplicationRoute = Route.extend({ actions: { - showModal: function() { + showModal() { this.render({ outlet: undefined, parentView: 'application' }); }, - hideModal: function() { + hideModal() { this.disconnectOutlet({ outlet: undefined, parentView: 'application' @@ -3802,11 +3733,11 @@ QUnit.test('Exception if outlet name is undefined in render and disconnectOutlet bootApplication(); - throws(function() { - run(function() { router.send('showModal'); }); + throws(() => { + run(() => router.send('showModal')); }, /You passed undefined as the outlet name/); - throws(function() { - run(function() { router.send('hideModal'); }); + throws(() => { + run(() => router.send('hideModal')); }, /You passed undefined as the outlet name/); }); diff --git a/packages/ember/tests/routing/query_params_test.js b/packages/ember/tests/routing/query_params_test.js index 6993575e14f..1c8c9460e51 100644 --- a/packages/ember/tests/routing/query_params_test.js +++ b/packages/ember/tests/routing/query_params_test.js @@ -15,7 +15,7 @@ import { dasherize } from 'ember-runtime/system/string'; import Mixin from 'ember-metal/mixin'; import { meta } from 'ember-metal/meta'; -var App, router, container; +let App, router, container; function bootApplication() { router = container.lookup('router:main'); @@ -23,7 +23,7 @@ function bootApplication() { } function handleURL(path) { - return run(function() { + return run(() => { return router.handleURL(path).then(function(value) { ok(true, 'url: `' + path + '` was handled'); return value; @@ -34,14 +34,14 @@ function handleURL(path) { }); } -var startingURL = ''; -var expectedReplaceURL, expectedPushURL; +let startingURL = ''; +let expectedReplaceURL, expectedPushURL; function setAndFlush(obj, prop, value) { run(obj, 'set', prop, value); } -var TestLocation = NoneLocation.extend({ +const TestLocation = NoneLocation.extend({ initState() { this.set('path', startingURL); }, @@ -70,7 +70,7 @@ var TestLocation = NoneLocation.extend({ }); function sharedSetup() { - run(function() { + run(() => { App = Application.create({ name: 'App', rootElement: '#qunit-fixture' @@ -98,7 +98,7 @@ function sharedSetup() { function sharedTeardown() { try { - run(function() { + run(() => { App.destroy(); App = null; }); @@ -135,7 +135,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); - var controller = container.lookup('controller:home'); + let controller = container.lookup('controller:home'); setAndFlush(controller, 'foo', '456'); @@ -161,7 +161,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); - var controller = container.lookup('controller:home'); + let controller = container.lookup('controller:home'); run(router, 'transitionTo', 'home', { queryParams: { page: '4' } }); equal(controller.get('page'), 4); @@ -178,7 +178,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); equal(router.get('location.path'), ''); - var controller = container.lookup('controller:index'); + let controller = container.lookup('controller:index'); setAndFlush(controller, 'foo', 'LEX'); @@ -206,7 +206,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); equal(router.get('location.path'), ''); - var controller = container.lookup('controller:index'); + let controller = container.lookup('controller:index'); setAndFlush(controller, 'funTimes', 'woot'); equal(router.get('location.path'), '/?fun-times=woot'); @@ -335,7 +335,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { QUnit.test('can opt into full transition by setting refreshModel in route queryParams when all configuration is in route', function() { expect(6); - var appModelCount = 0; + let appModelCount = 0; App.ApplicationRoute = Route.extend({ queryParams: { 'appomg': { @@ -347,7 +347,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { } }); - var indexModelCount = 0; + let indexModelCount = 0; App.IndexRoute = Route.extend({ queryParams: { omg: { @@ -371,7 +371,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { equal(appModelCount, 1); equal(indexModelCount, 1); - var indexController = container.lookup('controller:index'); + let indexController = container.lookup('controller:index'); setAndFlush(indexController, 'omg', 'lex'); equal(appModelCount, 1); @@ -396,7 +396,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { refreshModel: true } }, - refresh: function() { + refresh() { ok(false); } }); @@ -408,7 +408,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { QUnit.test('can use refreshModel even w URL changes that remove QPs from address bar when QP configured on route', function() { expect(4); - var indexModelCount = 0; + let indexModelCount = 0; App.IndexRoute = Route.extend({ queryParams: { omg: { @@ -419,7 +419,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { model(params) { indexModelCount++; - var data; + let data; if (indexModelCount === 1) { data = 'foo'; } else if (indexModelCount === 2) { @@ -434,7 +434,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); handleURL('/'); - var indexController = container.lookup('controller:index'); + let indexController = container.lookup('controller:index'); equal(indexController.get('omg'), 'lol'); }); @@ -454,7 +454,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { equal(router.get('location.path'), ''); - var appController = container.lookup('controller:application'); + let appController = container.lookup('controller:application'); expectedReplaceURL = '/?alex=wallace'; setAndFlush(appController, 'alex', 'wallace'); }); @@ -475,7 +475,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { equal(router.get('location.path'), ''); - var appController = container.lookup('controller:application'); + let appController = container.lookup('controller:application'); expectedReplaceURL = '/?commit_by=igor_seb'; setAndFlush(appController, 'commitBy', 'igor_seb'); }); @@ -498,7 +498,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); - var appController = container.lookup('controller:application'); + let appController = container.lookup('controller:application'); expectedPushURL = '/?alex=wallace&steely=jan'; run(appController, 'setProperties', { alex: 'wallace', steely: 'jan' }); @@ -519,7 +519,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { }); }); - var parentModelCount = 0; + let parentModelCount = 0; App.ParentRoute = Route.extend({ model() { parentModelCount++; @@ -558,7 +558,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { startingURL = '/?omg=borf'; bootApplication(); - var indexController = container.lookup('controller:index'); + let indexController = container.lookup('controller:index'); equal(indexController.get('omg'), 'borf'); run(router, 'transitionTo', '/'); equal(indexController.get('omg'), 'lol'); @@ -662,7 +662,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { startingURL = '/?foo=true'; bootApplication(); - var controller = container.lookup('controller:index'); + let controller = container.lookup('controller:index'); equal(controller.get('foo'), true); handleURL('/?foo=false'); @@ -681,7 +681,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { startingURL = '/?foo='; bootApplication(); - var controller = container.lookup('controller:index'); + let controller = container.lookup('controller:index'); equal(controller.get('foo'), ''); }); @@ -700,7 +700,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); - var controller = container.lookup('controller:home'); + let controller = container.lookup('controller:home'); setAndFlush(controller, 'foo', [1, 2]); @@ -743,7 +743,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { startingURL = '/?foo[]=1&foo[]=2&foo[]=3'; bootApplication(); - var controller = container.lookup('controller:index'); + let controller = container.lookup('controller:index'); deepEqual(controller.get('foo'), ['1', '2', '3']); }); @@ -761,7 +761,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { startingURL = '/?foo[]=1&foo[]=2&foo[]=3'; bootApplication(); - var controller = container.lookup('controller:index'); + let controller = container.lookup('controller:index'); deepEqual(controller.get('foo'), ['1', '2', '3']); }); @@ -784,7 +784,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { equal(router.get('location.path'), ''); - var controller = container.lookup('controller:home'); + let controller = container.lookup('controller:home'); run(controller.foo, 'pushObject', 1); equal(router.get('location.path'), '/?foo=%5B1%5D'); @@ -814,7 +814,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { QUnit.test('Overwriting with array with same content shouldn\'t refire update when configuration occurs on router but there is still a controller', function() { expect(3); - var modelCount = 0; + let modelCount = 0; App.Router.map(function() { this.route('home', { path: '/' }); @@ -836,7 +836,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); equal(modelCount, 1); - var controller = container.lookup('controller:home'); + let controller = container.lookup('controller:home'); setAndFlush(controller, 'model', emberA([1])); equal(modelCount, 1); equal(router.get('location.path'), ''); @@ -889,7 +889,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { }); bootApplication(); - var controller = container.lookup('controller:bar'); + let controller = container.lookup('controller:bar'); expectedPushURL = '/foo'; run(jQuery('#foo-link'), 'click'); @@ -929,11 +929,11 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); - var $link = jQuery('#the-link'); + let $link = jQuery('#the-link'); equal($link.attr('href'), '/example'); run($link, 'click'); - var controller = container.lookup('controller:example'); + let controller = container.lookup('controller:example'); equal(get(controller, 'foo'), undefined); }); @@ -1005,7 +1005,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); equal(router.get('location.path'), ''); - var controller = container.lookup('controller:index'); + let controller = container.lookup('controller:index'); setAndFlush(controller, 'funTimes', 'woot'); equal(router.get('location.path'), '/?fun-times=woot'); @@ -1041,9 +1041,9 @@ if (isEnabled('ember-routing-route-configured-query-params')) { App.register('template:about', compile("

{{link-to 'Home' 'home' (query-params foo='naw')}}

")); App.register('template:cats.index', compile("

{{link-to 'Cats' 'cats' (query-params name='domino') id='cats-link'}}

")); - var homeShouldBeCreated = false; - var aboutShouldBeCreated = false; - var catsIndexShouldBeCreated = false; + let homeShouldBeCreated = false; + let aboutShouldBeCreated = false; + let catsIndexShouldBeCreated = false; App.HomeRoute = Route.extend({ queryParams: { @@ -1114,7 +1114,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); equal(router.get('location.path'), '', 'url is correct'); - var controller = container.lookup('controller:home'); + let controller = container.lookup('controller:home'); setAndFlush(controller, 'foo', '456'); equal(router.get('location.path'), '/?foo=456', 'url is correct'); equal(jQuery('#link-to-about').attr('href'), '/about?lol=wat', 'link to about is correct'); @@ -1268,7 +1268,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { QUnit.test('can opt into full transition by setting refreshModel in route queryParams when configured on the route', function() { expect(6); - var appModelCount = 0; + let appModelCount = 0; App.ApplicationRoute = Route.extend({ queryParams: { 'appomg': { @@ -1280,7 +1280,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { } }); - var indexModelCount = 0; + let indexModelCount = 0; App.IndexRoute = Route.extend({ queryParams: { omg: { @@ -1304,7 +1304,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { equal(appModelCount, 1); equal(indexModelCount, 1); - var indexController = container.lookup('controller:index'); + let indexController = container.lookup('controller:index'); setAndFlush(indexController, 'omg', 'lex'); equal(appModelCount, 1); @@ -1315,7 +1315,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { QUnit.test('can use refreshModel even w URL changes that remove QPs from address bar when configured on the route', function() { expect(4); - var indexModelCount = 0; + let indexModelCount = 0; App.IndexRoute = Route.extend({ queryParams: { omg: { @@ -1326,7 +1326,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { model(params) { indexModelCount++; - var data; + let data; if (indexModelCount === 1) { data = 'foo'; } else if (indexModelCount === 2) { @@ -1341,7 +1341,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); handleURL('/'); - var indexController = container.lookup('controller:index'); + let indexController = container.lookup('controller:index'); equal(indexController.get('omg'), 'lol'); }); @@ -1361,7 +1361,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { equal(router.get('location.path'), ''); - var appController = container.lookup('controller:application'); + let appController = container.lookup('controller:application'); expectedReplaceURL = '/?alex=wallace'; setAndFlush(appController, 'alex', 'wallace'); }); @@ -1382,7 +1382,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { equal(router.get('location.path'), ''); - var appController = container.lookup('controller:application'); + let appController = container.lookup('controller:application'); expectedReplaceURL = '/?commit_by=igor_seb'; setAndFlush(appController, 'commitBy', 'igor_seb'); }); @@ -1405,7 +1405,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); - var appController = container.lookup('controller:application'); + let appController = container.lookup('controller:application'); expectedPushURL = '/?alex=wallace&steely=jan'; run(appController, 'setProperties', { alex: 'wallace', steely: 'jan' }); @@ -1426,7 +1426,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { }); }); - var parentModelCount = 0; + let parentModelCount = 0; App.ParentRoute = Route.extend({ model() { parentModelCount++; @@ -1527,7 +1527,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { startingURL = '/?omg=borf'; bootApplication(); - var indexController = container.lookup('controller:index'); + let indexController = container.lookup('controller:index'); equal(indexController.get('omg'), 'borf'); run(router, 'transitionTo', '/'); equal(indexController.get('omg'), 'lol'); @@ -1629,7 +1629,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { }); bootApplication(); - var controller = container.lookup('controller:index'); + let controller = container.lookup('controller:index'); expectedPushURL = '/?foo='; setAndFlush(controller, 'foo', ''); @@ -1646,7 +1646,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { }); bootApplication(); - var controller = container.lookup('controller:index'); + let controller = container.lookup('controller:index'); expectedPushURL = '/?foo='; setAndFlush(controller, 'foo', ''); @@ -1667,7 +1667,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { startingURL = '/?foo=true'; bootApplication(); - var controller = container.lookup('controller:index'); + let controller = container.lookup('controller:index'); equal(controller.get('foo'), true); handleURL('/?foo=false'); @@ -1686,7 +1686,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { startingURL = '/?foo='; bootApplication(); - var controller = container.lookup('controller:index'); + let controller = container.lookup('controller:index'); equal(controller.get('foo'), ''); }); @@ -1705,7 +1705,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); - var controller = container.lookup('controller:home'); + let controller = container.lookup('controller:home'); setAndFlush(controller, 'foo', [1, 2]); @@ -1748,7 +1748,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { startingURL = '/?foo[]=1&foo[]=2&foo[]=3'; bootApplication(); - var controller = container.lookup('controller:index'); + let controller = container.lookup('controller:index'); deepEqual(controller.get('foo'), ['1', '2', '3']); }); @@ -1769,7 +1769,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { equal(router.get('location.path'), ''); - var controller = container.lookup('controller:home'); + let controller = container.lookup('controller:home'); run(controller.foo, 'pushObject', 1); equal(router.get('location.path'), '/?foo=%5B1%5D'); @@ -1799,7 +1799,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { QUnit.test('Overwriting with array with same content shouldn\'t refire update when configured on the route', function() { expect(3); - var modelCount = 0; + let modelCount = 0; App.Router.map(function() { this.route('home', { path: '/' }); @@ -1819,7 +1819,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); equal(modelCount, 1); - var controller = container.lookup('controller:home'); + let controller = container.lookup('controller:home'); setAndFlush(controller, 'model', emberA([1])); equal(modelCount, 1); equal(router.get('location.path'), ''); @@ -1846,7 +1846,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { App.OtherRoute = Route.extend({ model(p, trans) { - var m = meta(trans.params.application); + let m = meta(trans.params.application); ok(!m.peekWatching('woot'), 'A meta object isn\'t constructed for this params POJO'); } }); @@ -1902,7 +1902,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { }); bootApplication(); - var controller = container.lookup('controller:bar'); + let controller = container.lookup('controller:bar'); expectedPushURL = '/foo'; run(jQuery('#foo-link'), 'click'); @@ -1940,11 +1940,11 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); - var $link = jQuery('#the-link'); + let $link = jQuery('#the-link'); equal($link.attr('href'), '/example'); run($link, 'click'); - var controller = container.lookup('controller:example'); + let controller = container.lookup('controller:example'); equal(get(controller, 'foo'), undefined); }); @@ -1968,10 +1968,10 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); - var controller = container.lookup('controller:example'); + let controller = container.lookup('controller:example'); - var $link1 = jQuery('#the-link1'); - var $link2 = jQuery('#the-link2'); + let $link1 = jQuery('#the-link1'); + let $link2 = jQuery('#the-link2'); equal($link1.attr('href'), '/example?bar=abc&foo=def'); equal($link2.attr('href'), '/example?bar=123&foo=456'); @@ -2014,7 +2014,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { startingURL = '/parent/child?foo=lol'; bootApplication(); - var parentController = container.lookup('controller:parent'); + let parentController = container.lookup('controller:parent'); equal(parentController.get('foo'), 'lol'); }); @@ -2043,7 +2043,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { startingURL = '/parent/child?foo=lol'; bootApplication(); - var parentController = container.lookup('controller:parent'); + let parentController = container.lookup('controller:parent'); equal(parentController.get('foo'), 'lol'); }); @@ -2060,7 +2060,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); - var controller = container.lookup('controller:home'); + let controller = container.lookup('controller:home'); setAndFlush(controller, 'foo', '456'); @@ -2082,7 +2082,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); - var controller = container.lookup('controller:home'); + let controller = container.lookup('controller:home'); setAndFlush(controller, 'foo', '456'); @@ -2102,7 +2102,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); equal(router.get('location.path'), ''); - var controller = container.lookup('controller:index'); + let controller = container.lookup('controller:index'); setAndFlush(controller, 'foo', 'LEX'); equal(router.get('location.path'), '/?other_foo=LEX'); @@ -2129,7 +2129,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); equal(router.get('location.path'), ''); - var controller = container.lookup('controller:index'); + let controller = container.lookup('controller:index'); setAndFlush(controller, 'funTimes', 'woot'); equal(router.get('location.path'), '/?fun-times=woot'); @@ -2150,7 +2150,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { QUnit.test('Can override inherited QP behavior by specifying queryParams as a computed property', function() { expect(0); - var SharedMixin = Mixin.create({ + let SharedMixin = Mixin.create({ queryParams: ['a'], a: 0 }); @@ -2163,7 +2163,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { }); bootApplication(); - var indexController = container.lookup('controller:index'); + let indexController = container.lookup('controller:index'); expectedReplaceURL = 'not gonna happen'; run(indexController, 'set', 'a', 1); @@ -2200,9 +2200,9 @@ if (isEnabled('ember-routing-route-configured-query-params')) { App.register('template:about', compile("

{{link-to 'Home' 'home' (query-params foo='naw')}}

")); App.register('template:cats.index', compile("

{{link-to 'Cats' 'cats' (query-params name='domino') id='cats-link'}}

")); - var homeShouldBeCreated = false; - var aboutShouldBeCreated = false; - var catsIndexShouldBeCreated = false; + let homeShouldBeCreated = false; + let aboutShouldBeCreated = false; + let catsIndexShouldBeCreated = false; App.HomeRoute = Route.extend({ setup() { @@ -2262,7 +2262,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); equal(router.get('location.path'), '', 'url is correct'); - var controller = container.lookup('controller:home'); + let controller = container.lookup('controller:home'); setAndFlush(controller, 'foo', '456'); equal(router.get('location.path'), '/?foo=456', 'url is correct'); equal(jQuery('#link-to-about').attr('href'), '/about?lol=wat', 'link to about is correct'); @@ -2426,14 +2426,14 @@ if (isEnabled('ember-routing-route-configured-query-params')) { omg: 'lol' }); - var appModelCount = 0; + let appModelCount = 0; App.ApplicationRoute = Route.extend({ model(params) { appModelCount++; } }); - var indexModelCount = 0; + let indexModelCount = 0; App.IndexRoute = Route.extend({ queryParams: { omg: { @@ -2456,7 +2456,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { equal(appModelCount, 1); equal(indexModelCount, 1); - var indexController = container.lookup('controller:index'); + let indexController = container.lookup('controller:index'); setAndFlush(indexController, 'omg', 'lex'); equal(appModelCount, 1); @@ -2481,7 +2481,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { refreshModel: true } }, - refresh: function() { + refresh() { ok(false); } }); @@ -2502,14 +2502,14 @@ if (isEnabled('ember-routing-route-configured-query-params')) { omg: 'lol' }); - var appModelCount = 0; + let appModelCount = 0; App.ApplicationRoute = Route.extend({ model(params) { appModelCount++; } }); - var indexModelCount = 0; + let indexModelCount = 0; App.IndexRoute = Route.extend({ queryParams: EmberObject.create({ unknownProperty(keyName) { @@ -2532,7 +2532,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { equal(appModelCount, 1); equal(indexModelCount, 1); - var indexController = container.lookup('controller:index'); + let indexController = container.lookup('controller:index'); setAndFlush(indexController, 'omg', 'lex'); equal(appModelCount, 1); @@ -2547,7 +2547,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { omg: 'lol' }); - var indexModelCount = 0; + let indexModelCount = 0; App.IndexRoute = Route.extend({ queryParams: { omg: { @@ -2557,7 +2557,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { model(params) { indexModelCount++; - var data; + let data; if (indexModelCount === 1) { data = 'foo'; } else if (indexModelCount === 2) { @@ -2572,7 +2572,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); handleURL('/'); - var indexController = container.lookup('controller:index'); + let indexController = container.lookup('controller:index'); equal(indexController.get('omg'), 'lol'); }); @@ -2595,7 +2595,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { equal(router.get('location.path'), ''); - var appController = container.lookup('controller:application'); + let appController = container.lookup('controller:application'); expectedReplaceURL = '/?alex=wallace'; setAndFlush(appController, 'alex', 'wallace'); }); @@ -2620,7 +2620,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { equal(router.get('location.path'), ''); - var appController = container.lookup('controller:application'); + let appController = container.lookup('controller:application'); expectedReplaceURL = '/?commit_by=igor_seb'; setAndFlush(appController, 'commitBy', 'igor_seb'); }); @@ -2647,7 +2647,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); - var appController = container.lookup('controller:application'); + let appController = container.lookup('controller:application'); expectedPushURL = '/?alex=wallace&steely=jan'; run(appController, 'setProperties', { alex: 'wallace', steely: 'jan' }); @@ -2668,7 +2668,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { }); }); - var parentModelCount = 0; + let parentModelCount = 0; App.ParentRoute = Route.extend({ model() { parentModelCount++; @@ -2717,7 +2717,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { equal(router.get('location.path'), ''); - var appController = container.lookup('controller:application'); + let appController = container.lookup('controller:application'); expectedReplaceURL = '/?alex=wallace'; setAndFlush(appController, 'alex', 'wallace'); }); @@ -2795,7 +2795,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { startingURL = '/?omg=borf'; bootApplication(); - var indexController = container.lookup('controller:index'); + let indexController = container.lookup('controller:index'); equal(indexController.get('omg'), 'borf'); run(router, 'transitionTo', '/'); equal(indexController.get('omg'), 'lol'); @@ -2880,7 +2880,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { }); bootApplication(); - var controller = container.lookup('controller:index'); + let controller = container.lookup('controller:index'); expectedPushURL = '/?foo='; setAndFlush(controller, 'foo', ''); @@ -2897,7 +2897,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { }); bootApplication(); - var controller = container.lookup('controller:index'); + let controller = container.lookup('controller:index'); expectedPushURL = '/?foo='; setAndFlush(controller, 'foo', ''); @@ -2918,7 +2918,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { startingURL = '/?foo=true'; bootApplication(); - var controller = container.lookup('controller:index'); + let controller = container.lookup('controller:index'); equal(controller.get('foo'), true); handleURL('/?foo=false'); @@ -2934,7 +2934,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { startingURL = '/?foo='; bootApplication(); - var controller = container.lookup('controller:index'); + let controller = container.lookup('controller:index'); equal(controller.get('foo'), ''); }); @@ -2950,7 +2950,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); - var controller = container.lookup('controller:home'); + let controller = container.lookup('controller:home'); setAndFlush(controller, 'foo', [1, 2]); @@ -2987,7 +2987,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { startingURL = '/?foo[]=1&foo[]=2&foo[]=3'; bootApplication(); - var controller = container.lookup('controller:index'); + let controller = container.lookup('controller:index'); deepEqual(controller.get('foo'), ['1', '2', '3']); }); @@ -3005,7 +3005,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { equal(router.get('location.path'), ''); - var controller = container.lookup('controller:home'); + let controller = container.lookup('controller:home'); run(controller.foo, 'pushObject', 1); equal(router.get('location.path'), '/?foo=%5B1%5D'); @@ -3035,7 +3035,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { QUnit.test('Overwriting with array with same content shouldn\'t refire update', function() { expect(3); - var modelCount = 0; + let modelCount = 0; App.Router.map(function() { this.route('home', { path: '/' }); @@ -3055,7 +3055,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); equal(modelCount, 1); - var controller = container.lookup('controller:home'); + let controller = container.lookup('controller:home'); setAndFlush(controller, 'model', emberA([1])); equal(modelCount, 1); equal(router.get('location.path'), ''); @@ -3079,7 +3079,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { App.OtherRoute = Route.extend({ model(p, trans) { - var m = meta(trans.params.application); + let m = meta(trans.params.application); ok(!m.peekWatching('woot'), 'A meta object isn\'t constructed for this params POJO'); } }); @@ -3138,7 +3138,7 @@ if (isEnabled('ember-routing-route-configured-query-params')) { }); bootApplication(); - var controller = container.lookup('controller:bar'); + let controller = container.lookup('controller:bar'); expectedPushURL = '/foo'; run(jQuery('#foo-link'), 'click'); @@ -3177,11 +3177,11 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bootApplication(); - var $link = jQuery('#the-link'); + let $link = jQuery('#the-link'); equal($link.attr('href'), '/example'); run($link, 'click'); - var controller = container.lookup('controller:example'); + let controller = container.lookup('controller:example'); equal(get(controller, 'foo'), undefined); }); } @@ -3219,6 +3219,6 @@ QUnit.test('handle routes names that clash with Object.prototype properties', fu run(router, 'transitionTo', 'constructor', { queryParams: { foo: '999' } }); - var controller = container.lookup('controller:constructor'); + let controller = container.lookup('controller:constructor'); equal(get(controller, 'foo'), '999'); }); diff --git a/packages/ember/tests/routing/query_params_test/model_dependent_state_with_query_params_test.js b/packages/ember/tests/routing/query_params_test/model_dependent_state_with_query_params_test.js index 98c2757cf34..840d663e780 100644 --- a/packages/ember/tests/routing/query_params_test/model_dependent_state_with_query_params_test.js +++ b/packages/ember/tests/routing/query_params_test/model_dependent_state_with_query_params_test.js @@ -11,7 +11,7 @@ import NoneLocation from 'ember-routing/location/none_location'; import { setTemplates } from 'ember-templates/template_registry'; import { classify } from 'ember-runtime/system/string'; -var App, router, registry, container; +let App, router, registry, container; function bootApplication() { router = container.lookup('router:main'); @@ -30,14 +30,14 @@ function handleURL(path) { }); } -var startingURL = ''; -var expectedReplaceURL, expectedPushURL; +let startingURL = ''; +let expectedReplaceURL, expectedPushURL; function setAndFlush(obj, prop, value) { run(obj, 'set', prop, value); } -var TestLocation = NoneLocation.extend({ +let TestLocation = NoneLocation.extend({ initState() { this.set('path', startingURL); }, @@ -210,7 +210,7 @@ function queryParamsStickyTest3(urlPrefix, articleLookup) { function queryParamsStickyTest4(urlPrefix, articleLookup) { return function() { - var articleClass = classify(articleLookup); + let articleClass = classify(articleLookup); if (isEnabled('ember-routing-route-configured-query-params')) { App[`${articleClass}Route`].reopen({ @@ -268,7 +268,7 @@ function queryParamsStickyTest5(urlPrefix, commentsLookupKey) { run(router, 'transitionTo', commentsLookupKey, 'a-1'); - var commentsCtrl = container.lookup(`controller:${commentsLookupKey}`); + let commentsCtrl = container.lookup(`controller:${commentsLookupKey}`); equal(commentsCtrl.get('page'), 1); equal(router.get('location.path'), `${urlPrefix}/a-1/comments`); @@ -290,7 +290,7 @@ function queryParamsStickyTest5(urlPrefix, commentsLookupKey) { function queryParamsStickyTest6(urlPrefix, articleLookup, commentsLookup) { return function() { - var articleClass = classify(articleLookup); + let articleClass = classify(articleLookup); App[`${articleClass}Route`].reopen({ resetController(controller, isExiting) { @@ -307,7 +307,7 @@ function queryParamsStickyTest6(urlPrefix, articleLookup, commentsLookup) { run(router, 'transitionTo', commentsLookup, 'a-1'); - var commentsCtrl = container.lookup(`controller:${commentsLookup}`); + let commentsCtrl = container.lookup(`controller:${commentsLookup}`); equal(commentsCtrl.get('page'), 1); equal(router.get('location.path'), `${urlPrefix}/a-1/comments`); @@ -342,13 +342,13 @@ QUnit.module('Model Dep Query Params', { this.route('about'); }); - var articles = this.articles = emberA([{ id: 'a-1' }, { id: 'a-2' }, { id: 'a-3' }]); + let articles = this.articles = emberA([{ id: 'a-1' }, { id: 'a-2' }, { id: 'a-3' }]); App.ApplicationController = Controller.extend({ articles: this.articles }); - var self = this; + let self = this; App.ArticleRoute = Route.extend({ model(params) { if (self.expectedModelHookParams) { @@ -433,13 +433,13 @@ QUnit.module('Model Dep Query Params (nested)', { this.route('about'); }); - var site_articles = this.site_articles = emberA([{ id: 'a-1' }, { id: 'a-2' }, { id: 'a-3' }]); + let site_articles = this.site_articles = emberA([{ id: 'a-1' }, { id: 'a-2' }, { id: 'a-3' }]); App.ApplicationController = Controller.extend({ articles: this.site_articles }); - var self = this; + let self = this; App.SiteArticleRoute = Route.extend({ model(params) { if (self.expectedModelHookParams) { @@ -522,18 +522,18 @@ QUnit.module('Model Dep Query Params (nested & more than 1 dynamic segment)', { }); }); - var sites = this.sites = emberA([{ id: 's-1' }, { id: 's-2' }, { id: 's-3' }]); - var site_articles = this.site_articles = emberA([{ id: 'a-1' }, { id: 'a-2' }, { id: 'a-3' }]); + let sites = this.sites = emberA([{ id: 's-1' }, { id: 's-2' }, { id: 's-3' }]); + let site_articles = this.site_articles = emberA([{ id: 'a-1' }, { id: 'a-2' }, { id: 'a-3' }]); App.ApplicationController = Controller.extend({ siteArticles: this.site_articles, sites: this.sites, allSitesAllArticles: computed({ - get: function() { - var ret = []; - var siteArticles = this.siteArticles; - var sites = this.sites; - sites.forEach(function(site) { + get() { + let ret = []; + let siteArticles = this.siteArticles; + let sites = this.sites; + sites.forEach(site => { ret = ret.concat(siteArticles.map((article) => { return { id: `${site.id}-${article.id}`, site_id: site.id, article_id: article.id }; })); @@ -543,7 +543,7 @@ QUnit.module('Model Dep Query Params (nested & more than 1 dynamic segment)', { }) }); - var self = this; + let self = this; App.SiteRoute = Route.extend({ model(params) { if (self.expectedSiteModelHookParams) { diff --git a/packages/ember/tests/routing/query_params_test/overlapping_query_params_test.js b/packages/ember/tests/routing/query_params_test/overlapping_query_params_test.js index 692243667db..597ffe1636a 100644 --- a/packages/ember/tests/routing/query_params_test/overlapping_query_params_test.js +++ b/packages/ember/tests/routing/query_params_test/overlapping_query_params_test.js @@ -8,21 +8,21 @@ import Application from 'ember-application/system/application'; import NoneLocation from 'ember-routing/location/none_location'; import { setTemplates, set as setTemplate } from 'ember-templates/template_registry'; -var App, router, registry, container; +let App, router, registry, container; function bootApplication() { router = container.lookup('router:main'); run(App, 'advanceReadiness'); } -var startingURL = ''; -var expectedReplaceURL, expectedPushURL; +let startingURL = ''; +let expectedReplaceURL, expectedPushURL; function setAndFlush(obj, prop, value) { run(obj, 'set', prop, value); } -var TestLocation = NoneLocation.extend({ +const TestLocation = NoneLocation.extend({ initState() { this.set('path', startingURL); }, @@ -51,7 +51,7 @@ var TestLocation = NoneLocation.extend({ }); function sharedSetup() { - run(function() { + run(() => { App = Application.create({ name: 'App', rootElement: '#qunit-fixture' @@ -79,7 +79,7 @@ function sharedSetup() { } function sharedTeardown() { - run(function() { + run(() => { App.destroy(); App = null; @@ -133,8 +133,8 @@ if (isEnabled('ember-routing-route-configured-query-params')) { equal(router.get('location.path'), '/parent/child'); - var parentController = container.lookup('controller:parent'); - var parentChildController = container.lookup('controller:parent.child'); + let parentController = container.lookup('controller:parent'); + let parentChildController = container.lookup('controller:parent.child'); setAndFlush(parentController, 'page', 2); equal(router.get('location.path'), '/parent/child?parentPage=2'); @@ -146,14 +146,14 @@ if (isEnabled('ember-routing-route-configured-query-params')) { setAndFlush(parentChildController, 'page', 1); equal(router.get('location.path'), '/parent/child'); - run(function() { + run(() => { parentController.set('page', 2); parentChildController.set('page', 2); }); equal(router.get('location.path'), '/parent/child?childPage=2&parentPage=2'); - run(function() { + run(() => { parentController.set('page', 1); parentChildController.set('page', 1); }); @@ -180,8 +180,8 @@ if (isEnabled('ember-routing-route-configured-query-params')) { } }); - var self = this; - expectAssertion(function() { + let self = this; + expectAssertion(() => { self.boot(); }, 'You\'re not allowed to have more than one controller property map to the same query param key, but both `parent:foo` and `parent.child:bar` map to `shared`. You can fix this by mapping one of the controller properties to a different query param key via the `as` config option, e.g. `foo: { as: \'other-foo\' }`'); }); @@ -222,8 +222,8 @@ if (isEnabled('ember-routing-route-configured-query-params')) { equal(router.get('location.path'), '/parent/child'); - var parentController = container.lookup('controller:parent'); - var parentChildController = container.lookup('controller:parent.child'); + let parentController = container.lookup('controller:parent'); + let parentChildController = container.lookup('controller:parent.child'); setAndFlush(parentController, 'page', 2); equal(router.get('location.path'), '/parent/child?parentPage=2'); @@ -235,14 +235,14 @@ if (isEnabled('ember-routing-route-configured-query-params')) { setAndFlush(parentChildController, 'page', 1); equal(router.get('location.path'), '/parent/child'); - run(function() { + run(() => { parentController.set('page', 2); parentChildController.set('page', 2); }); equal(router.get('location.path'), '/parent/child?childPage=2&parentPage=2'); - run(function() { + run(() => { parentController.set('page', 1); parentChildController.set('page', 1); }); @@ -261,14 +261,14 @@ if (isEnabled('ember-routing-route-configured-query-params')) { bar: 1 }); - var self = this; - expectAssertion(function() { + let self = this; + expectAssertion(() => { self.boot(); }, 'You\'re not allowed to have more than one controller property map to the same query param key, but both `parent:foo` and `parent.child:bar` map to `shared`. You can fix this by mapping one of the controller properties to a different query param key via the `as` config option, e.g. `foo: { as: \'other-foo\' }`'); }); QUnit.test('Support shared but overridable mixin pattern', function() { - var HasPage = Mixin.create({ + let HasPage = Mixin.create({ queryParams: 'page', page: 1 }); @@ -283,8 +283,8 @@ if (isEnabled('ember-routing-route-configured-query-params')) { equal(router.get('location.path'), '/parent/child'); - var parentController = container.lookup('controller:parent'); - var parentChildController = container.lookup('controller:parent.child'); + let parentController = container.lookup('controller:parent'); + let parentChildController = container.lookup('controller:parent.child'); setAndFlush(parentChildController, 'page', 2); equal(router.get('location.path'), '/parent/child?page=2'); diff --git a/packages/ember/tests/routing/query_params_test/query_params_paramless_link_to_test.js b/packages/ember/tests/routing/query_params_test/query_params_paramless_link_to_test.js index 8a39cb62a22..9626eace60c 100644 --- a/packages/ember/tests/routing/query_params_test/query_params_paramless_link_to_test.js +++ b/packages/ember/tests/routing/query_params_test/query_params_paramless_link_to_test.js @@ -9,11 +9,11 @@ import jQuery from 'ember-views/system/jquery'; import NoneLocation from 'ember-routing/location/none_location'; import { setTemplates, set as setTemplate } from 'ember-templates/template_registry'; -var App, container, router, registry; -var expectedReplaceURL, expectedPushURL; +let App, container, router, registry; +let expectedReplaceURL, expectedPushURL; -var TestLocation = NoneLocation.extend({ +let TestLocation = NoneLocation.extend({ initState() { this.set('path', startingURL); }, @@ -47,7 +47,7 @@ function bootApplication() { } function sharedSetup() { - run(function() { + run(() => { App = Application.create({ name: 'App', rootElement: '#qunit-fixture' @@ -75,7 +75,7 @@ function sharedSetup() { } function sharedTeardown() { - run(function() { + run(() => { App.destroy(); App = null; setTemplates({}); @@ -92,9 +92,9 @@ QUnit.module('Routing with Query Params', { } }); -var startingURL = ''; +let startingURL = ''; -var testParamlessLinks = function(routeName) { +function testParamlessLinks(routeName) { QUnit.test('param-less links in an app booted with query params in the URL don\'t reset the query params: ' + routeName, function() { expect(1); @@ -110,9 +110,9 @@ var testParamlessLinks = function(routeName) { equal(jQuery('#index-link').attr('href'), '/?foo=YEAH'); }); -}; +} -var testParamlessLinksWithRouteConfig = function(routeName) { +function testParamlessLinksWithRouteConfig(routeName) { QUnit.test('param-less links in an app booted with query params in the URL don\'t reset the query params: ' + routeName, function() { expect(1); @@ -131,7 +131,7 @@ var testParamlessLinksWithRouteConfig = function(routeName) { equal(jQuery('#index-link').attr('href'), '/?foo=YEAH'); }); -}; +} if (isEnabled('ember-routing-route-configured-query-params')) { testParamlessLinksWithRouteConfig('application'); diff --git a/packages/ember/tests/routing/router_map_test.js b/packages/ember/tests/routing/router_map_test.js index 014a4440cb9..1d0d8143a90 100644 --- a/packages/ember/tests/routing/router_map_test.js +++ b/packages/ember/tests/routing/router_map_test.js @@ -5,7 +5,7 @@ import Router from 'ember-routing/system/router'; import jQuery from 'ember-views/system/jquery'; import { setTemplates, set as setTemplate } from 'ember-templates/template_registry'; -var router, App, container; +let router, App, container; function bootApplication() { router = container.lookup('router:main'); @@ -13,7 +13,7 @@ function bootApplication() { } function handleURL(path) { - return run(function() { + return run(() => { return router.handleURL(path).then(function(value) { ok(true, 'url: `' + path + '` was handled'); return value; @@ -26,7 +26,7 @@ function handleURL(path) { QUnit.module('Router.map', { setup() { - run(function() { + run(() => { App = Application.create({ name: 'App', rootElement: '#qunit-fixture' @@ -43,7 +43,7 @@ QUnit.module('Router.map', { }, teardown() { - run(function() { + run(() => { App.destroy(); App = null; @@ -55,7 +55,7 @@ QUnit.module('Router.map', { QUnit.test('Router.map returns an Ember Router class', function () { expect(1); - var ret = App.Router.map(function() { + let ret = App.Router.map(function() { this.route('hello'); }); diff --git a/packages/ember/tests/routing/substates_test.js b/packages/ember/tests/routing/substates_test.js index 25a9f99fd17..c42beed4855 100644 --- a/packages/ember/tests/routing/substates_test.js +++ b/packages/ember/tests/routing/substates_test.js @@ -9,7 +9,7 @@ import NoneLocation from 'ember-routing/location/none_location'; import DefaultResolver from 'ember-application/system/resolver'; import { setTemplates, set as setTemplate } from 'ember-templates/template_registry'; -var Router, App, templates, router, container, counter; +let Router, App, templates, router, container, counter; function step(expectedValue, description) { equal(counter, expectedValue, 'Step ' + expectedValue + ': ' + description); @@ -17,7 +17,7 @@ function step(expectedValue, description) { } function bootApplication(startingURL) { - for (var name in templates) { + for (let name in templates) { setTemplate(name, compile(templates[name])); } @@ -79,8 +79,8 @@ QUnit.module('Loading/Error Substates', { }); QUnit.test('Slow promise from a child route of application enters nested loading state', function() { - var broModel = {}; - var broDeferred = RSVP.defer(); + let broModel = {}; + let broDeferred = RSVP.defer(); Router.map(function() { this.route('bro'); @@ -111,8 +111,8 @@ QUnit.test('Slow promise from a child route of application enters nested loading QUnit.test('Slow promises waterfall on startup', function() { expect(7); - var grandmaDeferred = RSVP.defer(); - var sallyDeferred = RSVP.defer(); + let grandmaDeferred = RSVP.defer(); + let sallyDeferred = RSVP.defer(); Router.map(function() { this.route('grandma', function() { @@ -165,7 +165,7 @@ QUnit.test('Slow promises waterfall on startup', function() { QUnit.test('ApplicationRoute#currentPath reflects loading state path', function() { expect(4); - var momDeferred = RSVP.defer(); + let momDeferred = RSVP.defer(); Router.map(function() { this.route('grandma', function() { @@ -187,7 +187,7 @@ QUnit.test('ApplicationRoute#currentPath reflects loading state path', function( equal(jQuery('#app', '#qunit-fixture').text(), 'GRANDMA GRANDMALOADING'); - var appController = container.lookup('controller:application'); + let appController = container.lookup('controller:application'); equal(appController.get('currentPath'), 'grandma.loading', 'currentPath reflects loading state'); run(momDeferred, 'resolve', {}); @@ -198,7 +198,7 @@ QUnit.test('ApplicationRoute#currentPath reflects loading state path', function( QUnit.test('Slow promises returned from ApplicationRoute#model don\'t enter LoadingRoute', function() { expect(2); - var appDeferred = RSVP.defer(); + let appDeferred = RSVP.defer(); App.ApplicationRoute = Route.extend({ model() { @@ -225,7 +225,7 @@ QUnit.test('Don\'t enter loading route unless either route or template defined', expect(2); - var indexDeferred = RSVP.defer(); + let indexDeferred = RSVP.defer(); App.ApplicationController = Controller.extend(); @@ -237,7 +237,7 @@ QUnit.test('Don\'t enter loading route unless either route or template defined', bootApplication(); - var appController = container.lookup('controller:application'); + let appController = container.lookup('controller:application'); ok(appController.get('currentPath') !== 'loading', 'loading state not entered'); run(indexDeferred, 'resolve', {}); @@ -249,7 +249,7 @@ QUnit.test('Enter loading route if only LoadingRoute defined', function() { expect(4); - var indexDeferred = RSVP.defer(); + let indexDeferred = RSVP.defer(); App.IndexRoute = Route.extend({ model() { @@ -266,7 +266,7 @@ QUnit.test('Enter loading route if only LoadingRoute defined', function() { bootApplication(); - var appController = container.lookup('controller:application'); + let appController = container.lookup('controller:application'); equal(appController.get('currentPath'), 'loading', 'loading state entered'); run(indexDeferred, 'resolve', {}); @@ -276,7 +276,7 @@ QUnit.test('Enter loading route if only LoadingRoute defined', function() { QUnit.test('Enter child loading state of pivot route', function() { expect(4); - var deferred = RSVP.defer(); + let deferred = RSVP.defer(); Router.map(function() { this.route('grandma', function() { @@ -305,7 +305,7 @@ QUnit.test('Enter child loading state of pivot route', function() { bootApplication('/grandma/mom/sally'); - var appController = container.lookup('controller:application'); + let appController = container.lookup('controller:application'); equal(appController.get('currentPath'), 'grandma.mom.sally', 'Initial route fully loaded'); run(router, 'transitionTo', 'grandma.smells'); @@ -321,8 +321,8 @@ QUnit.test('Loading actions bubble to root, but don\'t enter substates above piv delete templates.loading; - var sallyDeferred = RSVP.defer(); - var smellsDeferred = RSVP.defer(); + let sallyDeferred = RSVP.defer(); + let smellsDeferred = RSVP.defer(); Router.map(function() { this.route('grandma', function() { @@ -357,7 +357,7 @@ QUnit.test('Loading actions bubble to root, but don\'t enter substates above piv bootApplication('/grandma/mom/sally'); - var appController = container.lookup('controller:application'); + let appController = container.lookup('controller:application'); ok(!appController.get('currentPath'), 'Initial route fully loaded'); run(sallyDeferred, 'resolve', {}); @@ -411,7 +411,7 @@ QUnit.test('Default error event moves into nested route', function() { equal(jQuery('#app', '#qunit-fixture').text(), 'GRANDMA ERROR: did it broke?', 'error bubbles'); - var appController = container.lookup('controller:application'); + let appController = container.lookup('controller:application'); equal(appController.get('currentPath'), 'grandma.error', 'Initial route fully loaded'); }); @@ -489,7 +489,7 @@ QUnit.test('Non-bubbled errors that re-throw aren\'t swallowed', function() { QUnit.test('Handled errors that re-throw aren\'t swallowed', function() { expect(4); - var handledError; + let handledError; templates['grandma'] = 'GRANDMA {{outlet}}'; @@ -542,7 +542,7 @@ QUnit.test('Handled errors that re-throw aren\'t swallowed', function() { QUnit.test('Handled errors that bubble can be handled at a higher level', function() { expect(4); - var handledError; + let handledError; templates['grandma'] = 'GRANDMA {{outlet}}'; @@ -592,7 +592,7 @@ QUnit.test('Handled errors that bubble can be handled at a higher level', functi QUnit.test('errors that are bubbled are thrown at a higher level if not handled', function() { expect(3); - var handledError; + let handledError; templates['grandma'] = 'GRANDMA {{outlet}}'; @@ -640,7 +640,7 @@ QUnit.test('errors that are bubbled are thrown at a higher level if not handled' QUnit.test('Handled errors that are thrown through rejection aren\'t swallowed', function() { expect(4); - var handledError; + let handledError; templates['grandma'] = 'GRANDMA {{outlet}}'; @@ -691,7 +691,7 @@ QUnit.test('Handled errors that are thrown through rejection aren\'t swallowed', }); QUnit.test('Setting a query param during a slow transition should work', function() { - var deferred = RSVP.defer(); + let deferred = RSVP.defer(); Router.map(function() { this.route('grandma', { path: '/grandma/:seg' }, function() { }); @@ -721,8 +721,8 @@ QUnit.test('Setting a query param during a slow transition should work', functio bootApplication('/'); - var appController = container.lookup('controller:application'); - var grandmaController = container.lookup('controller:grandma'); + let appController = container.lookup('controller:application'); + let grandmaController = container.lookup('controller:grandma'); equal(appController.get('currentPath'), 'grandma.loading', 'Initial route should be loading'); @@ -743,7 +743,7 @@ import { test } from 'internal-test-helpers/tests/skip-if-glimmer'; test('Slow promises returned from ApplicationRoute#model enter ApplicationLoadingRoute if present', function() { expect(2); - var appDeferred = RSVP.defer(); + let appDeferred = RSVP.defer(); App.ApplicationRoute = Route.extend({ model() { @@ -751,7 +751,7 @@ test('Slow promises returned from ApplicationRoute#model enter ApplicationLoadin } }); - var loadingRouteEntered = false; + let loadingRouteEntered = false; App.ApplicationLoadingRoute = Route.extend({ setupController() { loadingRouteEntered = true; @@ -771,7 +771,7 @@ test('Slow promises returned from ApplicationRoute#model enter application_loadi templates['application_loading'] = '
TOPLEVEL LOADING
'; - var appDeferred = RSVP.defer(); + let appDeferred = RSVP.defer(); App.ApplicationRoute = Route.extend({ model() { return appDeferred.promise; @@ -829,7 +829,7 @@ QUnit.test('Default error event moves into nested route, prioritizing more speci equal(jQuery('#app', '#qunit-fixture').text(), 'GRANDMA MOM ERROR: did it broke?', 'the more specifically-named mom error substate was entered over the other error route'); - var appController = container.lookup('controller:application'); + let appController = container.lookup('controller:application'); equal(appController.get('currentPath'), 'grandma.mom_error', 'Initial route fully loaded'); }); @@ -848,7 +848,7 @@ QUnit.test('Prioritized substate entry works with preserved-namespace nested rou App.ApplicationController = Controller.extend(); - var deferred = RSVP.defer(); + let deferred = RSVP.defer(); App.FooBarRoute = Route.extend({ model() { return deferred.promise; @@ -878,7 +878,7 @@ QUnit.test('Prioritized loading substate entry works with preserved-namespace ne App.ApplicationController = Controller.extend(); - var deferred = RSVP.defer(); + let deferred = RSVP.defer(); App.FooBarRoute = Route.extend({ model() { return deferred.promise; @@ -938,7 +938,7 @@ QUnit.test('Prioritized loading substate entry works with auto-generated index r App.ApplicationController = Controller.extend(); - var deferred = RSVP.defer(); + let deferred = RSVP.defer(); App.FooIndexRoute = Route.extend({ model() { return deferred.promise; @@ -987,9 +987,8 @@ QUnit.test('Prioritized error substate entry works with auto-generated index rou } }); - throws(function() { - bootApplication('/foo'); - }, function(err) { return err.msg === 'did it broke?'; }); + throws(() => bootApplication('/foo'), + err => err.msg === 'did it broke?'); equal(jQuery('#app', '#qunit-fixture').text(), 'FOO ERROR: did it broke?', 'foo.index_error was entered'); }); @@ -999,7 +998,7 @@ test('Rejected promises returned from ApplicationRoute transition into top-level templates['application_error'] = '

TOPLEVEL ERROR: {{model.msg}}

'; - var reject = true; + let reject = true; App.ApplicationRoute = Route.extend({ model() { if (reject) { @@ -1010,9 +1009,8 @@ test('Rejected promises returned from ApplicationRoute transition into top-level } }); - throws(function() { - bootApplication(); - }, function(err) { return err.msg === 'BAD NEWS BEARS'; }); + throws(() => bootApplication(), + err => err.msg === 'BAD NEWS BEARS'); equal(jQuery('#toplevel-error', '#qunit-fixture').text(), 'TOPLEVEL ERROR: BAD NEWS BEARS'); diff --git a/packages/ember/tests/routing/toplevel_dom_test.js b/packages/ember/tests/routing/toplevel_dom_test.js index fb61dbe7f17..daa28e05f47 100644 --- a/packages/ember/tests/routing/toplevel_dom_test.js +++ b/packages/ember/tests/routing/toplevel_dom_test.js @@ -5,10 +5,10 @@ import jQuery from 'ember-views/system/jquery'; import NoneLocation from 'ember-routing/location/none_location'; import { setTemplates, set as setTemplate } from 'ember-templates/template_registry'; -var App, templates, router, container; +let App, templates, router, container; function bootApplication() { - for (var name in templates) { + for (let name in templates) { setTemplate(name, compile(templates[name])); } router = container.lookup('router:main'); @@ -17,7 +17,7 @@ function bootApplication() { QUnit.module('Top Level DOM Structure', { setup() { - run(function() { + run(() => { App = Application.create({ name: 'App', rootElement: '#qunit-fixture' @@ -38,7 +38,7 @@ QUnit.module('Top Level DOM Structure', { }, teardown() { - run(function() { + run(() => { App.destroy(); App = null; setTemplates({}); diff --git a/packages/ember/tests/view_instrumentation_test.js b/packages/ember/tests/view_instrumentation_test.js index 594c7a01af8..3aeea79b3ab 100644 --- a/packages/ember/tests/view_instrumentation_test.js +++ b/packages/ember/tests/view_instrumentation_test.js @@ -6,7 +6,7 @@ import { compile } from 'ember-template-compiler/tests/utils/helpers'; import { setTemplates, set as setTemplate } from 'ember-templates/template_registry'; import { test, testModule } from 'internal-test-helpers/tests/skip-if-glimmer'; -var App, $fixture; +let App, $fixture; function setupExample() { // setup templates @@ -20,13 +20,13 @@ function setupExample() { } function handleURL(path) { - var router = App.__container__.lookup('router:main'); + let router = App.__container__.lookup('router:main'); return run(router, 'handleURL', path); } testModule('View Instrumentation', { setup() { - run(function() { + run(() => { App = Application.create({ rootElement: '#qunit-fixture' }); @@ -50,7 +50,7 @@ testModule('View Instrumentation', { }); test('Nodes without view instances are instrumented', function(assert) { - var called = false; + let called = false; subscribe('render', { before() { called = true;