From fe66d52a22a5957efc24af6bf21f0a94db504ae0 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 31 Aug 2015 15:52:04 -0700 Subject: [PATCH] Don't copy `null` attributes passed to JX.$N() Summary: Fixes T8919. In Safari, `node.href = null;` has no effect, but in Chrome it is like `node.href = "null";`. Instead, just use semantics similar to `phutil_tag()`: don't assign attributes with `null` values. Test Plan: No more `/null` href in Chrome in Owners typehaead. Typeahead still works in Chrome/Safari. Reviewers: chad Reviewed By: chad Maniphest Tasks: T8919 Differential Revision: https://secure.phabricator.com/D14021 --- webroot/rsrc/externals/javelin/lib/DOM.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/webroot/rsrc/externals/javelin/lib/DOM.js b/webroot/rsrc/externals/javelin/lib/DOM.js index c131d107cb..189d778ad5 100644 --- a/webroot/rsrc/externals/javelin/lib/DOM.js +++ b/webroot/rsrc/externals/javelin/lib/DOM.js @@ -310,7 +310,13 @@ JX.$N = function(tag, attr, content) { } } - JX.copy(node, attr); + for (var k in attr) { + if (attr[k] === null) { + continue; + } + node[k] = attr[k]; + } + if (content) { JX.DOM.setContent(node, content); } -- 2.54.0