19
  1. Pick a question with tag (from here)
  2. Click edit or edit tags if you have the privilege.
  3. See if the question waiting for editing still has the tag.

I tried with a dozen questions or so, every time it just disappears, why is it? Someone really hates constructors and wants to kick it away? Interestingly, the tag is fine.

  • Before edit:

before edit

  • During edit:

during edit

As @hayd and @hims056 points out, it's also not in the tag box when editing, but it's not blacklisted (10K user only).

constructor tag

  • Reproduced in Firefox Aurora 30.0a2. I wonder if a constructor is getting called or referenced by accident somewhere. – doppelgreener Mar 25 '14 at 6:59
  • It's also not available if you write it in the tags box. – hayd Mar 25 '14 at 7:10
  • 1
    I doubted it is blacklisted. But it isn't. – hims056 Mar 25 '14 at 7:16
  • @hayd True, so whenever a question with tag [constructor] is edited, the tag is gone forever. What a sad story. – Yu Hao Mar 25 '14 at 7:18
  • 2
    Well, the bug is client side, the server is returning correct data including the "constructor" tag itself. – ShaWiz Mar 25 '14 at 8:00
  • 3
    I'm going to call it: whatever's populating that tag list just so happens to be calling foo['constructor'], and foo is an object or function, so it's returning an actual constructor function. – doppelgreener Mar 25 '14 at 8:54
4

Fixed in build rev 2014.3.24.2092 on meta and rev2014.3.24.1492 on sites.

  • if (existing[data[i].Name] === true) continue; // don't render existing tags Fixed using my suggestion. Muahahahaha. – michaelb958 Mar 25 '14 at 20:45
  • @michaelb958 tnx for spoiling the fun :) – m0sa Mar 25 '14 at 21:42
7

Jonathan Hobbs (in the comments) called correctly; this is a collision with a property of a raw JS object.

The tag editor uses functionality in tageditornew.en.js (link) for its autocompletion. Step one is to get the appropriate values from the server. This returns JSON starting with

[{"Name":"constructor","Synonyms":"constructors","Count":7280,"Excerpt":"A special type of subroutine called at the creation of an object."},...

(the ... being my addition). So the tag is making its merry way down from the server.

Step two is to check if that tag is already in use. The critical code:

function showTagSuggestions(data, typed) {
    // ...
    var existing = {};
    editor.find('.post-tag').each(function () { existing[$(this).text()] = true; });
    for (var i = 0; i < data.length; i++) {
        if (existing[data[i].Name]) continue; // don't render existing tags

Note the use of a bare object to hold already-used tags.

Console

>>> ({}).constructor
Object()

This attribute conflicts, as predicted, with the constructor tag, so step three (render the tag and add it to the list of suggestions) is skipped, as "the tag is already in use" (except it isn't; it just conflicts with a JS property).

That is a really dumb comparison in the above code; I suggest changing it to

if (existing[data[i].Name] === true) continue;

or using some other string storage mechanism that doesn't have this conflict potential.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .