language stringclasses 1
value | owner stringlengths 2 15 | repo stringlengths 2 21 | sha stringlengths 45 45 | message stringlengths 7 36.3k | path stringlengths 1 199 | patch stringlengths 15 102k | is_multipart bool 2
classes |
|---|---|---|---|---|---|---|---|
Other | emberjs | ember.js | 606d65ab2805ef0a60f3c1e8dae0c3f6c3d802c9.json | Fix more jshint warnings | .jshintrc | @@ -21,7 +21,8 @@
"ok",
"strictEqual",
"module",
- "expect"
+ "expect",
+ "minispade"
],
"node" : false, | true |
Other | emberjs | ember.js | 606d65ab2805ef0a60f3c1e8dae0c3f6c3d802c9.json | Fix more jshint warnings | packages/ember-handlebars/lib/helpers/binding.js | @@ -12,7 +12,6 @@ var get = Ember.get, getPath = Ember.Handlebars.getPath, set = Ember.set, fmt =
var forEach = Ember.ArrayUtils.forEach;
var EmberHandlebars = Ember.Handlebars, helpers = EmberHandlebars.helpers;
-var helpers = EmberHandlebars.helpers;
(function() {
// Binds a property into the DOM. This will create a hook in DOM that the | true |
Other | emberjs | ember.js | a948bc3e29643eaf01ba4a58eb932aa5605fed37.json | Install jshint on travis | .travis.yml | @@ -3,4 +3,5 @@ rvm:
before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
+ - "npm install -g jshint"
script: "rake test[all] && rake jshint" | false |
Other | emberjs | ember.js | fb1476913e9e45634dc1d2efd9aa8cb3ae3db318.json | Check jshint on travis | .travis.yml | @@ -3,4 +3,4 @@ rvm:
before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
-script: rake test
+script: "rake test && rake jshint" | false |
Other | emberjs | ember.js | 49ef31403da93b08f88ee47f1eff3f1cd5017d5f.json | add test for issue #460 | packages/ember-metal/tests/binding/sync_test.js | @@ -130,6 +130,52 @@ testBoth("bindings should do the right thing when binding is in prototype", func
equal(get(obj, 'selection'), 'a');
});
+testBoth("binding with transform should only fire one change when set", function (get, set) {
+ var a, b, changed, transform;
+
+ Ember.run(function() {
+ a = {array: null};
+ b = {a: a};
+ changed = 0;
+
+ Ember.addObserver(a, 'array', function() {
+ changed++;
+ });
+
+ transform = {
+ to: function(array) {
+ if (array) {
+ return array.join(',');
+ } else {
+ return array;
+ }
+ },
+ from: function(string) {
+ if (string) {
+ return string.split(',');
+ } else {
+ return string;
+ }
+ }
+ };
+ Ember.Binding.from('a.array').to('string').transform(transform).connect(b);
+ });
+
+ Ember.run(function() {
+ set(a, 'array', ['a', 'b', 'c']);
+ });
+
+ equal(changed, 1);
+ equal(get(b, 'string'), 'a,b,c');
+
+ Ember.run(function() {
+ set(b, 'string', '1,2,3');
+ });
+
+ equal(changed, 2);
+ deepEqual(get(a, 'array'), ['1','2','3']);
+});
+
testBoth("bindings should not try to sync destroyed objects", function(get, set) {
var a, b;
| false |
Other | emberjs | ember.js | e35332611f8bedbb3ab2ce51c8f8969fa6547072.json | Fix merge error | packages/ember-handlebars/tests/views/collection_view_test.js | @@ -285,8 +285,8 @@ test("should give its item views the property specified by itemPropertyBinding",
equal(view.$('ul li').length, 3, "adds 3 itemView");
view.$('ul li').each(function(i, li){
- equals($(li).text(), "baz", "creates the li with the property = baz");
- })
+ equal(Ember.$(li).text(), "baz", "creates the li with the property = baz");
+ });
Ember.run(function() {
setPath(view, 'baz', "yobaz"); | false |
Other | emberjs | ember.js | 9cff1d89f610b41d1f51de49892bbbb8d8e6ae2a.json | Use rake-pipeline to build | .gitignore | @@ -26,7 +26,7 @@ spec/reports
test/tmp
test/version_tmp
test_*.html
-/tests/source
+/tests/ember-tests.js
tmp
tmp*.gem
tmp.bpm | true |
Other | emberjs | ember.js | 9cff1d89f610b41d1f51de49892bbbb8d8e6ae2a.json | Use rake-pipeline to build | Assetfile | @@ -1,37 +1,54 @@
require "rake-pipeline-web-filters"
require "json"
+require "uglifier"
+require "./neuter"
-output "tests/source"
+output "tests"
input "packages" do
- match "*/{lib,tests}/**/*.js" do
+ match "*/tests/**/*.js" do
minispade :rewrite_requires => true, :string => true, :module_id_generator => proc { |input|
id = input.path.dup
- id.sub!('/lib/', '/')
id.sub!(/\.js$/, '')
id.sub!(/\/main$/, '')
id.sub!('/tests', '/~tests')
id
}
- concat do |filename|
- filename =~ %r{/tests/} ? "ember-tests.js" : "ember.js"
- end
+ concat "ember-tests.js"
end
+end
+
+output "dist"
+
+input "packages" do
+ match "*/lib/**/*.js" do
+ minispade :rewrite_requires => true, :string => true, :module_id_generator => proc { |input|
+ id = input.path.dup
+ id.sub!('/lib/', '/')
+ id.sub!(/\.js$/, '')
+ id.sub!(/\/main$/, '')
+ id
+ }
- # Hack to ignore certain files
- match "**/*.{json,md}" do
- concat "trash"
+ concat "ember.spade.js"
end
+end
- match "**/README" do
- concat "trash"
+input "packages" do
+ match "*/lib/**/main.js" do
+ neuter do |filename|
+ File.join("modules/", filename.gsub('/lib/main.js', '.js'))
+ end
end
- match "*/*.js" do
- concat "trash"
+ match "modules/*.js" do
+ concat ["modules/ember-debug.js", "modules/handlebars.js", "modules/ember-metal.js", "modules/ember-runtime.js", "modules/ember-views.js", "modules/ember-states.js", "modules/metamorph.js", "modules/ember-handlebars.js"], "ember.js"
end
end
-
-# vim: filetype=ruby
+input "dist" do
+ match "ember.js" do
+ uglify
+ end
+end
\ No newline at end of file | true |
Other | emberjs | ember.js | 9cff1d89f610b41d1f51de49892bbbb8d8e6ae2a.json | Use rake-pipeline to build | Gemfile | @@ -1,6 +1,5 @@
source "http://rubygems.org"
-gem "sproutcore", :git => "https://github.com/wycats/abbot-from-scratch.git"
gem "uglifier", "~> 1.0.3"
gem "execjs", "~> 1.2.6"
gem "rack" | true |
Other | emberjs | ember.js | 9cff1d89f610b41d1f51de49892bbbb8d8e6ae2a.json | Use rake-pipeline to build | Gemfile.lock | @@ -14,12 +14,6 @@ GIT
rack
thor
-GIT
- remote: https://github.com/wycats/abbot-from-scratch.git
- revision: 47662bbbb25afc213318051676cd31375d1d1f59
- specs:
- sproutcore (0.0.1)
-
GIT
remote: https://github.com/wycats/rake-pipeline-web-filters.git
revision: fe752a8cfdbb318b746fd76fd3c10dd8b8f29891
@@ -66,5 +60,4 @@ DEPENDENCIES
rack
rake-pipeline!
rake-pipeline-web-filters!
- sproutcore!
uglifier (~> 1.0.3) | true |
Other | emberjs | ember.js | 9cff1d89f610b41d1f51de49892bbbb8d8e6ae2a.json | Use rake-pipeline to build | Rakefile | @@ -5,7 +5,7 @@ require "net/github-upload"
require "bundler/setup"
require "erb"
-require "uglifier"
+require 'rake-pipeline'
require "ember_docs/cli"
desc "Strip trailing whitespace for JavaScript files in packages"
@@ -18,134 +18,22 @@ task :strip_whitespace do
end
end
-# for now, the SproutCore compiler will be used to compile Ember.js
-require "sproutcore"
-
LICENSE = File.read("generators/license.js")
-## Some Ember modules expect an exports object to exist. Mock it out.
-
-module SproutCore
- module Compiler
- class Entry
- def body
- "\n(function(exports) {\n#{@raw_body}\n})({});\n"
- end
- end
+desc "Build ember.js"
+task :dist => :clean do
+ Rake::Pipeline::Project.new("Assetfile").invoke
+ minified = File.read("dist/ember.min.js")
+ File.open("dist/ember.min.js", "w") do |file|
+ file.write "#{LICENSE} #{minified}"
end
end
-## HELPERS ##
-
-def strip_require(file)
- result = File.read(file)
- result.gsub!(%r{^\s*require\(['"]([^'"])*['"]\);?\s*}, "")
- result
-end
-
-def strip_dev_code(file)
- result = File.read(file)
- result.gsub!(%r{^(\s)+ember_(assert|deprecate|warn)\((.*)\).*$}, "")
- result
-end
-
-def uglify(file)
- uglified = Uglifier.compile(File.read(file))
- "#{LICENSE}\n#{uglified}"
-end
-
-# Set up the intermediate and output directories for the interim build process
-
-SproutCore::Compiler.intermediate = "tmp/intermediate"
-SproutCore::Compiler.output = "tmp/static"
-
-# Create a compile task for an Ember package. This task will compute
-# dependencies and output a single JS file for a package.
-def compile_package_task(input, output=input)
- js_tasks = SproutCore::Compiler::Preprocessors::JavaScriptTask.with_input "packages/#{input}/lib/**/*.js", "."
- SproutCore::Compiler::CombineTask.with_tasks js_tasks, "#{SproutCore::Compiler.intermediate}/#{output}"
-end
-
-## TASKS ##
-
-# Create ember:package tasks for each of the Ember packages
-namespace :ember do
- %w(metal debug runtime handlebars views states datetime).each do |package|
- task package => compile_package_task("ember-#{package}", "ember-#{package}")
- end
-end
-
-# Create a handlebars task
-task :handlebars => compile_package_task("handlebars")
-
-# Create a metamorph task
-task :metamorph => compile_package_task("metamorph")
-
-# Create a build task that depends on all of the package dependencies
-task :build => ["ember:debug", "ember:metal", "ember:runtime", "ember:handlebars", "ember:views", "ember:states", "ember:datetime", :handlebars, :metamorph]
-
-distributions = {
- "ember" => ["handlebars", "ember-metal", "ember-runtime", "ember-views", "ember-states", "metamorph", "ember-handlebars"],
- "ember-runtime" => ["ember-metal", "ember-runtime"]
-}
-
-distributions.each do |name, libraries|
- # Strip out require lines. For the interim, requires are
- # precomputed by the compiler so they are no longer necessary at runtime.
- file "tmp/dist/#{name}.js" => :build do
- mkdir_p "tmp/dist", :verbose => false
- File.open("tmp/dist/#{name}.js", "w") do |file|
- libraries.each do |library|
- file.puts strip_require("tmp/static/#{library}.js")
- end
- end
- end
-
- file "dist/#{name}.js" => "tmp/dist/#{name}.js" do
- puts "Generating #{name}.js... "
- mkdir_p "dist", :verbose => false
- File.open("dist/#{name}.js", "w") do |file|
- file.puts strip_require("tmp/static/ember-debug.js")
- file.puts File.read("tmp/dist/#{name}.js")
- end
- end
-
- # Minified distribution
- file "dist/#{name}.min.js" => "tmp/dist/#{name}.js" do
- require 'zlib'
-
- print "Generating #{name}.min.js... "
- STDOUT.flush
-
- mkdir_p "dist", :verbose => false
- File.open("dist/#{name}.prod.js", "w") do |file|
- file.puts strip_dev_code("tmp/dist/#{name}.js")
- end
-
- minified_code = uglify("dist/#{name}.prod.js")
- File.open("dist/#{name}.min.js", "w") do |file|
- file.puts minified_code
- end
-
- gzipped_kb = Zlib::Deflate.deflate(minified_code).bytes.count / 1024
-
- puts "#{gzipped_kb} KB gzipped"
-
- rm "dist/#{name}.prod.js", :verbose => false
- end
-end
-
-
-desc "Build Ember.js"
-task :dist => distributions.keys.map{|name| ["dist/#{name}.js", "dist/#{name}.min.js"] }.flatten
-
desc "Clean build artifacts from previous builds"
task :clean do
- sh "rm -rf tmp && rm -rf dist"
+ sh "rm -rf tmp dist tests/ember-tests.js"
end
-
-
### UPLOAD LATEST EMBERJS BUILD TASK ###
desc "Upload latest Ember.js build to GitHub repository"
task :upload => :dist do | true |
Other | emberjs | ember.js | 9cff1d89f610b41d1f51de49892bbbb8d8e6ae2a.json | Use rake-pipeline to build | config.ru | @@ -1,3 +1,9 @@
+begin
+ require 'bundler'
+ Bundler.setup :default
+rescue LoadError
+end
+
require 'rake-pipeline'
require 'rake-pipeline/middleware'
| true |
Other | emberjs | ember.js | 9cff1d89f610b41d1f51de49892bbbb8d8e6ae2a.json | Use rake-pipeline to build | neuter.rb | @@ -0,0 +1,114 @@
+require 'rake-pipeline'
+
+module Neuter
+
+ DEBUG = false
+
+ class SpadeWrapper < Rake::Pipeline::FileWrapper
+
+ REQUIRE_RE = %r{^\s*require\(['"]([^'"]*)['"]\);?\s*}
+
+ # Keep track of required files
+ @@required = []
+
+ # Yes, it's called package because module is a reserved word
+ def package
+ @package ||= path.split('/lib/')[0].split('/').last.split('.js').last
+ end
+
+ def read
+ source = super
+
+ # bail if this class is used for an intermediate file (it is!)
+ return source if !path.include?("/lib/")
+
+ # Replace all requires with emptiness, and accumulate dependency sources
+ prepend = ''
+ source.gsub! REQUIRE_RE do |m|
+
+ req = $1
+
+ # Find a reason to fail
+ reason = @@required.include?(req) ? 'Already required' : false
+ reason ||= is_package_req(req) ? 'Required package' : false
+ reason ||= is_external_req(package, req) ? "External package for #{package}" : false
+
+ if reason
+ p "Skipped #{req} required in #{path} (#{reason})" if DEBUG
+ else
+ @@required << req
+ req_file = File.join(package, "lib", "#{req.gsub(package, '')}.js")
+ prepend = prepend + self.class.new(root, req_file, encoding).read
+ p "Required #{req_file} as #{req} in #{path} in package #{package}" if DEBUG
+ end
+ ''
+ end
+
+ source = "(function(exports) {\n#{source}\n})({});\n\n"
+ "#{prepend}#{source}"
+ end
+
+ protected
+
+ def is_package_req(req)
+ !(req.include? '/')
+ end
+
+ def is_external_req(package, req)
+ !(req.split('/')[0] == package)
+ end
+ end
+
+ module Filters
+
+ class NeuterFilter < Rake::Pipeline::ConcatFilter
+
+ # Allows selective concat by passing packages array (or all if nil)
+ def initialize(packages=nil, string=nil, &block)
+ @packages = packages
+ @file_wrapper_class = SpadeWrapper
+ super(string, &block)
+ end
+
+ def generate_output(inputs, output)
+ inputs.each do |input|
+ if !(@packages.nil? || @packages.include?(input.path.split('/').first))
+ p "Not neutering: #{input.path}" if DEBUG
+ next
+ end
+ spade = SpadeWrapper.new(input.root, input.path, input.encoding)
+ p "Neutering #{input.path} into #{output.path}" if DEBUG
+ output.write spade.read
+ end
+ end
+ end
+
+ class SelectFilter < Rake::Pipeline::ConcatFilter
+
+ # Allows selective concat by passing packages array (or all if nil)
+ def initialize(packages=nil, string=nil, &block)
+ @packages = packages || []
+ super(string, &block)
+ end
+
+ def generate_output(inputs, output)
+ inputs.each do |input|
+ next unless @packages.include?(input.path)
+ output.write input.read
+ end
+ end
+ end
+ end
+
+ module Helpers
+ def neuter(*args, &block)
+ filter(Neuter::Filters::NeuterFilter, *args, &block)
+ end
+
+ def select(*args, &block)
+ filter(Neuter::Filters::SelectFilter, *args, &block)
+ end
+ end
+end
+
+Rake::Pipeline::DSL::PipelineDSL.send(:include, Neuter::Helpers)
\ No newline at end of file | true |
Other | emberjs | ember.js | 9cff1d89f610b41d1f51de49892bbbb8d8e6ae2a.json | Use rake-pipeline to build | tests/index.html | @@ -32,18 +32,27 @@ <h2 id="qunit-userAgent"></h2>
}
</script>
- <script type="text/javascript" src="minispade.js"></script>
- <script type="text/javascript" src="source/ember.js"></script>
- <script type="text/javascript" src="source/ember-tests.js"></script>
-
<script type="text/javascript">
// Handle extending prototypes
QUnit.config.urlConfig.push('extendprototypes');
window.ENV = window.ENV || {};
var extendPrototypes = location.search.match(/extendprototypes=([^&]+)/);
ENV['EXTEND_PROTOTYPES'] = !!(extendPrototypes && decodeURIComponent(extendPrototypes[1]));
+ </script>
+ <script type="text/javascript" src="minispade.js"></script>
+
+ <script>
+ // Load ember distribution from query vars
+ var distMatch = location.search.match(/dist=([^&]+)/),
+ dist = distMatch ? (distMatch[1] + ".") : "";
+ document.write(unescape('%3Cscript src="../dist/ember.'+dist+'js"%3E%3C/script%3E'));
+ </script>
+
+ <script type="text/javascript" src="ember-tests.js"></script>
+
+ <script>
// hack qunit to not suck for Ember objects
var originalTypeof = QUnit.jsDump.typeOf;
@@ -84,14 +93,33 @@ <h2 id="qunit-userAgent"></h2>
len = packages.length;
// There is no require for this in the code
- minispade.require('handlebars');
- minispade.require('ember-debug');
+ if (dist == 'spade.') {
+ minispade.require('handlebars');
+ minispade.require('ember-debug');
+ } else {
+ reqs = [
+ 'ember-runtime/system/native_array',
+ 'ember-runtime/system/object',
+ 'ember-runtime/mixins/comparable',
+ 'ember-states/state_manager',
+ 'ember-states/state',
+ 'ember-states/view_state',
+ 'ember-views/views/view'
+ ]
+ jQuery.each(reqs, function(i, e) {
+ minispade.loaded[e] = true;
+ });
+ }
for (idx=0; idx<len; idx++) {
packageName = packages[idx];
re = new RegExp('^'+packageName+'/([^/]+)');
- minispade.require(packageName);
+ if (dist == 'spade.') {
+ minispade.require(packageName);
+ } else {
+ minispade.loaded[packageName] = true;
+ }
for (moduleName in minispade.modules) {
if (!minispade.modules.hasOwnProperty(moduleName)) { continue; } | true |
Other | emberjs | ember.js | 7f21439ec0f765ee0b8186fb347c0a569cc1656d.json | Fix some jshint errors | .jshintrc | @@ -13,13 +13,15 @@
"equal",
"test",
"testBoth",
+ "testWithDefault",
"raises",
"deepEqual",
"start",
"stop",
"ok",
"strictEqual",
- "module"
+ "module",
+ "expect"
],
"node" : false, | true |
Other | emberjs | ember.js | 7f21439ec0f765ee0b8186fb347c0a569cc1656d.json | Fix some jshint errors | packages/ember-handlebars/lib/controls/select.js | @@ -1,3 +1,5 @@
+/*jshint eqeqeq:false */
+
var set = Ember.set, get = Ember.get, getPath = Ember.getPath;
var indexOf = Ember.ArrayUtils.indexOf;
| true |
Other | emberjs | ember.js | 7f21439ec0f765ee0b8186fb347c0a569cc1656d.json | Fix some jshint errors | packages/ember-handlebars/lib/views/metamorph_view.js | @@ -24,7 +24,7 @@ var DOMManager = {
nextView._insertElementLater(function() {
var morph = view.morph;
morph.after(nextView.outerHTML);
- nextView,outerHTML = null;
+ nextView.outerHTML = null;
});
},
| true |
Other | emberjs | ember.js | 7f21439ec0f765ee0b8186fb347c0a569cc1656d.json | Fix some jshint errors | packages/ember-metal/lib/array.js | @@ -83,7 +83,7 @@ Ember.ArrayUtils = {
var args = Array.prototype.slice.call(arguments, 1);
return obj.indexOf ? obj.indexOf.apply(obj, args) : arrayIndexOf.apply(obj, args);
}
-}
+};
if (Ember.SHIM_ES5) { | true |
Other | emberjs | ember.js | 7f21439ec0f765ee0b8186fb347c0a569cc1656d.json | Fix some jshint errors | packages/ember-metal/tests/accessors/get_test.js | @@ -94,7 +94,7 @@ test('should get arbitrary properties on an object', function() {
obj = {
undef: undefined
- }
+ };
equal(Ember.getWithDefault(obj, "undef", "default"), "default", "explicit undefined retrieves the default");
equal(Ember.getWithDefault(obj, "not-present", "default"), "default", "non-present key retrieves the default");
@@ -119,7 +119,7 @@ testBoth("if unknownProperty is present, it is called", function(get, set) {
var obj = {
count: 0,
unknownProperty: function(key) {
- if (key == "foo") {
+ if (key === "foo") {
equal(key, 'foo', "should pass key");
this.count++;
return "FOO"; | true |
Other | emberjs | ember.js | 7f21439ec0f765ee0b8186fb347c0a569cc1656d.json | Fix some jshint errors | packages/ember-runtime/tests/system/object/computed_test.js | @@ -3,7 +3,6 @@
// Copyright: ©2011 Strobe Inc. and contributors.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
-/*globals testBoth */
require('ember-runtime/~tests/props_helper');
| true |
Other | emberjs | ember.js | 7f21439ec0f765ee0b8186fb347c0a569cc1656d.json | Fix some jshint errors | packages/ember-states/tests/state_manager_test.js | @@ -345,7 +345,7 @@ test("it sends exit events in the correct order when changing to a state multipl
stateManager.goToState('start.outer.inner');
stateManager.goToState('start');
stateManager.goToState('start.outer.inner');
- exitOrder = []
+ exitOrder = [];
stateManager.goToState('start');
equal(exitOrder.length, 2, "precond - it calls both exits");
equal(exitOrder[0], 'exitedInner', "inner exit is called first"); | true |
Other | emberjs | ember.js | 7f21439ec0f765ee0b8186fb347c0a569cc1656d.json | Fix some jshint errors | packages/ember-views/lib/core.js | @@ -5,5 +5,5 @@
// License: Licensed under MIT license (see license.js)
// ==========================================================================
-ember_assert("Ember requires jQuery 1.6 or 1.7", window.jQuery && jQuery().jquery.match(/^1\.[67](.\d+)?$/));
+ember_assert("Ember requires jQuery 1.6 or 1.7", window.jQuery && window.jQuery().jquery.match(/^1\.[67](.\d+)?$/));
Ember.$ = window.jQuery; | true |
Other | emberjs | ember.js | 7f21439ec0f765ee0b8186fb347c0a569cc1656d.json | Fix some jshint errors | packages/ember-views/lib/system/event_dispatcher.js | @@ -133,7 +133,7 @@ Ember.EventDispatcher = Ember.Object.extend(
});
rootElement.delegate('[data-ember-action]', event + '.ember', function(evt) {
- var actionId = $(evt.currentTarget).attr('data-ember-action'),
+ var actionId = Ember.$(evt.currentTarget).attr('data-ember-action'),
action = Ember.Handlebars.ActionHelper.registeredActions[actionId],
handler = action.handler;
| true |
Other | emberjs | ember.js | 7f21439ec0f765ee0b8186fb347c0a569cc1656d.json | Fix some jshint errors | packages/ember-views/lib/system/render_buffer.js | @@ -25,7 +25,7 @@ ClassSet.prototype = {
toDOM: function() {
return this.list.join(" ");
}
-}
+};
/**
@class
@@ -43,7 +43,7 @@ Ember.RenderBuffer = function(tagName) {
Ember._RenderBuffer = function(tagName) {
this.elementTag = tagName;
this.childBuffers = [];
-}
+};
Ember._RenderBuffer.prototype =
/** @scope Ember.RenderBuffer.prototype */ {
@@ -138,7 +138,7 @@ Ember._RenderBuffer.prototype =
*/
addClass: function(className) {
// lazily create elementClasses
- var elementClasses = this.elementClasses = (this.elementClasses || new ClassSet())
+ var elementClasses = this.elementClasses = (this.elementClasses || new ClassSet());
this.elementClasses.add(className);
return this; | true |
Other | emberjs | ember.js | 7f21439ec0f765ee0b8186fb347c0a569cc1656d.json | Fix some jshint errors | packages/ember-views/lib/views/view.js | @@ -346,7 +346,7 @@ Ember.View = Ember.Object.extend(Ember.Evented,
// try to find the function for the state in the cache
if (fn = invokeForState[stateName][name]) {
- args = a_slice.call(arguments)
+ args = a_slice.call(arguments);
args[0] = this;
return fn.apply(this, args);
@@ -1426,7 +1426,7 @@ Ember.View = Ember.Object.extend(Ember.Evented,
// are done on the DOM element.
/** @private */
-DOMManager = {
+var DOMManager = {
prepend: function(view, childView) {
childView._insertElementLater(function() {
var element = view.$(); | true |
Other | emberjs | ember.js | 7f21439ec0f765ee0b8186fb347c0a569cc1656d.json | Fix some jshint errors | packages/ember-views/tests/views/view/element_test.js | @@ -69,7 +69,7 @@ test("discovers element if has no element but parent view does have element", fu
});
test("should not allow the elementId to be changed", function() {
- view = Ember.View.create({
+ var view = Ember.View.create({
elementId: 'one'
});
| true |
Other | emberjs | ember.js | c7925ed13317be0df893094db2c7a56db01d47b9.json | Upgrade QUnit and fix warnings/errors | packages/ember-handlebars/tests/handlebars_test.js | @@ -1542,6 +1542,8 @@ test("bindings can be 'this', in which case they *are* the current context", fun
// https://github.com/emberjs/ember.js/issues/120
test("should not enter an infinite loop when binding an attribute in Handlebars", function() {
+ expect(0);
+
App = Ember.Application.create();
App.test = Ember.Object.create({ href: 'test' });
App.Link = Ember.View.extend({ | true |
Other | emberjs | ember.js | c7925ed13317be0df893094db2c7a56db01d47b9.json | Upgrade QUnit and fix warnings/errors | packages/ember-handlebars/tests/views/collection_view_test.js | @@ -115,7 +115,7 @@ test("collection helper should accept emptyViewClass attribute", function() {
view.appendTo('#qunit-fixture');
});
- equals(view.$('tr').length, 0, 'emptyViewClass has no effect without inverse');
+ equal(view.$('tr').length, 0, 'emptyViewClass has no effect without inverse');
view.remove();
view = Ember.View.create({
@@ -126,7 +126,7 @@ test("collection helper should accept emptyViewClass attribute", function() {
view.appendTo('#qunit-fixture');
});
- equals(view.$('tr').hasClass('empty'), 1, 'if emptyViewClass is given it is used for inverse');
+ equal(view.$('tr').hasClass('empty'), 1, 'if emptyViewClass is given it is used for inverse');
Ember.run(function(){ window.App.destroy(); });
});
@@ -282,18 +282,17 @@ test("should give its item views the property specified by itemPropertyBinding",
view.appendTo('#qunit-fixture');
});
- equals(view.$('ul li').length, 3, "adds 3 itemView");
+ equal(view.$('ul li').length, 3, "adds 3 itemView");
view.$('ul li').each(function(i, li){
- console.log( li)
- equals($(li).text(), "baz", "creates the li with the property = baz");
- })
+ equal(Ember.$(li).text(), "baz", "creates the li with the property = baz");
+ });
Ember.run(function() {
setPath(view, 'baz', "yobaz");
});
- equals(view.$('ul li:first').text(), "yobaz", "change property of sub view");
+ equal(view.$('ul li:first').text(), "yobaz", "change property of sub view");
});
test("should work inside a bound {{#if}}", function() { | true |
Other | emberjs | ember.js | c7925ed13317be0df893094db2c7a56db01d47b9.json | Upgrade QUnit and fix warnings/errors | packages/ember-metal/tests/accessors/setPath_test.js | @@ -133,7 +133,7 @@ test('[obj, foo.baz.bat] -> EXCEPTION', function() {
test('[obj, foo.baz.bat] -> EXCEPTION', function() {
Ember.trySetPath(obj, 'foo.baz.bat', "BAM");
- // does not raise
+ ok(true, "does not raise");
});
test('[obj, Foo.bar] -> Foo.bar', function() { | true |
Other | emberjs | ember.js | c7925ed13317be0df893094db2c7a56db01d47b9.json | Upgrade QUnit and fix warnings/errors | packages/ember-metal/tests/binding/sync_test.js | @@ -103,7 +103,7 @@ testBoth("bindings should not try to sync destroyed objects", function(get, set)
Ember.run(function() {
set(a, 'foo', 'trollface');
set(b, 'isDestroyed', true);
- // should not raise
+ ok(true, "should not raise");
});
Ember.run(function() {
@@ -120,6 +120,6 @@ testBoth("bindings should not try to sync destroyed objects", function(get, set)
Ember.run(function() {
set(b, 'foo', 'trollface');
set(a, 'isDestroyed', true);
- // should not raise
+ ok(true, "should not raise");
});
}); | true |
Other | emberjs | ember.js | c7925ed13317be0df893094db2c7a56db01d47b9.json | Upgrade QUnit and fix warnings/errors | packages/ember-metal/tests/mixin/required_test.js | @@ -56,6 +56,7 @@ test('combined mixins to meet requirement', function() {
test('merged mixin', function() {
Ember.Mixin.create(PartialMixin, { foo: 'FOO' }).apply(obj);
+ equal(Ember.get(obj, 'foo'), 'FOO', 'should now be defined');
});
test('define property on source object', function() { | true |
Other | emberjs | ember.js | c7925ed13317be0df893094db2c7a56db01d47b9.json | Upgrade QUnit and fix warnings/errors | packages/ember-metal/tests/utils/meta_test.js | @@ -4,6 +4,8 @@
// License: Licensed under MIT license (see license.js)
// ==========================================================================
+/*global jQuery*/
+
module("Ember.meta");
test("should return the same hash for an object", function() {
@@ -58,6 +60,6 @@ if (window.jQuery) {
jQuery.extend(true, result, { arr: array });
- equals(result.arr.length, 3);
+ equal(result.arr.length, 3);
});
} | true |
Other | emberjs | ember.js | c7925ed13317be0df893094db2c7a56db01d47b9.json | Upgrade QUnit and fix warnings/errors | packages/ember-runtime/tests/suites/enumerable/forEach.js | @@ -21,7 +21,10 @@ suite.test('forEach should iterate over list', function() {
suite.test('forEach should iterate over list after mutation', function() {
- if (Ember.get(this, 'canTestMutation')) return ;
+ if (Ember.get(this, 'canTestMutation')) {
+ expect(0);
+ return ;
+ }
var obj = this.newObject(),
ary = this.toArray(obj), | true |
Other | emberjs | ember.js | c7925ed13317be0df893094db2c7a56db01d47b9.json | Upgrade QUnit and fix warnings/errors | packages/ember-runtime/tests/suites/enumerable/map.js | @@ -23,7 +23,10 @@ suite.test('map should iterate over list', function() {
suite.test('map should iterate over list after mutation', function() {
- if (Ember.get(this, 'canTestMutation')) return ;
+ if (Ember.get(this, 'canTestMutation')) {
+ expect(0);
+ return ;
+ }
var obj = this.newObject(),
ary = this.toArray(obj).map(mapFunc), | true |
Other | emberjs | ember.js | c7925ed13317be0df893094db2c7a56db01d47b9.json | Upgrade QUnit and fix warnings/errors | packages/ember-runtime/tests/system/object/destroy_test.js | @@ -34,5 +34,7 @@ test("should raise an exception when modifying watched properties on a destroyed
raises(function() {
Ember.set(obj, 'foo', 'baz');
}, Error, "raises an exception");
+ } else {
+ expect(0);
}
}); | true |
Other | emberjs | ember.js | c7925ed13317be0df893094db2c7a56db01d47b9.json | Upgrade QUnit and fix warnings/errors | packages/ember-runtime/tests/system/string/dasherize.js | @@ -35,12 +35,20 @@ test("dasherize camelcased string", function() {
}
});
-test("after call with the same passed value take object from cashe", function() {
+test("after call with the same passed value take object from cache", function() {
var res = Ember.String.dasherize('innerHTML');
+
+ var callCount = 0;
var decamelize = Ember.String.decamelize;
- Ember.String.decamelize = function() {
- throw "Ember.String.decamelize has been called.";
- };
- Ember.String.dasherize('innerHTML');
- Ember.String.decamelize = decamelize;
+
+ try {
+ Ember.String.decamelize = function() {
+ callCount++;
+ };
+ Ember.String.dasherize('innerHTML');
+ } finally {
+ Ember.String.decamelize = decamelize;
+ }
+
+ equal(callCount, 0, "decamelize is not called again");
}); | true |
Other | emberjs | ember.js | c7925ed13317be0df893094db2c7a56db01d47b9.json | Upgrade QUnit and fix warnings/errors | packages/ember-states/tests/state_manager_test.js | @@ -463,9 +463,9 @@ test("goToState triggers all enter states", function() {
test("goToState with current state does not trigger enter or exit", function() {
stateManager.goToState('grandparent.parent.child');
stateManager.goToState('grandparent.parent.child');
- equals(stateManager.grandparent.entered, 1, "the top level should only be entered once");
- equals(stateManager.grandparent.parent.entered, 1, "intermediate states should only be entered once");
- equals(stateManager.grandparent.parent.child.entered, 1, "the final state should only be entered once");
- equals(stateManager.grandparent.parent.child.exited, 0, "the final state should not be exited");
+ equal(stateManager.grandparent.entered, 1, "the top level should only be entered once");
+ equal(stateManager.grandparent.parent.entered, 1, "intermediate states should only be entered once");
+ equal(stateManager.grandparent.parent.child.entered, 1, "the final state should only be entered once");
+ equal(stateManager.grandparent.parent.child.exited, 0, "the final state should not be exited");
});
| true |
Other | emberjs | ember.js | c7925ed13317be0df893094db2c7a56db01d47b9.json | Upgrade QUnit and fix warnings/errors | packages/ember-views/tests/system/application_test.js | @@ -23,6 +23,7 @@ module("Ember.Application", {
test("you can make a new application in a non-overlapping element", function() {
var app = Ember.Application.create({ rootElement: '#two' });
app.destroy();
+ ok(true, "should not raise");
});
test("you cannot make a new application that is a parent of an existing application", function() { | true |
Other | emberjs | ember.js | c7925ed13317be0df893094db2c7a56db01d47b9.json | Upgrade QUnit and fix warnings/errors | packages/ember-views/tests/views/view/attribute_bindings_test.js | @@ -37,7 +37,7 @@ test("should render attribute bindings", function() {
view.createElement();
- equals(view.$().attr('type'), 'submit', "updates type attribute");
+ equal(view.$().attr('type'), 'submit', "updates type attribute");
ok(view.$().attr('disabled'), "supports customizing attribute name for Boolean values");
ok(!view.$().attr('exploded'), "removes exploded attribute when false");
ok(!view.$().attr('destroyed'), "removes destroyed attribute when false");
@@ -65,7 +65,7 @@ test("should update attribute bindings", function() {
view.createElement();
- equals(view.$().attr('type'), 'reset', "adds type attribute");
+ equal(view.$().attr('type'), 'reset', "adds type attribute");
ok(view.$().attr('disabled'), "adds disabled attribute when true");
ok(view.$().attr('exploded'), "adds exploded attribute when true");
ok(view.$().attr('destroyed'), "adds destroyed attribute when true");
@@ -84,7 +84,7 @@ test("should update attribute bindings", function() {
view.set('notDefined', undefined);
view.set('notNumber', NaN);
- equals(view.$().attr('type'), 'submit', "updates type attribute");
+ equal(view.$().attr('type'), 'submit', "updates type attribute");
ok(!view.$().attr('disabled'), "removes disabled attribute when false");
ok(!view.$().attr('exploded'), "removes exploded attribute when false");
ok(!view.$().attr('destroyed'), "removes destroyed attribute when false"); | true |
Other | emberjs | ember.js | c7925ed13317be0df893094db2c7a56db01d47b9.json | Upgrade QUnit and fix warnings/errors | tests/qunit/qunit.css | @@ -1,13 +1,11 @@
/**
- * QUnit v1.3.0pre - A JavaScript Unit Testing Framework
+ * QUnit v1.4.0pre - A JavaScript Unit Testing Framework
*
* http://docs.jquery.com/QUnit
*
- * Copyright (c) 2011 John Resig, Jörn Zaefferer
+ * Copyright (c) 2012 John Resig, Jörn Zaefferer
* Dual licensed under the MIT (MIT-LICENSE.txt)
* or GPL (GPL-LICENSE.txt) licenses.
- * Pulled Live from Git Fri Dec 9 20:50:01 UTC 2011
- * Last Commit: 0712230bb203c262211649b32bd712ec7df5f857
*/
/** Font Family and Sizes */
@@ -56,6 +54,10 @@
color: #fff;
}
+#qunit-header label {
+ display: inline-block;
+}
+
#qunit-banner {
height: 5px;
}
@@ -225,4 +227,6 @@
position: absolute;
top: -10000px;
left: -10000px;
+ width: 1000px;
+ height: 1000px;
} | true |
Other | emberjs | ember.js | c7925ed13317be0df893094db2c7a56db01d47b9.json | Upgrade QUnit and fix warnings/errors | tests/qunit/qunit.js | @@ -1,22 +1,23 @@
/**
- * QUnit v1.3.0pre - A JavaScript Unit Testing Framework
+ * QUnit v1.4.0pre - A JavaScript Unit Testing Framework
*
* http://docs.jquery.com/QUnit
*
- * Copyright (c) 2011 John Resig, Jörn Zaefferer
+ * Copyright (c) 2012 John Resig, Jörn Zaefferer
* Dual licensed under the MIT (MIT-LICENSE.txt)
* or GPL (GPL-LICENSE.txt) licenses.
- * Pulled Live from Git Fri Dec 9 20:50:01 UTC 2011
- * Last Commit: 0712230bb203c262211649b32bd712ec7df5f857
*/
(function(window) {
var defined = {
setTimeout: typeof window.setTimeout !== "undefined",
sessionStorage: (function() {
+ var x = "qunit-test-string";
try {
- return !!sessionStorage.getItem;
+ sessionStorage.setItem(x, x);
+ sessionStorage.removeItem(x);
+ return true;
} catch(e) {
return false;
}
@@ -27,11 +28,10 @@ var testId = 0,
toString = Object.prototype.toString,
hasOwn = Object.prototype.hasOwnProperty;
-var Test = function(name, testName, expected, testEnvironmentArg, async, callback) {
+var Test = function(name, testName, expected, async, callback) {
this.name = name;
this.testName = testName;
this.expected = expected;
- this.testEnvironmentArg = testEnvironmentArg;
this.async = async;
this.callback = callback;
this.assertions = [];
@@ -64,16 +64,17 @@ Test.prototype = {
runLoggingCallbacks( 'moduleStart', QUnit, {
name: this.module
} );
+ } else if (config.autorun) {
+ runLoggingCallbacks( 'moduleStart', QUnit, {
+ name: this.module
+ } );
}
config.current = this;
this.testEnvironment = extend({
setup: function() {},
teardown: function() {}
}, this.moduleTestEnvironment);
- if (this.testEnvironmentArg) {
- extend(this.testEnvironment, this.testEnvironmentArg);
- }
runLoggingCallbacks( 'testStart', QUnit, {
name: this.testName,
@@ -84,11 +85,14 @@ Test.prototype = {
// TODO why??
QUnit.current_testEnvironment = this.testEnvironment;
+ if ( !config.pollution ) {
+ saveGlobal();
+ }
+ if ( config.notrycatch ) {
+ this.testEnvironment.setup.call(this.testEnvironment);
+ return;
+ }
try {
- if ( !config.pollution ) {
- saveGlobal();
- }
-
this.testEnvironment.setup.call(this.testEnvironment);
} catch(e) {
QUnit.ok( false, "Setup failed on " + this.testName + ": " + e.message );
@@ -120,17 +124,24 @@ Test.prototype = {
},
teardown: function() {
config.current = this;
- try {
+ if ( config.notrycatch ) {
this.testEnvironment.teardown.call(this.testEnvironment);
- checkPollution();
- } catch(e) {
- QUnit.ok( false, "Teardown failed on " + this.testName + ": " + e.message );
+ return;
+ } else {
+ try {
+ this.testEnvironment.teardown.call(this.testEnvironment);
+ } catch(e) {
+ QUnit.ok( false, "Teardown failed on " + this.testName + ": " + e.message );
+ }
}
+ checkPollution();
},
finish: function() {
config.current = this;
if ( this.expected != null && this.expected != this.assertions.length ) {
QUnit.ok( false, "Expected " + this.expected + " assertions, but " + this.assertions.length + " were run" );
+ } else if ( this.expected == null && !this.assertions.length ) {
+ QUnit.ok( false, "Expected at least one assertion, but none were run - call expect(0) to accept zero assertions." );
}
var good = 0, bad = 0,
@@ -276,17 +287,12 @@ var QUnit = {
},
test: function(testName, expected, callback, async) {
- var name = '<span class="test-name">' + escapeInnerText(testName) + '</span>', testEnvironmentArg;
+ var name = '<span class="test-name">' + escapeInnerText(testName) + '</span>';
if ( arguments.length === 2 ) {
callback = expected;
expected = null;
}
- // is 2nd argument a testEnvironment?
- if ( expected && typeof expected === 'object') {
- testEnvironmentArg = expected;
- expected = null;
- }
if ( config.currentModule ) {
name = '<span class="module-name">' + config.currentModule + "</span>: " + name;
@@ -296,7 +302,7 @@ var QUnit = {
return;
}
- var test = new Test(name, testName, expected, testEnvironmentArg, async, callback);
+ var test = new Test(name, testName, expected, async, callback);
test.module = config.currentModule;
test.moduleTestEnvironment = config.currentModuleTestEnviroment;
test.queue();
@@ -313,16 +319,26 @@ var QUnit = {
* Asserts true.
* @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" );
*/
- ok: function(a, msg) {
- a = !!a;
+ ok: function(result, msg) {
+ if (!config.current) {
+ throw new Error("ok() assertion outside test context, was " + sourceFromStacktrace(2));
+ }
+ result = !!result;
var details = {
- result: a,
+ result: result,
message: msg
};
- msg = escapeInnerText(msg);
+ msg = escapeInnerText(msg || (result ? "okay" : "failed"));
+ if ( !result ) {
+ var source = sourceFromStacktrace(2);
+ if (source) {
+ details.source = source;
+ msg += '<table><tr class="test-source"><th>Source: </th><td><pre>' + escapeInnerText(source) + '</pre></td></tr></table>';
+ }
+ }
runLoggingCallbacks( 'log', QUnit, details );
config.current.assertions.push({
- result: a,
+ result: result,
message: msg
});
},
@@ -449,9 +465,14 @@ var QUnit = {
QUnit.constructor = F;
})();
-// Backwards compatibility, deprecated
-QUnit.equals = QUnit.equal;
-QUnit.same = QUnit.deepEqual;
+// deprecated; still export them to window to provide clear error messages
+// next step: remove entirely
+QUnit.equals = function() {
+ throw new Error("QUnit.equals has been deprecated since 2009 (e88049a0), use QUnit.equal instead");
+};
+QUnit.same = function() {
+ throw new Error("QUnit.same has been deprecated since 2009 (e88049a0), use QUnit.deepEqual instead");
+};
// Maintain internal state
var config = {
@@ -510,13 +531,10 @@ var config = {
})();
// Expose the API as global variables, unless an 'exports'
-// object exists, in that case we assume we're in CommonJS
+// object exists, in that case we assume we're in CommonJS - export everything at the end
if ( typeof exports === "undefined" || typeof require === "undefined" ) {
extend(window, QUnit);
window.QUnit = QUnit;
-} else {
- extend(exports, QUnit);
- exports.QUnit = QUnit;
}
// define these after exposing globals to keep them in these QUnit namespace only
@@ -538,6 +556,16 @@ extend(QUnit, {
semaphore: 0
});
+ var qunit = id( "qunit" );
+ if ( qunit ) {
+ qunit.innerHTML =
+ '<h1 id="qunit-header">' + escapeInnerText( document.title ) + '</h1>' +
+ '<h2 id="qunit-banner"></h2>' +
+ '<div id="qunit-testrunner-toolbar"></div>' +
+ '<h2 id="qunit-userAgent"></h2>' +
+ '<ol id="qunit-tests"></ol>';
+ }
+
var tests = id( "qunit-tests" ),
banner = id( "qunit-banner" ),
result = id( "qunit-testresult" );
@@ -638,6 +666,9 @@ extend(QUnit, {
},
push: function(result, actual, expected, message) {
+ if (!config.current) {
+ throw new Error("assertion outside test context, was " + sourceFromStacktrace());
+ }
var details = {
result: result,
message: message,
@@ -647,9 +678,7 @@ extend(QUnit, {
message = escapeInnerText(message) || (result ? "okay" : "failed");
message = '<span class="test-message">' + message + "</span>";
-
var output = message;
-
if (!result) {
expected = escapeInnerText(QUnit.jsDump.parse(expected));
actual = escapeInnerText(QUnit.jsDump.parse(actual));
@@ -663,8 +692,8 @@ extend(QUnit, {
details.source = source;
output += '<tr class="test-source"><th>Source: </th><td><pre>' + escapeInnerText(source) + '</pre></td></tr>';
}
+ output += "</table>";
}
- output += "</table>";
runLoggingCallbacks( 'log', QUnit, details );
@@ -852,6 +881,15 @@ function done() {
].join(" ");
}
+ // clear own sessionStorage items if all tests passed
+ if ( config.reorder && defined.sessionStorage && config.stats.bad === 0 ) {
+ for (var key in sessionStorage) {
+ if (sessionStorage.hasOwnProperty(key) && key.indexOf("qunit-") === 0 ) {
+ sessionStorage.removeItem(key);
+ }
+ }
+ }
+
runLoggingCallbacks( 'done', QUnit, {
failed: config.stats.bad,
passed: passed,
@@ -886,16 +924,21 @@ function validTest( name ) {
// so far supports only Firefox, Chrome and Opera (buggy)
// could be extended in the future to use something like https://github.com/csnover/TraceKit
-function sourceFromStacktrace() {
+function sourceFromStacktrace(offset) {
+ offset = offset || 3;
try {
throw new Error();
} catch ( e ) {
if (e.stacktrace) {
// Opera
- return e.stacktrace.split("\n")[6];
+ return e.stacktrace.split("\n")[offset + 3];
} else if (e.stack) {
// Firefox, Chrome
- return e.stack.split("\n")[4];
+ var stack = e.stack.split("\n");
+ if (/^error$/i.test(stack[0])) {
+ stack.shift();
+ }
+ return stack[offset];
} else if (e.sourceURL) {
// Safari, PhantomJS
// TODO sourceURL points at the 'throw new Error' line above, useless
@@ -1371,12 +1414,20 @@ QUnit.jsDump = (function() {
nodelist: array,
arguments: array,
object:function( map, stack ) {
- var ret = [ ];
+ var ret = [ ], keys, key, val, i;
QUnit.jsDump.up();
- for ( var key in map ) {
- var val = map[key];
- ret.push( QUnit.jsDump.parse(key,'key') + ': ' + QUnit.jsDump.parse(val, undefined, stack));
- }
+ if (Object.keys) {
+ keys = Object.keys( map );
+ } else {
+ keys = [];
+ for (key in map) { keys.push( key ); }
+ }
+ keys.sort();
+ for (i = 0; i < keys.length; i++) {
+ key = keys[ i ];
+ val = map[ key ];
+ ret.push( QUnit.jsDump.parse( key, 'key' ) + ': ' + QUnit.jsDump.parse( val, undefined, stack ) );
+ }
QUnit.jsDump.down();
return join( '{', ret, '}' );
},
@@ -1600,4 +1651,10 @@ QUnit.diff = (function() {
};
})();
-})(this);
+// for CommonJS enviroments, export everything
+if ( typeof exports !== "undefined" || typeof require !== "undefined" ) {
+ extend(exports, QUnit);
+}
+
+// get at whatever the global object is, like window in browsers
+})( (function() {return this}).call() ); | true |
Other | emberjs | ember.js | 8f2dfc4dd0fe3a02ac0a49cd28397110400f4cdd.json | Hide some private methods from docs | packages/ember-metal/lib/array.js | @@ -2,6 +2,7 @@
// Testing this is not ideal, but we want ArrayUtils to use native functions
// if available, but not to use versions created by libraries like Prototype
+/** @private */
var isNativeFunc = function(func) {
// This should probably work in all browsers likely to have ES5 array methods
return func && Function.prototype.toString.call(func).indexOf('[native code]') > -1; | true |
Other | emberjs | ember.js | 8f2dfc4dd0fe3a02ac0a49cd28397110400f4cdd.json | Hide some private methods from docs | packages/ember-metal/lib/utils.js | @@ -150,7 +150,7 @@ var EMPTY_META = {
if (Object.freeze) Object.freeze(EMPTY_META);
-var createMeta = Ember.platform.defineProperty.isSimulated ? o_create : function(meta) { return meta; };
+var createMeta = Ember.platform.defineProperty.isSimulated ? o_create : (function(meta) { return meta; });
/**
@private | true |
Other | emberjs | ember.js | 8f2dfc4dd0fe3a02ac0a49cd28397110400f4cdd.json | Hide some private methods from docs | packages/ember-runtime/lib/mixins/array.js | @@ -15,8 +15,10 @@ require('ember-runtime/mixins/enumerable');
var get = Ember.get, set = Ember.set, meta = Ember.meta;
+/** @private */
function none(obj) { return obj===null || obj===undefined; }
+/** @private */
function xform(target, method, params) {
method.call(target, params[0], params[2], params[3], params[4]);
} | true |
Other | emberjs | ember.js | 8f2dfc4dd0fe3a02ac0a49cd28397110400f4cdd.json | Hide some private methods from docs | packages/ember-runtime/lib/mixins/evented.js | @@ -1,5 +1,6 @@
var get = Ember.get, set = Ember.set;
+/** @private */
function xform(target, method, params) {
var args = [].slice.call(params, 2);
method.apply(target, args); | true |
Other | emberjs | ember.js | 8f2dfc4dd0fe3a02ac0a49cd28397110400f4cdd.json | Hide some private methods from docs | packages/ember-runtime/lib/system/map.js | @@ -18,6 +18,7 @@
`Ember.Map.create()` for symmetry with other Ember classes.
*/
+/** @private */
var guidFor = Ember.guidFor;
var indexOf = Ember.ArrayUtils.indexOf;
@@ -97,6 +98,7 @@ OrderedSet.prototype = {
we delete its entry in `keys` and `values`.
*/
+/** @private */
var Map = Ember.Map = function() {
this.keys = Ember.OrderedSet.create();
this.values = {}; | true |
Other | emberjs | ember.js | 8f2dfc4dd0fe3a02ac0a49cd28397110400f4cdd.json | Hide some private methods from docs | packages/ember-views/lib/views/view.js | @@ -1428,6 +1428,7 @@ Ember.View = Ember.Object.extend(Ember.Evented,
// once the view has been inserted into the DOM, legal manipulations
// are done on the DOM element.
+/** @private */
DOMManager = {
prepend: function(view, childView) {
childView._insertElementLater(function() { | true |
Other | emberjs | ember.js | 9050fabac7f7b3e302893ce3312d241805514ee0.json | Add a cache for invokeForState in Ember.View | packages/ember-views/lib/views/view.js | @@ -39,6 +39,14 @@ var childViewsProperty = Ember.computed(function() {
*/
Ember.TEMPLATES = {};
+var invokeForState = {
+ preRender: {},
+ inBuffer: {},
+ hasElement: {},
+ inDOM: {},
+ destroyed: {}
+};
+
/**
@class
@since Ember 0.9
@@ -334,8 +342,18 @@ Ember.View = Ember.Object.extend(Ember.Evented,
},
invokeForState: function(name) {
- var parent = this, states = parent.states;
- var stateName = get(this, 'state'), state;
+ var stateName = this.state, args;
+
+ // try to find the function for the state in the cache
+ if (fn = invokeForState[stateName][name]) {
+ args = a_slice.call(arguments)
+ args[0] = this;
+
+ return fn.apply(this, args);
+ }
+
+ // otherwise, find and cache the function for this state
+ var parent = this, states = parent.states, state;
while (states) {
state = states[stateName];
@@ -344,7 +362,9 @@ Ember.View = Ember.Object.extend(Ember.Evented,
var fn = state[name];
if (fn) {
- var args = a_slice.call(arguments, 1);
+ invokeForState[stateName][name] = fn;
+
+ args = a_slice.call(arguments, 1);
args.unshift(this);
return fn.apply(this, args);
@@ -1348,7 +1368,7 @@ Ember.View = Ember.Object.extend(Ember.Evented,
},
transitionTo: function(state, children) {
- set(this, 'state', state);
+ this.state = state;
if (children !== false) {
this.forEachChildView(function(view) { | false |
Other | emberjs | ember.js | f44c29a8f62eb548a3ae402f5efbf2310c469d3a.json | Update API docs for ArrayController and ArrayProxy | packages/ember-runtime/lib/controllers/array_controller.js | @@ -9,11 +9,13 @@ require('ember-runtime/system/array_proxy');
/**
@class
- Ember.ArrayController provides a way for you to publish an array of objects for
- Ember.CollectionView or other controllers to work with. To work with an
- ArrayController, set the content property to the array you want the controller
- to manage. Then work directly with the controller object as if it were the
- array itself.
+ Ember.ArrayController provides a way for you to publish a collection of objects
+ so that you can easily bind to the collection from a Handlebars #each helper,
+ an Ember.CollectionView, or other controllers.
+
+ The advantage of using an ArrayController is that you only have to set up
+ your view bindings once; to change what's displayed, simply swap out the
+ `content` property on the controller.
For example, imagine you wanted to display a list of items fetched via an XHR
request. Create an Ember.ArrayController and set its `content` property:
@@ -26,13 +28,19 @@ require('ember-runtime/system/array_proxy');
Then, create a view that binds to your new controller:
- {{#each MyApp.listController}}
- {{firstName}} {{lastName}}
- {{/each}}
+ {{#each MyApp.listController}}
+ {{firstName}} {{lastName}}
+ {{/each}}
- The advantage of using an array controller is that you only have to set up
- your view bindings once; to change what's displayed, simply swap out the
- `content` property on the controller.
+ Although you are binding to the controller, the behavior of this controller
+ is to pass through any methods or properties to the underlying array. This
+ capability comes from `Ember.ArrayProxy`, which this class inherits from.
+
+ Note: As of this writing, `ArrayController` does not add any functionality
+ to its superclass, `ArrayProxy`. The Ember team plans to add additional
+ controller-specific functionality in the future, e.g. single or multiple
+ selection support. If you are creating something that is conceptually a
+ controller, use this class.
@extends Ember.ArrayProxy
*/ | true |
Other | emberjs | ember.js | f44c29a8f62eb548a3ae402f5efbf2310c469d3a.json | Update API docs for ArrayController and ArrayProxy | packages/ember-runtime/lib/system/array_proxy.js | @@ -15,9 +15,31 @@ var get = Ember.get, set = Ember.set;
@class
An ArrayProxy wraps any other object that implements Ember.Array and/or
- Ember.MutableArray, forwarding all requests. ArrayProxy isn't useful by itself
- but you can extend it to do specialized things like transforming values,
- etc.
+ Ember.MutableArray, forwarding all requests. This makes it very useful for
+ a number of binding use cases or other cases where being able to swap
+ out the underlying array is useful.
+
+ A simple example of usage:
+
+ var pets = ['dog', 'cat', 'fish'];
+ var arrayProxy = Ember.ArrayProxy.create({ content: Ember.A(pets) });
+ ap.get('firstObject'); // => 'dog'
+ ap.set('content', ['amoeba', 'paramecium']);
+ ap.get('firstObject'); // => 'amoeba'
+
+ This class can also be useful as a layer to transform the contents of
+ an array, as they are accessed. This can be done by overriding
+ `objectAtContent`:
+
+ var pets = ['dog', 'cat', 'fish'];
+ var ap = Ember.ArrayProxy.create({
+ content: Ember.A(pets),
+ objectAtContent: function(idx) {
+ return this.get('content').objectAt(idx).toUpperCase();
+ }
+ });
+ ap.get('firstObject'); // => 'DOG'
+
@extends Ember.Object
@extends Ember.Array
@@ -27,7 +49,7 @@ Ember.ArrayProxy = Ember.Object.extend(Ember.MutableArray,
/** @scope Ember.ArrayProxy.prototype */ {
/**
- The content array. Must be an object that implements Ember.Array and or
+ The content array. Must be an object that implements Ember.Array and/or
Ember.MutableArray.
@property {Ember.Array}
@@ -36,7 +58,7 @@ Ember.ArrayProxy = Ember.Object.extend(Ember.MutableArray,
/**
Should actually retrieve the object at the specified index from the
- content. You can override this method in subclasses to transform the
+ content. You can override this method in subclasses to transform the
content item to something new.
This method will only be called if content is non-null.
@@ -72,6 +94,10 @@ Ember.ArrayProxy = Ember.Object.extend(Ember.MutableArray,
get(this, 'content').replace(idx, amt, objects);
},
+ /**
+ Invoked when the content property is about to change. Notifies observers that the
+ entire array content will change.
+ */
contentWillChange: Ember.beforeObserver(function() {
var content = get(this, 'content'),
len = content ? get(content, 'length') : 0;
@@ -117,6 +143,7 @@ Ember.ArrayProxy = Ember.Object.extend(Ember.MutableArray,
this.arrayContentDidChange(idx, removedCnt, addedCnt);
},
+ /** @private (nodoc) */
init: function() {
this._super();
this.contentDidChange(); | true |
Other | emberjs | ember.js | 02ac26d7805a5a3848def089506bd1f1e45ecc8c.json | Make the RenderBuffer lazier and more efficient
Don't bother setting up structures that will never
be used and use regular accessors. We don't need
the RenderBuffer to be observable. | packages/ember-views/lib/system/render_buffer.js | @@ -100,11 +100,7 @@ Ember._RenderBuffer = Ember.Object.extend(
init: function() {
this._super();
- set(this ,'elementClasses', Ember.A());
- set(this, 'elementAttributes', {});
- set(this, 'elementStyle', {});
- set(this, 'childBuffers', []);
- set(this, 'elements', {});
+ this.childBuffers = [];
},
/**
@@ -114,7 +110,7 @@ Ember._RenderBuffer = Ember.Object.extend(
@returns {Ember.RenderBuffer} this
*/
push: function(string) {
- get(this, 'childBuffers').push(String(string));
+ this.childBuffers.push(String(string));
return this;
},
@@ -125,7 +121,10 @@ Ember._RenderBuffer = Ember.Object.extend(
@returns {Ember.RenderBuffer} this
*/
addClass: function(className) {
- get(this, 'elementClasses').addObject(className);
+ // lazily create elementClasses
+ var elementClasses = this.elementClasses = (this.elementClasses || Ember.A([]))
+
+ this.elementClasses.addObject(className);
return this;
},
@@ -136,7 +135,7 @@ Ember._RenderBuffer = Ember.Object.extend(
@returns {Ember.RenderBuffer} this
*/
id: function(id) {
- set(this, 'elementId', id);
+ this.elementId = id;
return this;
},
@@ -151,7 +150,7 @@ Ember._RenderBuffer = Ember.Object.extend(
@returns {Ember.RenderBuffer|String} this or the current attribute value
*/
attr: function(name, value) {
- var attributes = get(this, 'elementAttributes');
+ var attributes = this.elementAttributes = (this.elementAttributes || {});
if (arguments.length === 1) {
return attributes[name];
@@ -169,8 +168,8 @@ Ember._RenderBuffer = Ember.Object.extend(
@returns {Ember.RenderBuffer} this
*/
removeAttr: function(name) {
- var attributes = get(this, 'elementAttributes');
- delete attributes[name];
+ var attributes = this.elementAttributes;
+ if (attributes) { delete attributes[name]; }
return this;
},
@@ -183,7 +182,9 @@ Ember._RenderBuffer = Ember.Object.extend(
@returns {Ember.RenderBuffer} this
*/
style: function(name, value) {
- get(this, 'elementStyle')[name] = value;
+ var style = this.elementStyle = (this.elementStyle || {});
+
+ this.elementStyle[name] = value;
return this;
},
@@ -225,10 +226,10 @@ Ember._RenderBuffer = Ember.Object.extend(
the existing buffer.
*/
replaceWithBuffer: function(newBuffer) {
- var parent = get(this, 'parentBuffer');
+ var parent = this.parentBuffer;
if (!parent) { return; }
- var childBuffers = get(parent, 'childBuffers');
+ var childBuffers = parent.childBuffers;
var index = indexOf(childBuffers, this);
@@ -249,7 +250,7 @@ Ember._RenderBuffer = Ember.Object.extend(
*/
begin: function(tagName) {
return this.newBuffer(tagName, this, function(buffer) {
- get(this, 'childBuffers').push(buffer);
+ this.childBuffers.push(buffer);
});
},
@@ -260,7 +261,7 @@ Ember._RenderBuffer = Ember.Object.extend(
*/
prepend: function(tagName) {
return this.newBuffer(tagName, this, function(buffer) {
- get(this, 'childBuffers').splice(0, 0, buffer);
+ this.childBuffers.splice(0, 0, buffer);
});
},
@@ -270,7 +271,7 @@ Ember._RenderBuffer = Ember.Object.extend(
@param {String} tagName Tag name to use for the new buffer's element
*/
replaceWith: function(tagName) {
- var parentBuffer = get(this, 'parentBuffer');
+ var parentBuffer = this.parentBuffer;
return this.newBuffer(tagName, parentBuffer, function(buffer) {
this.replaceWithBuffer(buffer);
@@ -286,7 +287,7 @@ Ember._RenderBuffer = Ember.Object.extend(
var parentBuffer = get(this, 'parentBuffer');
return this.newBuffer(tagName, parentBuffer, function(buffer) {
- var siblings = get(parentBuffer, 'childBuffers');
+ var siblings = parentBuffer.childBuffers;
var index = indexOf(siblings, this);
siblings.splice(index + 1, 0, buffer);
});
@@ -298,7 +299,7 @@ Ember._RenderBuffer = Ember.Object.extend(
@returns {Ember.RenderBuffer} The parentBuffer, if one exists. Otherwise, this
*/
end: function() {
- var parent = get(this, 'parentBuffer');
+ var parent = this.parentBuffer;
return parent || this;
},
@@ -320,40 +321,42 @@ Ember._RenderBuffer = Ember.Object.extend(
@returns {String} The generated HTMl
*/
string: function() {
- var id = get(this, 'elementId'),
- classes = get(this, 'elementClasses'),
- attrs = get(this, 'elementAttributes'),
- style = get(this, 'elementStyle'),
- tag = get(this, 'elementTag'),
- content = '',
- styleBuffer = [], prop, openTag;
+ var content = '', tag = this.elementTag, openTag;
if (tag) {
+ var id = this.elementId,
+ classes = this.elementClasses,
+ attrs = this.elementAttributes,
+ style = this.elementStyle,
+ styleBuffer = '', prop;
+
openTag = ["<" + tag];
if (id) { openTag.push('id="' + id + '"'); }
- if (classes.length) { openTag.push('class="' + classes.join(" ") + '"'); }
+ if (classes) { openTag.push('class="' + classes.join(" ") + '"'); }
- if (!Ember.$.isEmptyObject(style)) {
+ if (style) {
for (prop in style) {
if (style.hasOwnProperty(prop)) {
- styleBuffer.push(prop + ':' + style[prop] + ';');
+ styleBuffer += (prop + ':' + style[prop] + ';');
}
}
- openTag.push('style="' + styleBuffer.join("") + '"');
+ openTag.push('style="' + styleBuffer + '"');
}
- for (prop in attrs) {
- if (attrs.hasOwnProperty(prop)) {
- openTag.push(prop + '="' + attrs[prop] + '"');
+ if (attrs) {
+ for (prop in attrs) {
+ if (attrs.hasOwnProperty(prop)) {
+ openTag.push(prop + '="' + attrs[prop] + '"');
+ }
}
}
openTag = openTag.join(" ") + '>';
}
- var childBuffers = get(this, 'childBuffers');
+ var childBuffers = this.childBuffers;
forEach(childBuffers, function(buffer) {
var stringy = typeof buffer === 'string'; | false |
Other | emberjs | ember.js | caa4c9cd21b43c6f2f827e307f5486785d9b0174.json | Make DOMManager stateless for performance | packages/ember-handlebars/lib/views/metamorph_view.js | @@ -5,75 +5,73 @@ require("ember-views/views/view");
var set = Ember.set, get = Ember.get, getPath = Ember.getPath;
+var DOMManager = {
+ remove: function(view) {
+ var morph = view.morph;
+ if (morph.isRemoved()) { return; }
+ morph.remove();
+ },
+
+ prepend: function(view, childView) {
+ childView._insertElementLater(function() {
+ var morph = view.morph;
+ morph.prepend(childView.outerHTML);
+ childView.outerHTML = null;
+ });
+ },
+
+ after: function(view, nextView) {
+ nextView._insertElementLater(function() {
+ var morph = view.morph;
+ morph.after(nextView.outerHTML);
+ nextView,outerHTML = null;
+ });
+ },
+
+ replace: function(view) {
+ var morph = view.morph;
+
+ view.transitionTo('preRender');
+ view.clearRenderedChildren();
+ var buffer = view.renderToBuffer();
+
+ Ember.run.schedule('render', this, function() {
+ if (get(view, 'isDestroyed')) { return; }
+ view.invalidateRecursively('element');
+ view._notifyWillInsertElement();
+ morph.replaceWith(buffer.string());
+ view.transitionTo('inDOM');
+ view._notifyDidInsertElement();
+ });
+ }
+};
+
+// The `morph` and `outerHTML` properties are internal only
+// and not observable.
+
Ember.Metamorph = Ember.Mixin.create({
isVirtual: true,
tagName: '',
init: function() {
this._super();
- set(this, 'morph', Metamorph());
+ this.morph = Metamorph();
},
beforeRender: function(buffer) {
- var morph = get(this, 'morph');
- buffer.push(morph.startTag());
+ buffer.push(this.morph.startTag());
},
afterRender: function(buffer) {
- var morph = get(this, 'morph');
- buffer.push(morph.endTag());
+ buffer.push(this.morph.endTag());
},
createElement: function() {
var buffer = this.renderToBuffer();
- set(this, 'outerHTML', buffer.string());
+ this.outerHTML = buffer.string();
this.clearBuffer();
},
- domManagerClass: Ember.Object.extend({
- remove: function(view) {
- var morph = getPath(this, 'view.morph');
- if (morph.isRemoved()) { return; }
- getPath(this, 'view.morph').remove();
- },
-
- prepend: function(childView) {
- var view = get(this, 'view');
-
- childView._insertElementLater(function() {
- var morph = get(view, 'morph');
- morph.prepend(get(childView, 'outerHTML'));
- childView.set('outerHTML', null);
- });
- },
-
- after: function(nextView) {
- var view = get(this, 'view');
-
- nextView._insertElementLater(function() {
- var morph = get(view, 'morph');
- morph.after(get(nextView, 'outerHTML'));
- nextView.set('outerHTML', null);
- });
- },
-
- replace: function() {
- var view = get(this, 'view');
- var morph = getPath(this, 'view.morph');
-
- view.transitionTo('preRender');
- view.clearRenderedChildren();
- var buffer = view.renderToBuffer();
-
- Ember.run.schedule('render', this, function() {
- if (get(view, 'isDestroyed')) { return; }
- view.invalidateRecursively('element');
- view._notifyWillInsertElement();
- morph.replaceWith(buffer.string());
- view.transitionTo('inDOM');
- view._notifyDidInsertElement();
- });
- }
- })
+ domManager: DOMManager
});
| true |
Other | emberjs | ember.js | caa4c9cd21b43c6f2f827e307f5486785d9b0174.json | Make DOMManager stateless for performance | packages/ember-views/lib/views/container_view.js | @@ -139,9 +139,9 @@ Ember.ContainerView = Ember.View.extend({
*/
_scheduleInsertion: function(view, prev) {
if (prev) {
- prev.get('domManager').after(view);
+ prev.domManager.after(prev, view);
} else {
- this.get('domManager').prepend(view);
+ this.domManager.prepend(this, view);
}
}
}); | true |
Other | emberjs | ember.js | caa4c9cd21b43c6f2f827e307f5486785d9b0174.json | Make DOMManager stateless for performance | packages/ember-views/lib/views/states/in_dom.js | @@ -42,7 +42,7 @@ Ember.View.states.hasElement = {
view.clearRenderedChildren();
- get(view, 'domManager').replace();
+ view.domManager.replace(view);
return view;
},
@@ -52,7 +52,7 @@ Ember.View.states.hasElement = {
destroyElement: function(view) {
view._notifyWillDestroyElement();
- get(view, 'domManager').remove();
+ view.domManager.remove(view);
return view;
},
| true |
Other | emberjs | ember.js | caa4c9cd21b43c6f2f827e307f5486785d9b0174.json | Make DOMManager stateless for performance | packages/ember-views/lib/views/view.js | @@ -1117,6 +1117,8 @@ Ember.View = Ember.Object.extend(Ember.Evented,
*/
attributeBindings: [],
+ state: 'preRender',
+
// .......................................................
// CORE DISPLAY METHODS
//
@@ -1130,8 +1132,6 @@ Ember.View = Ember.Object.extend(Ember.Evented,
dispatch
*/
init: function() {
- set(this, 'state', 'preRender');
-
var parentView = get(this, '_parentView');
this._super();
@@ -1141,18 +1141,16 @@ Ember.View = Ember.Object.extend(Ember.Evented,
Ember.View.views[get(this, 'elementId')] = this;
var childViews = Ember.A(get(this, '_childViews').slice());
+
// setup child views. be sure to clone the child views array first
set(this, '_childViews', childViews);
-
ember_assert("Only arrays are allowed for 'classNameBindings'", Ember.typeOf(this.classNameBindings) === 'array');
this.classNameBindings = Ember.A(this.classNameBindings.slice());
ember_assert("Only arrays are allowed for 'classNames'", Ember.typeOf(this.classNames) === 'array');
this.classNames = Ember.A(this.classNames.slice());
- set(this, 'domManager', this.domManagerClass.create({ view: this }));
-
var viewController = get(this, 'viewController');
if (viewController) {
viewController = Ember.getPath(viewController);
@@ -1410,49 +1408,43 @@ Ember.View = Ember.Object.extend(Ember.Evented,
// once the view has been inserted into the DOM, legal manipulations
// are done on the DOM element.
-Ember.View.reopen({
- states: Ember.View.states,
- domManagerClass: Ember.Object.extend({
- view: this,
-
- prepend: function(childView) {
- var view = get(this, 'view');
-
- childView._insertElementLater(function() {
- var element = view.$();
- element.prepend(childView.$());
- });
- },
+DOMManager = {
+ prepend: function(view, childView) {
+ childView._insertElementLater(function() {
+ var element = view.$();
+ element.prepend(childView.$());
+ });
+ },
- after: function(nextView) {
- var view = get(this, 'view');
+ after: function(view, nextView) {
+ nextView._insertElementLater(function() {
+ var element = view.$();
+ element.after(nextView.$());
+ });
+ },
- nextView._insertElementLater(function() {
- var element = view.$();
- element.after(nextView.$());
- });
- },
+ replace: function(view) {
+ var element = get(view, 'element');
- replace: function() {
- var view = get(this, 'view');
- var element = get(view, 'element');
+ set(view, 'element', null);
- set(view, 'element', null);
+ view._insertElementLater(function() {
+ Ember.$(element).replaceWith(get(view, 'element'));
+ });
+ },
- view._insertElementLater(function() {
- Ember.$(element).replaceWith(get(view, 'element'));
- });
- },
+ remove: function(view) {
+ var elem = get(view, 'element');
- remove: function() {
- var view = get(this, 'view');
- var elem = get(view, 'element');
+ set(view, 'element', null);
- set(view, 'element', null);
+ Ember.$(elem).remove();
+ }
+};
- Ember.$(elem).remove();
- }
- })
+Ember.View.reopen({
+ states: Ember.View.states,
+ domManager: DOMManager
});
// Create a global view hash. | true |
Other | emberjs | ember.js | ce385e3294be019215c555511c7f393aebc02e41.json | Allow static classes in bindAttr | packages/ember-handlebars/lib/helpers/binding.js | @@ -321,7 +321,7 @@ EmberHandlebars.bindClasses = function(context, classBindings, view, bindAttrId)
property = split[0];
- var val = getPath(context, property);
+ var val = property !== '' ? getPath(context, property) : true;
// If value is a Boolean and true, return the dasherized property
// name.
@@ -392,7 +392,9 @@ EmberHandlebars.bindClasses = function(context, classBindings, view, bindAttrId)
};
var property = binding.split(':')[0];
- Ember.addObserver(context, property, invoker);
+ if (property !== '') {
+ Ember.addObserver(context, property, invoker);
+ }
// We've already setup the observer; now we just need to figure out the
// correct behavior right now on the first pass through. | true |
Other | emberjs | ember.js | ce385e3294be019215c555511c7f393aebc02e41.json | Allow static classes in bindAttr | packages/ember-handlebars/tests/handlebars_test.js | @@ -1234,7 +1234,7 @@ test("should be able to bind boolean element attributes using {{bindAttr}}", fun
});
test("should be able to add multiple classes using {{bindAttr class}}", function() {
- var template = Ember.Handlebars.compile('<div {{bindAttr class="content.isAwesomeSauce content.isAlsoCool content.isAmazing:amazing"}}></div>');
+ var template = Ember.Handlebars.compile('<div {{bindAttr class="content.isAwesomeSauce content.isAlsoCool content.isAmazing:amazing :is-super-duper"}}></div>');
var content = Ember.Object.create({
isAwesomeSauce: true,
isAlsoCool: true,
@@ -1251,6 +1251,7 @@ test("should be able to add multiple classes using {{bindAttr class}}", function
ok(view.$('div').hasClass('is-awesome-sauce'), "dasherizes first property and sets classname");
ok(view.$('div').hasClass('is-also-cool'), "dasherizes second property and sets classname");
ok(view.$('div').hasClass('amazing'), "uses alias for third property and sets classname");
+ ok(view.$('div').hasClass('is-super-duper'), "static class is present");
Ember.run(function() {
set(content, 'isAwesomeSauce', false);
@@ -1259,6 +1260,7 @@ test("should be able to add multiple classes using {{bindAttr class}}", function
ok(!view.$('div').hasClass('is-awesome-sauce'), "removes dasherized class when property is set to false");
ok(!view.$('div').hasClass('amazing'), "removes aliased class when property is set to false");
+ ok(view.$('div').hasClass('is-super-duper'), "static class is still present");
});
test("should be able to bindAttr to 'this' in an {{#each}} block", function() { | true |
Other | emberjs | ember.js | 71769f2ae255290f4d4a93fd8fef53fa243124c9.json | add test for issue #546 | packages/ember-metal/tests/binding/sync_test.js | @@ -89,6 +89,47 @@ testBoth("bindings should do the right thing when observers trigger bindings in
equal(get(a, 'foo'), "what is going on");
});
+testBoth("bindings should do the right thing when binding is in prototype", function(get, set) {
+ var obj, proto, a, b, selectionChanged;
+ Ember.run(function() {
+ obj = {
+ selection: null
+ };
+
+ selectionChanged = 0;
+
+ Ember.addObserver(obj, 'selection', function () {
+ selectionChanged++;
+ });
+
+ proto = {
+ obj: obj,
+ changeSelection: function (value) {
+ set(this, 'selection', value);
+ }
+ };
+ Em.bind(proto, 'selection', 'obj.selection');
+
+ a = Em.create(proto);
+ b = Em.create(proto);
+ });
+
+ Em.run(function () {
+ set(a, 'selection', 'a');
+ });
+
+ Em.run(function () {
+ set(b, 'selection', 'b');
+ });
+
+ Em.run(function () {
+ set(a, 'selection', 'a');
+ });
+
+ equal(selectionChanged, 3);
+ equal(get(obj, 'selection'), 'a');
+});
+
testBoth("bindings should not try to sync destroyed objects", function(get, set) {
var a, b;
| false |
Other | emberjs | ember.js | d9e44a37a01132ecba52d3415b13ff70eafe09d4.json | Fix jQuery.extend for older browsers - fixes #344 | packages/ember-metal/lib/utils.js | @@ -150,6 +150,8 @@ var EMPTY_META = {
if (Object.freeze) Object.freeze(EMPTY_META);
+var createMeta = Ember.platform.defineProperty.isSimulated ? o_create : function(meta) { return meta; };
+
/**
@private
@function
@@ -178,26 +180,27 @@ Ember.meta = function meta(obj, writable) {
if (!ret) {
o_defineProperty(obj, META_KEY, META_DESC);
- ret = obj[META_KEY] = {
+ ret = obj[META_KEY] = createMeta({
descs: {},
watching: {},
values: {},
lastSetValues: {},
cache: {},
source: obj
- };
+ });
// make sure we don't accidentally try to create constructor like desc
ret.descs.constructor = null;
} else if (ret.source !== obj) {
- ret = obj[META_KEY] = o_create(ret);
+ ret = o_create(ret);
ret.descs = o_create(ret.descs);
ret.values = o_create(ret.values);
ret.watching = o_create(ret.watching);
ret.lastSetValues = {};
ret.cache = {};
ret.source = obj;
+ ret = obj[META_KEY] = createMeta(ret);
}
return ret;
}; | true |
Other | emberjs | ember.js | d9e44a37a01132ecba52d3415b13ff70eafe09d4.json | Fix jQuery.extend for older browsers - fixes #344 | packages/ember-metal/tests/utils/meta_test.js | @@ -40,3 +40,18 @@ test("getMeta and setMeta", function() {
Ember.setMeta(obj, 'foo', "bar");
equal(Ember.getMeta(obj, 'foo'), "bar", "foo property on meta now exists");
});
+
+if (window.jQuery) {
+ // Tests fix for https://github.com/emberjs/ember.js/issues/344
+ // This is primarily for older browsers such as IE8
+ // We would use NativeArray but it's not defined in metal
+ test("jQuery.extend works on an extended Array", function() {
+ var mixin = Ember.Mixin.create({ prop: 'val' })
+ array = mixin.apply([1,2,3]),
+ result = {};
+
+ jQuery.extend(true, result, { arr: array });
+
+ equals(result.arr.length, 3);
+ });
+} | true |
Other | emberjs | ember.js | 2326580cda4383ee732e84a28407728fe4231bfb.json | Add an evented mixin for Ember objects
In general, we should be using events more
extensively that happen to trigger callbacks as
a side effect.
This makes it possible for other objects to
register for notifications that would normally
be provided via callbacks, such as when a single
object manages a number of views. | packages/ember-runtime/lib/mixins.js | @@ -13,3 +13,4 @@ require('ember-runtime/mixins/mutable_array');
require('ember-runtime/mixins/mutable_enumerable');
require('ember-runtime/mixins/observable');
require('ember-runtime/mixins/target_action_support');
+require('ember-runtime/mixins/evented'); | true |
Other | emberjs | ember.js | 2326580cda4383ee732e84a28407728fe4231bfb.json | Add an evented mixin for Ember objects
In general, we should be using events more
extensively that happen to trigger callbacks as
a side effect.
This makes it possible for other objects to
register for notifications that would normally
be provided via callbacks, such as when a single
object manages a number of views. | packages/ember-runtime/lib/mixins/evented.js | @@ -0,0 +1,25 @@
+var get = Ember.get, set = Ember.set;
+
+function xform(target, method, params) {
+ var args = [].slice.call(params, 2);
+ method.apply(target, args);
+}
+
+Ember.Evented = Ember.Mixin.create({
+ bindEvent: function(name, target, method) {
+ if (!method) {
+ method = target;
+ target = null;
+ }
+
+ Ember.addListener(this, name, target, method, xform);
+ },
+
+ triggerEvent: function(name) {
+ Ember.sendEvent.apply(null, [this, name].concat([].slice.call(arguments, 1)));
+ },
+
+ unbindEvent: function(name, target, method) {
+ Ember.removeListener(this, name, target, method);
+ }
+}); | true |
Other | emberjs | ember.js | 2326580cda4383ee732e84a28407728fe4231bfb.json | Add an evented mixin for Ember objects
In general, we should be using events more
extensively that happen to trigger callbacks as
a side effect.
This makes it possible for other objects to
register for notifications that would normally
be provided via callbacks, such as when a single
object manages a number of views. | packages/ember-runtime/tests/system/object/events_test.js | @@ -0,0 +1,51 @@
+module("Object events");
+
+test("a listener can be added to an object", function() {
+ var count = 0;
+ var F = function() { count++; };
+
+ var obj = Ember.Object.create(Ember.Evented);
+
+ obj.bindEvent('event!', F);
+ obj.triggerEvent('event!');
+
+ equal(count, 1, "the event was triggered");
+
+ obj.triggerEvent('event!');
+
+ equal(count, 2, "the event was triggered");
+});
+
+test("triggering an event can have arguments", function() {
+ var self, args;
+
+ var obj = Ember.Object.create(Ember.Evented);
+
+ obj.bindEvent('event!', function() {
+ args = [].slice.call(arguments);
+ self = this;
+ });
+
+ obj.triggerEvent('event!', "foo", "bar");
+
+ deepEqual(args, [ "foo", "bar" ]);
+ equal(self, obj);
+});
+
+test("binding an event can specify a different target", function() {
+ var self, args;
+
+ var obj = Ember.Object.create(Ember.Evented);
+ var target = {};
+
+ obj.bindEvent('event!', target, function() {
+ args = [].slice.call(arguments);
+ self = this;
+ });
+
+ obj.triggerEvent('event!', "foo", "bar");
+
+ deepEqual(args, [ "foo", "bar" ]);
+ equal(self, target);
+});
+ | true |
Other | emberjs | ember.js | 8a09430363e01c6121fdeff1e7111360151fd555.json | Expose OrderedSet for Ember Data | packages/ember-runtime/lib/system/map.js | @@ -20,7 +20,10 @@
var guidFor = Ember.guidFor;
-var OrderedSet = function() {
+// This class is used internally by Ember.js and Ember Data.
+// Please do not use it at this time. We plan to clean it up
+// and add many tests soon.
+var OrderedSet = Ember.OrderedSet = function() {
this.clear();
};
| false |
Other | emberjs | ember.js | 3d2ba75dc7d381b63347e44934457f1a36669300.json | Remove more mentions of IndexSet | packages/ember-runtime/lib/mixins/mutable_array.js | @@ -74,13 +74,12 @@ Ember.MutableArray = Ember.Mixin.create(Ember.Array, Ember.MutableEnumerable,
/**
Remove an object at the specified index using the replace() primitive
- method. You can pass either a single index, a start and a length or an
- index set.
+ method. You can pass either a single index, or a start and a length.
- If you pass a single index or a start and length that is beyond the
+ If you pass a start and length that is beyond the
length this method will throw an Ember.OUT_OF_RANGE_EXCEPTION
- @param {Number|Ember.IndexSet} start index, start of range, or index set
+ @param {Number} start index, start of range
@param {Number} len length of passing range
@returns {Object} receiver
*/ | true |
Other | emberjs | ember.js | 3d2ba75dc7d381b63347e44934457f1a36669300.json | Remove more mentions of IndexSet | packages/ember-runtime/lib/mixins/mutable_enumerable.js | @@ -55,9 +55,8 @@ Ember.MutableEnumerable = Ember.Mixin.create(Ember.Enumerable,
already present in the collection. If the object is present, this method
has no effect.
- If the passed object is of a type not supported by the receiver (for
- example if you pass an object to an IndexSet) then this method should
- raise an exception.
+ If the passed object is of a type not supported by the receiver
+ then this method should raise an exception.
@param {Object} object
The object to add to the enumerable.
@@ -86,9 +85,8 @@ Ember.MutableEnumerable = Ember.Mixin.create(Ember.Enumerable,
object is in present in the collection. If the object is not present,
this method has no effect.
- If the passed object is of a type not supported by the receiver (for
- example if you pass an object to an IndexSet) then this method should
- raise an exception.
+ If the passed object is of a type not supported by the receiver
+ then this method should raise an exception.
@param {Object} object
The object to remove from the enumerable. | true |
Other | emberjs | ember.js | 2bdc696ab6f16977336785ed4cae865263ad0423.json | Add an eachComputedProperty iterator | packages/ember-runtime/lib/system/core_object.js | @@ -213,6 +213,25 @@ var ClassMixin = Ember.Mixin.create({
ember_assert("metaForProperty() could not find a computed property with key '"+key+"'.", !!desc && desc instanceof Ember.ComputedProperty);
return desc._meta || {};
+ },
+
+ /**
+ Iterate over each computed property for the class, passing its name
+ and any associated metadata (see `metaForProperty`) to the callback.
+ */
+ eachComputedProperty: function(callback, binding) {
+ var proto = get(this, 'proto'),
+ descs = meta(proto).descs,
+ empty = {},
+ property;
+
+ for (var name in descs) {
+ property = descs[name];
+
+ if (property instanceof Ember.ComputedProperty) {
+ callback.call(binding || this, name, property._meta || empty);
+ }
+ }
}
}); | true |
Other | emberjs | ember.js | 2bdc696ab6f16977336785ed4cae865263ad0423.json | Add an eachComputedProperty iterator | packages/ember-runtime/tests/system/object/computed_test.js | @@ -159,3 +159,53 @@ test("can retrieve metadata for a computed property", function() {
ClassWithNoMetadata.metaForProperty('staticProperty');
}, Error, "throws an error if metadata for a non-computed property is requested");
});
+
+testBoth("can iterate over a list of computed properties for a class", function(get, set) {
+ var MyClass = Ember.Object.extend({
+ foo: Ember.computed(function() {
+
+ }),
+
+ fooDidChange: Ember.observer(function() {
+
+ }, 'foo'),
+
+ bar: Ember.computed(function() {
+
+ })
+ });
+
+ var SubClass = MyClass.extend({
+ baz: Ember.computed(function() {
+
+ })
+ });
+
+ SubClass.reopen({
+ bat: Ember.computed(function() {
+
+ }).meta({ iAmBat: true })
+ });
+
+ var list = [];
+
+ MyClass.eachComputedProperty(function(name) {
+ list.push(name);
+ });
+
+ deepEqual(list.sort(), ['bar', 'foo'], "watched and unwatched computed properties are iterated");
+
+ list = [];
+
+ SubClass.eachComputedProperty(function(name, meta) {
+ list.push(name);
+
+ if (name === 'bat') {
+ deepEqual(meta, { iAmBat: true });
+ } else {
+ deepEqual(meta, {});
+ }
+ });
+
+ deepEqual(list.sort(), ['bar', 'bat', 'baz', 'foo'], "all inherited properties are included");
+}); | true |
Other | emberjs | ember.js | 6e3489e3d29b0bcc5841d6613c2c58f5fb2c53a2.json | use html entity to avoid doc breakage in parsing | packages/ember-handlebars/lib/helpers/template.js | @@ -17,7 +17,7 @@ require('ember-handlebars/ext');
</script>
This helper looks for templates in the global Ember.TEMPLATES hash. If you
- add <script> tags to your page with the `data-template-name` attribute set,
+ add <script> tags to your page with the `data-template-name` attribute set,
they will be compiled and placed in this hash automatically.
You can also manually register templates by adding them to the hash: | false |
Other | emberjs | ember.js | b2c61125feb1a3778ebc8d9e8dd9bf9556926cf2.json | fix typo in Ember.Set docs | packages/ember-runtime/lib/system/set.js | @@ -22,7 +22,7 @@ var get = Ember.get, set = Ember.set, guidFor = Ember.guidFor, none = Ember.none
A Set works a bit like an array except that its items are not ordered.
You can create a set to efficiently test for membership for an object. You
can also iterate through a set just like an array, even accessing objects
- by index, however there is no gaurantee as to their order.
+ by index, however there is no guarantee as to their order.
Starting with Ember 2.0 all Sets are now observable since there is no
added cost to providing this support. Sets also do away with the more | false |
Other | emberjs | ember.js | 12b8f02e324ff6a6bc3fbcb80e45d09afbfab56d.json | Add a strip_whitespace task to the Rakefile | Rakefile | @@ -7,6 +7,16 @@ require "bundler/setup"
require "erb"
require "uglifier"
+desc "Strip trailing whitespace for JavaScript files in packages"
+task :strip_whitespace do
+ Dir["packages/**/*.js"].each do |name|
+ body = File.read(name)
+ File.open(name, "w") do |file|
+ file.write body.gsub(/ +\n/, "\n")
+ end
+ end
+end
+
# for now, the SproutCore compiler will be used to compile Ember.js
require "sproutcore"
| false |
Other | emberjs | ember.js | fcfe4fd2e146c24d7ed4426d63ded907137bce9d.json | Fix jshint complaint about negation | packages/ember-metal/lib/watching.js | @@ -180,7 +180,7 @@ Wp.copy = function(obj) {
var ret = new ChainNode(null, null, obj, this._separator);
var paths = this._paths, path;
for(path in paths) {
- if (!(paths[path] > 0)) continue; // this check will also catch non-number vals.
+ if (paths[path] <= 0) continue; // this check will also catch non-number vals.
ret.add(path);
}
return ret; | true |
Other | emberjs | ember.js | fcfe4fd2e146c24d7ed4426d63ded907137bce9d.json | Fix jshint complaint about negation | packages/ember-runtime/tests/suites/enumerable/find.js | @@ -32,7 +32,7 @@ suite.test('every should stop invoking when you return true', function() {
exp = cnt,
found = [], result;
- result = obj.find(function(i) { found.push(i); return !(--cnt>0); });
+ result = obj.find(function(i) { found.push(i); return --cnt >= 0; });
equal(result, ary[exp-1], 'return value of obj.find');
equal(found.length, exp, 'should invoke proper number of times');
deepEqual(found, ary.slice(0,-2), 'items passed during find() should match'); | true |
Other | emberjs | ember.js | fcfe4fd2e146c24d7ed4426d63ded907137bce9d.json | Fix jshint complaint about negation | packages/ember-runtime/tests/suites/enumerable/some.js | @@ -31,7 +31,7 @@ suite.test('every should stop invoking when you return true', function() {
exp = cnt,
found = [], result;
- result = obj.some(function(i) { found.push(i); return !(--cnt>0); });
+ result = obj.some(function(i) { found.push(i); return --cnt <= 0; });
equal(result, true, 'return value of obj.some');
equal(found.length, exp, 'should invoke proper number of times');
deepEqual(found, ary.slice(0,-2), 'items passed during some() should match'); | true |
Other | emberjs | ember.js | 625e38267861b3e6e3281808c833ef7f668d543a.json | Fix boolean logic error in view helper assert | packages/ember-handlebars/lib/helpers/view.js | @@ -92,7 +92,7 @@ Ember.Handlebars.ViewHelper = Ember.Object.create({
var viewOptions = {};
if (fn) {
- ember_assert("You cannot provide a template block if you also specified a templateName", !(get(viewOptions, 'templateName')) && !(newView.PrototypeMixin.keys().indexOf('templateName') >= 0));
+ ember_assert("You cannot provide a template block if you also specified a templateName", !(get(viewOptions, 'templateName')) && (newView.PrototypeMixin.keys().indexOf('templateName') >= 0));
viewOptions.template = fn;
}
| false |
Other | emberjs | ember.js | 02cd42b89f76bf4565f9b8aade2996af0b625d61.json | Remove test for deprecation warning | packages/ember-runtime/tests/legacy_1x/system/binding_test.js | @@ -236,16 +236,6 @@ test("Binding value1 such that it will recieve only single values", function() {
equal("@@MULT@@",get(bon1, "array1"));
});
-test("Single binding using notEmpty function.", function() {
- // This should raise an exception for Ember 1.x developers who are using
- // the old syntax.
- raises(function() {
- var bond = Bon1.create ({
- array1Binding: Ember.Binding.single("TestNamespace.bon2.arr").notEmpty(null,'(EMPTY)')
- });
- });
-});
-
test("Binding with transforms, function to check the type of value", function() {
var jon = Bon1.create({
value1Binding: Ember.Binding.transform({ | false |
Other | emberjs | ember.js | dc40aa710789e5789802a9d5045ff5787fc75da4.json | Eliminate vestigial YES and NO | packages/ember-handlebars/lib/helpers/binding.js | @@ -287,7 +287,7 @@ EmberHandlebars.registerHelper('bindAttr', function(options) {
change, the correct class name will be reapplied to the DOM element.
For example, if you pass the string "fooBar", it will first look up the
- "fooBar" value of the context. If that value is YES, it will add the
+ "fooBar" value of the context. If that value is true, it will add the
"foo-bar" class to the current element (i.e., the dasherized form of
"fooBar"). If the value is a string, it will add that string as the class.
Otherwise, it will not add any new class name.
@@ -331,7 +331,7 @@ EmberHandlebars.bindClasses = function(context, classBindings, view, bindAttrId)
var parts = property.split('.');
return Ember.String.dasherize(parts[parts.length-1]);
- // If the value is not NO, undefined, or null, return the current
+ // If the value is not false, undefined, or null, return the current
// value of the property.
} else if (val !== false && val !== undefined && val !== null) {
return val; | true |
Other | emberjs | ember.js | dc40aa710789e5789802a9d5045ff5787fc75da4.json | Eliminate vestigial YES and NO | packages/ember-handlebars/lib/views/bindable_span.js | @@ -43,7 +43,7 @@ Ember._BindableSpanView = Ember.View.extend(Ember.Metamorph,
For example, this is true when using the `{{#if}}` helper, because the
template inside the helper should look up properties relative to the same
- object as outside the block. This would be NO when used with `{{#with
+ object as outside the block. This would be false when used with `{{#with
foo}}` because the template should receive the object found by evaluating
`foo`.
| true |
Other | emberjs | ember.js | dc40aa710789e5789802a9d5045ff5787fc75da4.json | Eliminate vestigial YES and NO | packages/ember-handlebars/tests/controls/text_area_test.js | @@ -150,11 +150,11 @@ test("should call the cancel method when escape key is pressed", function() {
// textArea.insertNewline = function() {
// insertNewlineCalled++;
-// return YES;
+// return true;
// };
// textArea.cancel = function() {
// cancelCalled++;
-// return YES;
+// return true;
// };
// textArea.$().focus(); | true |
Other | emberjs | ember.js | dc40aa710789e5789802a9d5045ff5787fc75da4.json | Eliminate vestigial YES and NO | packages/ember-handlebars/tests/controls/text_field_test.js | @@ -159,11 +159,11 @@ test("should call the cancel method when escape key is pressed", function() {
// textField.insertNewline = function() {
// insertNewlineCalled++;
-// return YES;
+// return true;
// };
// textField.cancel = function() {
// cancelCalled++;
-// return YES;
+// return true;
// };
// textField.$().focus(); | true |
Other | emberjs | ember.js | dc40aa710789e5789802a9d5045ff5787fc75da4.json | Eliminate vestigial YES and NO | packages/ember-metal/lib/binding.js | @@ -240,7 +240,7 @@ Binding.prototype = /** @scope Ember.Binding.prototype */ {
@param {Boolean} flag
(Optional) passing nothing here will make the binding oneWay. You can
- instead pass NO to disable oneWay, making the binding two way again.
+ instead pass false to disable oneWay, making the binding two way again.
@returns {Ember.Binding} receiver
*/
@@ -332,8 +332,8 @@ Binding.prototype = /** @scope Ember.Binding.prototype */ {
/**
Adds a transform to convert the value to a bool value. If the value is
- an array it will return YES if array is not empty. If the value is a
- string it will return YES if the string is not empty.
+ an array it will return true if array is not empty. If the value is a
+ string it will return true if the string is not empty.
@returns {Ember.Binding} this
*/
@@ -393,7 +393,7 @@ Binding.prototype = /** @scope Ember.Binding.prototype */ {
},
/**
- Adds a transform that will return YES if the value is null or undefined, NO otherwise.
+ Adds a transform that will return true if the value is null or undefined, false otherwise.
@returns {Ember.Binding} this
*/ | true |
Other | emberjs | ember.js | dc40aa710789e5789802a9d5045ff5787fc75da4.json | Eliminate vestigial YES and NO | packages/ember-metal/lib/utils.js | @@ -299,7 +299,7 @@ Ember.wrap = function(func, superFunc) {
/**
@function
- Returns YES if the passed object is an array or Array-like.
+ Returns true if the passed object is an array or Array-like.
Ember Array Protocol:
| true |
Other | emberjs | ember.js | dc40aa710789e5789802a9d5045ff5787fc75da4.json | Eliminate vestigial YES and NO | packages/ember-runtime/lib/core.js | @@ -11,24 +11,6 @@ require('ember-metal');
// GLOBAL CONSTANTS
//
-/**
- @name YES
- @static
- @type Boolean
- @default true
- @constant
-*/
-YES = true;
-
-/**
- @name NO
- @static
- @type Boolean
- @default NO
- @constant
-*/
-NO = false;
-
// ensure no undefined errors in browsers where console doesn't exist
if (typeof console === 'undefined') {
window.console = {};
@@ -42,7 +24,7 @@ if (typeof console === 'undefined') {
/**
@static
@type Boolean
- @default YES
+ @default true
@constant
Determines whether Ember should enhances some built-in object
@@ -108,7 +90,7 @@ Ember.typeOf = function(item) {
};
/**
- Returns YES if the passed value is null or undefined. This avoids errors
+ Returns true if the passed value is null or undefined. This avoids errors
from JSLint complaining about use of ==, which can be technically
confusing.
| true |
Other | emberjs | ember.js | dc40aa710789e5789802a9d5045ff5787fc75da4.json | Eliminate vestigial YES and NO | packages/ember-runtime/lib/mixins/comparable.js | @@ -24,7 +24,7 @@ Ember.Comparable = Ember.Mixin.create( /** @scope Ember.Comparable.prototype */{
walk like a duck. Indicates that the object can be compared.
@type Boolean
- @default YES
+ @default true
@constant
*/
isComparable: true, | true |
Other | emberjs | ember.js | dc40aa710789e5789802a9d5045ff5787fc75da4.json | Eliminate vestigial YES and NO | packages/ember-runtime/lib/mixins/enumerable.js | @@ -298,7 +298,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
/**
Returns an array with all of the items in the enumeration that the passed
- function returns YES for. This method corresponds to filter() defined in
+ function returns true for. This method corresponds to filter() defined in
JavaScript 1.6.
The callback method you provide should have the following signature (all
@@ -310,7 +310,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
- *index* is the current index in the iteration
- *enumerable* is the enumerable object itself.
- It should return the YES to include the item in the results, NO otherwise.
+ It should return the true to include the item in the results, false otherwise.
Note that in addition to a callback, you can also pass an optional target
object that will be set as "this" on the context. This is a good way
@@ -342,7 +342,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
},
/**
- Returns the first item in the array for which the callback returns YES.
+ Returns the first item in the array for which the callback returns true.
This method works similar to the filter() method defined in JavaScript 1.6
except that it will stop working on the array once a match is found.
@@ -355,7 +355,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
- *index* is the current index in the iteration
- *enumerable* is the enumerable object itself.
- It should return the YES to include the item in the results, NO otherwise.
+ It should return the true to include the item in the results, false otherwise.
Note that in addition to a callback, you can also pass an optional target
object that will be set as "this" on the context. This is a good way
@@ -397,7 +397,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
},
/**
- Returns YES if the passed function returns YES for every item in the
+ Returns true if the passed function returns true for every item in the
enumeration. This corresponds with the every() method in JavaScript 1.6.
The callback method you provide should have the following signature (all
@@ -409,7 +409,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
- *index* is the current index in the iteration
- *enumerable* is the enumerable object itself.
- It should return the YES or NO.
+ It should return the true or false.
Note that in addition to a callback, you can also pass an optional target
object that will be set as "this" on the context. This is a good way
@@ -443,7 +443,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
/**
- Returns YES if the passed function returns true for any item in the
+ Returns true if the passed function returns true for any item in the
enumeration. This corresponds with the every() method in JavaScript 1.6.
The callback method you provide should have the following signature (all
@@ -455,7 +455,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
- *index* is the current index in the iteration
- *enumerable* is the enumerable object itself.
- It should return the YES to include the item in the results, NO otherwise.
+ It should return the true to include the item in the results, false otherwise.
Note that in addition to a callback, you can also pass an optional target
object that will be set as "this" on the context. This is a good way | true |
Other | emberjs | ember.js | dc40aa710789e5789802a9d5045ff5787fc75da4.json | Eliminate vestigial YES and NO | packages/ember-runtime/lib/mixins/freezable.js | @@ -71,7 +71,7 @@ Ember.Freezable = Ember.Mixin.create(
/** @scope Ember.Freezable.prototype */ {
/**
- Set to YES when the object is frozen. Use this property to detect whether
+ Set to true when the object is frozen. Use this property to detect whether
your object is frozen or not.
@property {Boolean} | true |
Other | emberjs | ember.js | dc40aa710789e5789802a9d5045ff5787fc75da4.json | Eliminate vestigial YES and NO | packages/ember-runtime/lib/mixins/observable.js | @@ -297,7 +297,7 @@ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ {
},
/**
- Returns YES if the object currently has observers registered for a
+ Returns true if the object currently has observers registered for a
particular key. You can use this method to potentially defer performing
an expensive action until someone begins observing a particular property
on the object. | true |
Other | emberjs | ember.js | dc40aa710789e5789802a9d5045ff5787fc75da4.json | Eliminate vestigial YES and NO | packages/ember-runtime/tests/legacy_1x/mixins/observable/observable_test.js | @@ -513,13 +513,13 @@ test("change dependent should clear cache when observers of dependent are called
test('setting one of two computed properties that depend on a third property should clear the kvo cache', function() {
// we have to call set twice to fill up the cache
- object.set('isOff', YES);
- object.set('isOn', YES);
+ object.set('isOff', true);
+ object.set('isOn', true);
- // setting isOff to YES should clear the kvo cache
- object.set('isOff', YES);
- equal(object.get('isOff'), YES, 'object.isOff should be YES');
- equal(object.get('isOn'), NO, 'object.isOn should be NO');
+ // setting isOff to true should clear the kvo cache
+ object.set('isOff', true);
+ equal(object.get('isOff'), true, 'object.isOff should be true');
+ equal(object.get('isOn'), false, 'object.isOn should be false');
});
test("dependent keys should be able to be specified as property paths", function() {
@@ -801,17 +801,17 @@ test("should unregister an observer for a property - special case when key has a
test("removing an observer inside of an observer shouldn’t cause any problems", function() {
// The observable system should be protected against clients removing
// observers in the middle of observer notification.
- var encounteredError = NO;
+ var encounteredError = false;
try {
ObjectD.addObserver('observableValue', null, 'observer1');
ObjectD.addObserver('observableValue', null, 'observer2');
ObjectD.addObserver('observableValue', null, 'observer3');
Ember.run(function() { ObjectD.set('observableValue', "hi world"); });
}
catch(e) {
- encounteredError = YES;
+ encounteredError = true;
}
- equal(encounteredError, NO);
+ equal(encounteredError, false);
});
| true |
Other | emberjs | ember.js | dc40aa710789e5789802a9d5045ff5787fc75da4.json | Eliminate vestigial YES and NO | packages/ember-runtime/tests/legacy_1x/mixins/observable/propertyChanges_test.js | @@ -27,7 +27,7 @@
var ObservableObject = Ember.Object.extend(Ember.Observable);
-var revMatches = NO , ObjectA;
+var revMatches = false , ObjectA;
module("object.propertyChanges", {
setup: function() { | true |
Other | emberjs | ember.js | dc40aa710789e5789802a9d5045ff5787fc75da4.json | Eliminate vestigial YES and NO | packages/ember-runtime/tests/legacy_1x/system/binding_test.js | @@ -182,7 +182,7 @@ test("changing first output should propograte to third after flush", function()
equal("change", get(first, "output"), "first.output") ;
ok("change" !== get(third, "input"), "third.input") ;
- var didChange = YES;
+ var didChange = true;
while(didChange) didChange = Ember.run.sync() ;
equal("change", get(first, "output"), "first.output") ;
@@ -301,8 +301,8 @@ module("AND binding", {
setup: function() {
// temporarily set up two source objects in the Ember namespace so we can
// use property paths to access them
- Ember.set(Ember, 'testControllerA', Ember.Object.create({ value: NO }));
- Ember.set(Ember, 'testControllerB', Ember.Object.create({ value: NO }));
+ Ember.set(Ember, 'testControllerA', Ember.Object.create({ value: false }));
+ Ember.set(Ember, 'testControllerB', Ember.Object.create({ value: false }));
toObject = Ember.Object.create({
value: null,
@@ -317,40 +317,40 @@ module("AND binding", {
});
-test("toObject.value should be YES if both sources are YES", function() {
+test("toObject.value should be true if both sources are true", function() {
Ember.RunLoop.begin();
- set(Ember.testControllerA, 'value', YES);
- set(Ember.testControllerB, 'value', YES);
+ set(Ember.testControllerA, 'value', true);
+ set(Ember.testControllerB, 'value', true);
Ember.RunLoop.end();
Ember.run.sync();
- equal(get(toObject, 'value'), YES);
+ equal(get(toObject, 'value'), true);
});
-test("toObject.value should be NO if either source is NO", function() {
+test("toObject.value should be false if either source is false", function() {
Ember.RunLoop.begin();
- set(Ember.testControllerA, 'value', YES);
- set(Ember.testControllerB, 'value', NO);
+ set(Ember.testControllerA, 'value', true);
+ set(Ember.testControllerB, 'value', false);
Ember.RunLoop.end();
Ember.run.sync();
- equal(get(toObject, 'value'), NO);
+ equal(get(toObject, 'value'), false);
Ember.RunLoop.begin();
- set(Ember.testControllerA, 'value', YES);
- set(Ember.testControllerB, 'value', YES);
+ set(Ember.testControllerA, 'value', true);
+ set(Ember.testControllerB, 'value', true);
Ember.RunLoop.end();
Ember.run.sync();
- equal(get(toObject, 'value'), YES);
+ equal(get(toObject, 'value'), true);
Ember.RunLoop.begin();
- set(Ember.testControllerA, 'value', NO);
- set(Ember.testControllerB, 'value', YES);
+ set(Ember.testControllerA, 'value', false);
+ set(Ember.testControllerB, 'value', true);
Ember.RunLoop.end();
Ember.run.sync();
- equal(get(toObject, 'value'), NO);
+ equal(get(toObject, 'value'), false);
});
// ..........................................................
@@ -362,7 +362,7 @@ module("OR binding", {
setup: function() {
// temporarily set up two source objects in the Ember namespace so we can
// use property paths to access them
- Ember.set(Ember, 'testControllerA', Ember.Object.create({ value: NO }));
+ Ember.set(Ember, 'testControllerA', Ember.Object.create({ value: false }));
Ember.set(Ember, 'testControllerB', Ember.Object.create({ value: null }));
toObject = Ember.Object.create({
@@ -390,7 +390,7 @@ test("toObject.value should be first value if first value is truthy", function()
test("toObject.value should be second value if first is falsy", function() {
Ember.RunLoop.begin();
- set(Ember.testControllerA, 'value', NO);
+ set(Ember.testControllerA, 'value', false);
set(Ember.testControllerB, 'value', 'second value');
Ember.RunLoop.end();
| true |
Other | emberjs | ember.js | dc40aa710789e5789802a9d5045ff5787fc75da4.json | Eliminate vestigial YES and NO | packages/ember-runtime/tests/legacy_1x/system/object/base_test.js | @@ -49,7 +49,7 @@ module("A new Ember.Object instance", {
aMethodThatExists: function() {},
aMethodThatReturnsTrue: function() { return true; },
aMethodThatReturnsFoobar: function() { return "Foobar"; },
- aMethodThatReturnsFalse: function() { return NO; }
+ aMethodThatReturnsFalse: function() { return false; }
});
},
@@ -91,37 +91,37 @@ module("Ember.Object observers", {
// normal observer
observer: Ember.observer(function(){
- this._normal = YES;
+ this._normal = true;
}, "prop1"),
globalObserver: Ember.observer(function() {
- this._global = YES;
+ this._global = true;
}, "TestNamespace.obj.value"),
bothObserver: Ember.observer(function() {
- this._both = YES;
+ this._both = true;
}, "prop1", "TestNamespace.obj.value")
});
}
});
test("Local observers work", function() {
- obj._normal = NO;
- set(obj, "prop1", NO);
- equal(obj._normal, YES, "Normal observer did change.");
+ obj._normal = false;
+ set(obj, "prop1", false);
+ equal(obj._normal, true, "Normal observer did change.");
});
test("Global observers work", function() {
- obj._global = NO;
+ obj._global = false;
set(TestNamespace.obj, "value", "test2");
- equal(obj._global, YES, "Global observer did change.");
+ equal(obj._global, true, "Global observer did change.");
});
test("Global+Local observer works", function() {
- obj._both = NO;
- set(obj, "prop1", NO);
- equal(obj._both, YES, "Both observer did change.");
+ obj._both = false;
+ set(obj, "prop1", false);
+ equal(obj._both, true, "Both observer did change.");
});
@@ -149,8 +149,8 @@ module("Ember.Object superclass and subclasses", {
});
test("Checking the detect() function on an object and its subclass", function(){
- equal(obj.detect(obj1), YES);
- equal(obj1.detect(obj), NO);
+ equal(obj.detect(obj1), true);
+ equal(obj1.detect(obj), false);
});
test("Checking the detectInstance() function on an object and its subclass", function() { | true |
Other | emberjs | ember.js | dc40aa710789e5789802a9d5045ff5787fc75da4.json | Eliminate vestigial YES and NO | packages/ember-runtime/tests/legacy_1x/system/object/bindings_test.js | @@ -91,12 +91,12 @@ test("Ember.Binding.bool(TestNamespace.fromObject.bar)) should create binding wi
set(fromObject, "bar", 1) ;
Ember.run.sync();
- equal(YES, get(testObject, "foo"), "testObject.foo == YES");
+ equal(true, get(testObject, "foo"), "testObject.foo == true");
set(fromObject, "bar", 0) ;
Ember.run.sync();
- equal(NO, get(testObject, "foo"), "testObject.foo == NO");
+ equal(false, get(testObject, "foo"), "testObject.foo == false");
});
test("bind(TestNamespace.fromObject*extraObject.foo) should create chained binding", function() {
@@ -205,12 +205,12 @@ test("fooBinding: Ember.Binding.bool(TestNamespace.fromObject.bar should create
set(fromObject, "bar", 1) ;
Ember.run.sync();
- equal(YES, get(testObject, "foo"), "testObject.foo == YES");
+ equal(true, get(testObject, "foo"), "testObject.foo == true");
set(fromObject, "bar", 0) ;
Ember.run.sync();
- equal(NO, get(testObject, "foo"), "testObject.foo == NO");
+ equal(false, get(testObject, "foo"), "testObject.foo == false");
});
test("fooBinding: TestNamespace.fromObject*extraObject.foo should create chained binding", function() {
@@ -295,12 +295,12 @@ test("fooBinding: TestNamespace.fromObject.bar should have bool binding", functi
set(fromObject, "bar", 1) ;
Ember.run.sync();
- equal(YES, get(testObject, "foo"), "testObject.foo == YES");
+ equal(true, get(testObject, "foo"), "testObject.foo == true");
set(fromObject, "bar", 0) ;
Ember.run.sync();
- equal(NO, get(testObject, "foo"), "testObject.foo == NO");
+ equal(false, get(testObject, "foo"), "testObject.foo == false");
});
test("fooBinding: Ember.Binding.not(TestNamespace.fromObject.bar should override default", function() {
@@ -314,12 +314,12 @@ test("fooBinding: Ember.Binding.not(TestNamespace.fromObject.bar should override
set(fromObject, "bar", 1) ;
Ember.run.sync();
- equal(NO, get(testObject, "foo"), "testObject.foo == NO");
+ equal(false, get(testObject, "foo"), "testObject.foo == false");
set(fromObject, "bar", 0) ;
Ember.run.sync();
- equal(YES, get(testObject, "foo"), "testObject.foo == YES");
+ equal(true, get(testObject, "foo"), "testObject.foo == true");
});
module("fooBindingDefault: Ember.Binding.bool() (new style)", {
@@ -361,12 +361,12 @@ test("fooBinding: TestNamespace.fromObject.bar should have bool binding", functi
set(fromObject, "bar", 1) ;
Ember.run.sync();
- equal(YES, get(testObject, "foo"), "testObject.foo == YES");
+ equal(true, get(testObject, "foo"), "testObject.foo == true");
set(fromObject, "bar", 0) ;
Ember.run.sync();
- equal(NO, get(testObject, "foo"), "testObject.foo == NO");
+ equal(false, get(testObject, "foo"), "testObject.foo == false");
});
test("fooBinding: Ember.Binding.not(TestNamespace.fromObject.bar should override default", function() {
@@ -380,12 +380,12 @@ test("fooBinding: Ember.Binding.not(TestNamespace.fromObject.bar should override
set(fromObject, "bar", 1) ;
Ember.run.sync();
- equal(NO, get(testObject, "foo"), "testObject.foo == NO");
+ equal(false, get(testObject, "foo"), "testObject.foo == false");
set(fromObject, "bar", 0) ;
Ember.run.sync();
- equal(YES, get(testObject, "foo"), "testObject.foo == YES");
+ equal(true, get(testObject, "foo"), "testObject.foo == true");
});
test("Chained binding should be null if intermediate object in chain is null", function() { | true |
Other | emberjs | ember.js | dc40aa710789e5789802a9d5045ff5787fc75da4.json | Eliminate vestigial YES and NO | packages/ember-runtime/tests/legacy_1x/system/set_test.js | @@ -43,9 +43,9 @@ test("Ember.Set.create() should create empty set", function() {
test("Ember.Set.create([1,2,3]) should create set with three items in them", function() {
var set = Ember.Set.create(Ember.A([a,b,c])) ;
equal(set.length, 3) ;
- equal(set.contains(a), YES) ;
- equal(set.contains(b), YES) ;
- equal(set.contains(c), YES) ;
+ equal(set.contains(a), true) ;
+ equal(set.contains(b), true) ;
+ equal(set.contains(c), true) ;
});
test("Ember.Set.create() should accept anything that implements Ember.Array", function() {
@@ -57,9 +57,9 @@ test("Ember.Set.create() should accept anything that implements Ember.Array", fu
var set = Ember.Set.create(arrayLikeObject) ;
equal(set.length, 3) ;
- equal(set.contains(a), YES) ;
- equal(set.contains(b), YES) ;
- equal(set.contains(c), YES) ;
+ equal(set.contains(a), true) ;
+ equal(set.contains(b), true) ;
+ equal(set.contains(c), true) ;
});
var set ; // global variables
@@ -83,7 +83,7 @@ test("should add an Ember.Object", function() {
var oldLength = set.length ;
set.add(obj) ;
- equal(set.contains(obj), YES, "contains()") ;
+ equal(set.contains(obj), true, "contains()") ;
equal(set.length, oldLength+1, "new set length") ;
});
@@ -92,7 +92,7 @@ test("should add a regular hash", function() {
var oldLength = set.length ;
set.add(obj) ;
- equal(set.contains(obj), YES, "contains()") ;
+ equal(set.contains(obj), true, "contains()") ;
equal(set.length, oldLength+1, "new set length") ;
});
@@ -101,7 +101,7 @@ test("should add a string", function() {
var oldLength = set.length ;
set.add(obj) ;
- equal(set.contains(obj), YES, "contains()") ;
+ equal(set.contains(obj), true, "contains()") ;
equal(set.length, oldLength+1, "new set length") ;
});
@@ -110,27 +110,27 @@ test("should add a number", function() {
var oldLength = set.length ;
set.add(obj) ;
- equal(set.contains(obj), YES, "contains()") ;
+ equal(set.contains(obj), true, "contains()") ;
equal(set.length, oldLength+1, "new set length") ;
});
test("should add bools", function() {
var oldLength = set.length ;
set.add(true) ;
- equal(set.contains(true), YES, "contains(true)");
+ equal(set.contains(true), true, "contains(true)");
equal(set.length, oldLength+1, "new set length");
set.add(false);
- equal(set.contains(false), YES, "contains(false)");
+ equal(set.contains(false), true, "contains(false)");
equal(set.length, oldLength+2, "new set length");
});
test("should add 0", function() {
var oldLength = set.length ;
set.add(0) ;
- equal(set.contains(0), YES, "contains(0)");
+ equal(set.contains(0), true, "contains(0)");
equal(set.length, oldLength+1, "new set length");
});
@@ -139,20 +139,20 @@ test("should add a function", function() {
var oldLength = set.length ;
set.add(obj) ;
- equal(set.contains(obj), YES, "contains()") ;
+ equal(set.contains(obj), true, "contains()") ;
equal(set.length, oldLength+1, "new set length") ;
});
test("should NOT add a null", function() {
set.add(null) ;
equal(set.length, 0) ;
- equal(set.contains(null), NO) ;
+ equal(set.contains(null), false) ;
});
test("should NOT add an undefined", function() {
set.add(undefined) ;
equal(set.length, 0) ;
- equal(set.contains(undefined), NO) ;
+ equal(set.contains(undefined), false) ;
});
test("adding an item, removing it, adding another item", function() {
@@ -163,7 +163,7 @@ test("adding an item, removing it, adding another item", function() {
set.remove(item1) ; //remove from set
set.add(item2) ;
- equal(set.contains(item1), NO, "set.contains(item1)") ;
+ equal(set.contains(item1), false, "set.contains(item1)") ;
set.add(item1) ; // re-add to set
equal(set.length, 2, "set.length") ;
@@ -175,8 +175,8 @@ module("Ember.Set.remove + Ember.Set.contains", {
// ones we add in the tests below...
setup: function() {
set = Ember.Set.create(Ember.A([
- Ember.Object.create({ dummy: YES }),
- { isHash: YES },
+ Ember.Object.create({ dummy: true }),
+ { isHash: true },
"Not the String",
16, true, false, 0])) ;
},
@@ -190,73 +190,73 @@ module("Ember.Set.remove + Ember.Set.contains", {
test("should remove an Ember.Object and reduce length", function() {
var obj = Ember.Object.create() ;
set.add(obj) ;
- equal(set.contains(obj), YES) ;
+ equal(set.contains(obj), true) ;
var oldLength = set.length ;
set.remove(obj) ;
- equal(set.contains(obj), NO, "should be removed") ;
+ equal(set.contains(obj), false, "should be removed") ;
equal(set.length, oldLength-1, "should be 1 shorter") ;
});
test("should remove a regular hash and reduce length", function() {
var obj = {} ;
set.add(obj) ;
- equal(set.contains(obj), YES) ;
+ equal(set.contains(obj), true) ;
var oldLength = set.length ;
set.remove(obj) ;
- equal(set.contains(obj), NO, "should be removed") ;
+ equal(set.contains(obj), false, "should be removed") ;
equal(set.length, oldLength-1, "should be 1 shorter") ;
});
test("should remove a string and reduce length", function() {
var obj = "String!" ;
set.add(obj) ;
- equal(set.contains(obj), YES) ;
+ equal(set.contains(obj), true) ;
var oldLength = set.length ;
set.remove(obj) ;
- equal(set.contains(obj), NO, "should be removed") ;
+ equal(set.contains(obj), false, "should be removed") ;
equal(set.length, oldLength-1, "should be 1 shorter") ;
});
test("should remove a number and reduce length", function() {
var obj = 23 ;
set.add(obj) ;
- equal(set.contains(obj), YES) ;
+ equal(set.contains(obj), true) ;
var oldLength = set.length ;
set.remove(obj) ;
- equal(set.contains(obj), NO, "should be removed") ;
+ equal(set.contains(obj), false, "should be removed") ;
equal(set.length, oldLength-1, "should be 1 shorter") ;
});
test("should remove a bools and reduce length", function() {
var oldLength = set.length ;
set.remove(true) ;
- equal(set.contains(true), NO, "should be removed") ;
+ equal(set.contains(true), false, "should be removed") ;
equal(set.length, oldLength-1, "should be 1 shorter") ;
set.remove(false);
- equal(set.contains(false), NO, "should be removed") ;
+ equal(set.contains(false), false, "should be removed") ;
equal(set.length, oldLength-2, "should be 2 shorter") ;
});
test("should remove 0 and reduce length", function(){
var oldLength = set.length;
set.remove(0) ;
- equal(set.contains(0), NO, "should be removed") ;
+ equal(set.contains(0), false, "should be removed") ;
equal(set.length, oldLength-1, "should be 1 shorter") ;
});
test("should remove a function and reduce length", function() {
var obj = function() { return "Test function"; } ;
set.add(obj) ;
- equal(set.contains(obj), YES) ;
+ equal(set.contains(obj), true) ;
var oldLength = set.length ;
set.remove(obj) ;
- equal(set.contains(obj), NO, "should be removed") ;
+ equal(set.contains(obj), false, "should be removed") ;
equal(set.length, oldLength-1, "should be 1 shorter") ;
});
@@ -293,8 +293,8 @@ module("Ember.Set.pop + Ember.Set.copy", {
// ones we add in the tests below...
setup: function() {
set = Ember.Set.create(Ember.A([
- Ember.Object.create({ dummy: YES }),
- { isHash: YES },
+ Ember.Object.create({ dummy: true }),
+ { isHash: true },
"Not the String",
16, false])) ;
},
@@ -323,9 +323,9 @@ test("the copy() should return an indentical set", function() {
var oldLength = set.length ;
var obj = set.copy();
equal(oldLength,obj.length,'length of the clone should be same');
- equal(obj.contains(set[0]), YES);
- equal(obj.contains(set[1]), YES);
- equal(obj.contains(set[2]), YES);
- equal(obj.contains(set[3]), YES);
- equal(obj.contains(set[4]), YES);
+ equal(obj.contains(set[0]), true);
+ equal(obj.contains(set[1]), true);
+ equal(obj.contains(set[2]), true);
+ equal(obj.contains(set[3]), true);
+ equal(obj.contains(set[4]), true);
}); | true |
Other | emberjs | ember.js | dc40aa710789e5789802a9d5045ff5787fc75da4.json | Eliminate vestigial YES and NO | packages/ember-views/lib/views/view.js | @@ -51,10 +51,10 @@ Ember.View = Ember.Object.extend(
/**
@type Boolean
- @default YES
+ @default true
@constant
*/
- isView: YES,
+ isView: true,
// ..........................................................
// TEMPLATE SUPPORT
@@ -513,7 +513,7 @@ Ember.View = Ember.Object.extend(
// If value is a Boolean and true, return the dasherized property
// name.
- if (val === YES) {
+ if (val === true) {
if (className) { return className; }
// Normalize property path to be suitable for use
@@ -522,9 +522,9 @@ Ember.View = Ember.Object.extend(
var parts = property.split('.');
return Ember.String.dasherize(parts[parts.length-1]);
- // If the value is not NO, undefined, or null, return the current
+ // If the value is not false, undefined, or null, return the current
// value of the property.
- } else if (val !== NO && val !== undefined && val !== null) {
+ } else if (val !== false && val !== undefined && val !== null) {
return val;
// Nothing to display. Return null so that the old class is removed | true |
Other | emberjs | ember.js | dc40aa710789e5789802a9d5045ff5787fc75da4.json | Eliminate vestigial YES and NO | packages/ember-views/tests/views/view/create_child_view_test.js | @@ -11,7 +11,7 @@ var view, myViewClass ;
module("Ember.View#createChildView", {
setup: function() {
view = Ember.View.create();
- myViewClass = Ember.View.extend({ isMyView: YES, foo: 'bar' });
+ myViewClass = Ember.View.extend({ isMyView: true, foo: 'bar' });
}
});
| true |
Other | emberjs | ember.js | 672e25b8d901a9973fce139fcf687b94382e16ab.json | Add Handlebars helper for {{yield}} | packages/ember-handlebars/lib/helpers.js | @@ -11,4 +11,5 @@ require("ember-handlebars/helpers/unbound");
require("ember-handlebars/helpers/debug");
require("ember-handlebars/helpers/each");
require("ember-handlebars/helpers/template");
-require("ember-handlebars/helpers/action");
\ No newline at end of file
+require("ember-handlebars/helpers/action");
+require("ember-handlebars/helpers/yield"); | true |
Other | emberjs | ember.js | 672e25b8d901a9973fce139fcf687b94382e16ab.json | Add Handlebars helper for {{yield}} | packages/ember-handlebars/lib/helpers/yield.js | @@ -0,0 +1,16 @@
+var get = Ember.get, set = Ember.set;
+
+Ember.Handlebars.registerHelper('yield', function(options) {
+ var view = options.data.view, template;
+
+ while (view && !get(view, 'layout')) {
+ view = get(view, 'parentView');
+ }
+
+ ember_assert("You called yield in a template that was not a layout", !!view);
+
+ template = get(view, 'template');
+
+ ember_assert("You called yield on " + view.toString() + " without supplying a template", !!template);
+ template(this, options);
+}); | true |
Other | emberjs | ember.js | 672e25b8d901a9973fce139fcf687b94382e16ab.json | Add Handlebars helper for {{yield}} | packages/ember-handlebars/tests/helpers/yield_test.js | @@ -0,0 +1,104 @@
+// ==========================================================================
+// Project: Ember Handlebar Views
+// Copyright: ©2011 Strobe Inc. and contributors.
+// License: Licensed under MIT license (see license.js)
+// ==========================================================================
+/*global TemplateTests*/
+
+var set = Ember.set, get = Ember.get, setPath = Ember.setPath, getPath = Ember.getPath;
+
+var view;
+
+module("Support for {{yield}} helper (#307)", {
+ setup: function() {
+ window.TemplateTests = Ember.Namespace.create();
+ },
+ teardown: function() {
+ if (view) {
+ view.destroy();
+ }
+
+ window.TemplateTests = undefined;
+ }
+});
+
+test("a view with a layout set renders its template where the {{yield}} helper appears", function() {
+ TemplateTests.ViewWithLayout = Ember.View.extend({
+ layout: Ember.Handlebars.compile('<div class="wrapper"><h1>{{title}}</h1>{{yield}}</div>')
+ });
+
+ view = Ember.View.create({
+ template: Ember.Handlebars.compile('{{#view TemplateTests.ViewWithLayout title="My Fancy Page"}}<div class="page-body">Show something interesting here</div>{{/view}}')
+ });
+
+ Ember.run(function() {
+ view.appendTo('#qunit-fixture');
+ });
+
+ equal(view.$('div.wrapper div.page-body').length, 1, 'page-body is embedded within wrapping my-page');
+});
+
+test("block should work properly even when templates are not hard-coded", function() {
+ var templates = Ember.Object.create({
+ nester: Ember.Handlebars.compile('<div class="wrapper"><h1>{{title}}</h1>{{yield}}</div>'),
+ nested: Ember.Handlebars.compile('{{#view TemplateTests.ViewWithLayout title="My Fancy Page"}}<div class="page-body">Show something interesting here</div>{{/view}}')
+ });
+
+ TemplateTests.ViewWithLayout = Ember.View.extend({
+ layoutName: 'nester',
+ templates: templates
+ });
+
+ view = Ember.View.create({
+ templateName: 'nested',
+ templates: templates
+ });
+
+ Ember.run(function() {
+ view.appendTo('#qunit-fixture');
+ });
+
+ equal(view.$('div.wrapper div.page-body').length, 1, 'page-body is embedded within wrapping my-page');
+
+});
+
+test("templates should yield to block, when the yield is embedded in a hierarchy of virtual views", function() {
+ TemplateTests.TimesView = Ember.View.extend({
+ layout: Ember.Handlebars.compile('<div class="times">{{#each index}}{{debugger}}{{yield}}{{/each}}</div>'),
+ n: null,
+ index: Ember.computed(function() {
+ var n = Ember.get(this, 'n'), indexArray = Ember.A([]);
+ for (var i=0; i < n; i++) {
+ indexArray[i] = i;
+ }
+ return indexArray;
+ }).property().cacheable()
+ });
+
+ view = Ember.View.create({
+ template: Ember.Handlebars.compile('<div id="container"><div class="title">Counting to 5</div>{{#view TemplateTests.TimesView n=5}}<div class="times-item">Hello</div>{{/view}}</div>')
+ });
+
+ Ember.run(function() {
+ view.appendTo('#qunit-fixture');
+ });
+
+ equal(view.$('div#container div.times-item').length, 5, 'times-item is embedded within wrapping container 5 times, as expected');
+});
+
+test("templates should yield to block, when the yield is embedded in a hierarchy of non-virtual views", function() {
+ TemplateTests.NestingView = Ember.View.extend({
+ layout: Ember.Handlebars.compile('{{#view Ember.View tagName="div" classNames="nesting"}}{{yield}}{{/view}}')
+ });
+
+ view = Ember.View.create({
+ template: Ember.Handlebars.compile('<div id="container">{{#view TemplateTests.NestingView}}<div id="block">Hello</div>{{/view}}</div>')
+ });
+
+ Ember.run(function() {
+ view.appendTo('#qunit-fixture');
+ });
+
+ equal(view.$('div#container div.nesting div#block').length, 1, 'nesting view yields correctly even within a view hierarchy in the nesting view');
+});
+ | true |
Other | emberjs | ember.js | ee81cf79c6cac90e2ef60936c7ea6c5f1ba20466.json | Add a .jshintrc | .jshintrc | @@ -0,0 +1,52 @@
+{
+ "predef": [
+ "jasmine",
+ "spyOn",
+ "it",
+ "console",
+ "describe",
+ "expect",
+ "beforeEach",
+ "waits",
+ "waitsFor",
+ "runs",
+ "Ember",
+ "DS",
+ "ember_assert",
+ "require",
+ "equal",
+ "test",
+ "raises",
+ "deepEqual",
+ "start",
+ "stop",
+ "ok",
+ "strictEqual"
+ ],
+
+ "node" : true,
+ "es5" : true,
+ "browser" : true,
+
+ "boss" : false,
+ "curly": false,
+ "debug": false,
+ "devel": false,
+ "eqeqeq": true,
+ "evil": true,
+ "forin": false,
+ "immed": true,
+ "laxbreak": false,
+ "newcap": true,
+ "noarg": true,
+ "noempty": false,
+ "nonew": false,
+ "nomen": false,
+ "onevar": false,
+ "plusplus": false,
+ "regexp": false,
+ "undef": true,
+ "sub": true,
+ "strict": false,
+ "white": false
+} | false |
Other | emberjs | ember.js | 4331b5365034565ae1fadffb0a824c9e4967a00d.json | Add layout support to Ember.View | packages/ember-views/lib/views/view.js | @@ -72,6 +72,18 @@ Ember.View = Ember.Object.extend(
*/
templateName: null,
+ /**
+ The name of the layout to lookup if no layout is provided.
+
+ Ember.View will look for a template with this name in this view's
+ `templates` object. By default, this will be a global object
+ shared in `Ember.TEMPLATES`.
+
+ @type String
+ @default null
+ */
+ layoutName: null,
+
/**
The hash in which to look for `templateName`.
@@ -94,25 +106,46 @@ Ember.View = Ember.Object.extend(
template: Ember.computed(function(key, value) {
if (value !== undefined) { return value; }
- var templateName = get(this, 'templateName'), template;
+ var templateName = get(this, 'templateName'),
+ template = this.templateForName(templateName, 'template');
- if (templateName) { template = get(get(this, 'templates'), templateName); }
+ return template || get(this, 'defaultTemplate');
+ }).property('templateName').cacheable(),
- // If there is no template but a templateName has been specified,
- // try to lookup as a spade module
- if (!template && templateName) {
- if ('undefined' !== require && require.exists) {
- if (require.exists(templateName)) { template = require(templateName); }
- }
+ /**
+ A view may contain a layout. A layout is a regular template but
+ supercedes the `template` property during rendering. It is the
+ responsibility of the layout template to retrieve the `template`
+ property from the view and render it in the correct location.
- if (!template) {
- throw new Ember.Error(fmt('%@ - Unable to find template "%@".', [this, templateName]));
- }
+ This is useful for a view that has a shared wrapper, but which delegates
+ the rendering of the contents of the wrapper to the `template` property
+ on a subclass.
+
+ @field
+ @type Function
+ */
+ layout: Ember.computed(function(key, value) {
+ if (arguments.length === 2) { return value; }
+
+ var layoutName = get(this, 'layoutName'),
+ layout = this.templateForName(layoutName, 'layout');
+
+ return layout || get(this, 'defaultLayout');
+ }).property('layoutName').cacheable(),
+
+ templateForName: function(name, type) {
+ if (!name) { return; }
+
+ var templates = get(this, 'templates'),
+ template = get(templates, name);
+
+ if (!template) {
+ throw new Ember.Error(fmt('%@ - Unable to find %@ "%@".', [this, type, name]));
}
- // return the template, or undefined if no template was found
- return template || get(this, 'defaultTemplate');
- }).property('templateName').cacheable(),
+ return template;
+ },
/**
The object from which templates should access properties.
@@ -276,7 +309,10 @@ Ember.View = Ember.Object.extend(
@param {Ember.RenderBuffer} buffer The render buffer
*/
render: function(buffer) {
- var template = get(this, 'template');
+ // If this view has a layout, it is the responsibility of the
+ // the layout to render the view's template. Otherwise, render the template
+ // directly.
+ var template = get(this, 'layout') || get(this, 'template');
if (template) {
var context = get(this, 'templateContext'), | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.