Test for presence of event before using its target!

This commit is contained in:
Patrick Filler 2011-09-28 11:31:10 -04:00
parent 66e5da9dec
commit 5a783bbb96
6 changed files with 12 additions and 12 deletions

View file

@ -161,13 +161,13 @@
} }
}; };
Chosen.prototype.container_mousedown = function(evt) { Chosen.prototype.container_mousedown = function(evt) {
var target; var target_node;
if (!this.is_disabled) { if (!this.is_disabled) {
target = evt.target; target_node = evt != null ? evt.target.nodeName : null;
if (evt && evt.type === "mousedown") { if (evt && evt.type === "mousedown") {
evt.stopPropagation(); evt.stopPropagation();
} }
if (!this.pending_destroy_click && target.nodeName !== "ABBR") { if (!this.pending_destroy_click && target_node !== "ABBR") {
if (!this.active_field) { if (!this.active_field) {
if (this.is_multiple) { if (this.is_multiple) {
this.search_field.val(""); this.search_field.val("");

File diff suppressed because one or more lines are too long

View file

@ -152,13 +152,13 @@
} }
}; };
Chosen.prototype.container_mousedown = function(evt) { Chosen.prototype.container_mousedown = function(evt) {
var target; var target_node;
if (!this.is_disabled) { if (!this.is_disabled) {
target = evt.target; target_node = evt != null ? evt.target.nodeName : null;
if (evt && evt.type === "mousedown") { if (evt && evt.type === "mousedown") {
evt.stop(); evt.stop();
} }
if (!this.pending_destroy_click && target.nodeName !== "ABBR") { if (!this.pending_destroy_click && target_node !== "ABBR") {
if (!this.active_field) { if (!this.active_field) {
if (this.is_multiple) { if (this.is_multiple) {
this.search_field.clear(); this.search_field.clear();

File diff suppressed because one or more lines are too long

View file

@ -123,10 +123,10 @@ class Chosen
container_mousedown: (evt) -> container_mousedown: (evt) ->
if !@is_disabled if !@is_disabled
target = evt.target target_node = if evt? then evt.target.nodeName else null
if evt and evt.type is "mousedown" if evt and evt.type is "mousedown"
evt.stopPropagation() evt.stopPropagation()
if not @pending_destroy_click and target.nodeName != "ABBR" if not @pending_destroy_click and target_node != "ABBR"
if not @active_field if not @active_field
@search_field.val "" if @is_multiple @search_field.val "" if @is_multiple
$(document).click @click_test_action $(document).click @click_test_action

View file

@ -118,10 +118,10 @@ class Chosen
container_mousedown: (evt) -> container_mousedown: (evt) ->
if !@is_disabled if !@is_disabled
target = evt.target target_node = if evt? then evt.target.nodeName else null
if evt and evt.type is "mousedown" if evt and evt.type is "mousedown"
evt.stop() evt.stop()
if not @pending_destroy_click and target.nodeName != "ABBR" if not @pending_destroy_click and target_node != "ABBR"
if not @active_field if not @active_field
@search_field.clear() if @is_multiple @search_field.clear() if @is_multiple
document.observe "click", @click_test_action document.observe "click", @click_test_action