Files
phabricator/webroot/rsrc/js/application/repository/repository-crossreference.js
vrana 0cdc4e008d Use textContent instead of innerHTML for linking symbols
Summary: Go to https://secure.phabricator.com/D2646#59cc9d49 and click on `array_mergev` to repro.

Test Plan: Checked if the property exists in DOM inspector.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D2742
2012-06-13 14:45:45 -07:00

37 lines
1.0 KiB
JavaScript

/**
* @provides javelin-behavior-repository-crossreference
* @requires javelin-behavior
* javelin-dom
* javelin-uri
*/
JX.behavior('repository-crossreference', function(config) {
// NOTE: Pretty much everything in this file is a worst practice. We're
// constrained by the markup generated by the syntax highlighters.
var container = JX.$(config.container);
JX.DOM.alterClass(container, 'repository-crossreference', true);
JX.DOM.listen(
container,
'click',
'tag:span',
function(e) {
var target = e.getTarget();
var map = {nc : 'class', nf : 'function'};
if (JX.DOM.isNode(target, 'span') && (target.className in map)) {
var symbol = target.textContent || target.innerText;
var uri = JX.$U('/diffusion/symbol/' + symbol + '/');
uri.addQueryParams({
type : map[target.className],
lang : config.lang,
projects : config.projects.join(','),
jump : true
});
window.open(uri);
e.kill();
}
});
});