Merges multiple tags into a single tag and all related objects are reassigned
423170
def merge(request, obj_id):
    """"""
    res = Result()
    if request.POST:
        tags = json.loads(request.POST['tags'])
    else:
        tags = json.loads(request.body)['body']['tags']

    guids = []
    images = Image.objects.filter(tags__id__in=tags)
    guids += [_.guid for _ in images]
    videos = Video.objects.filter(tags__id__in=tags)
    guids += [_.guid for _ in videos]
    # -- Remove all tags from objects
    _manageTags(tags, guids, add=False)
    # -- Add merged tag to all objects
    _manageTags([obj_id], guids, add=True)
    # -- Delete old tags
    Tag.objects.filter(pk__in=tags).delete()

    return JsonResponse(res.asDict())
594082
function merge(docset, customTags) {
  doc_ast.linenr = docset["linenr"];

  // useful for applying global NS items to the proper NS
  docset["original_name"] = docset["code"].name;
  docset["comment"] = doc_ast.detect(docset["tagname"], docset["comment"], customTags);
  
  return Merger.merge(docset);
}
426659
private void mergeOneOf() {
        if (SchemaCompositeMatchers.hasOneOf().matches(schema)) {
            SchemaList list = schema.getOneOf();
            Schema choice = list.get(rnd.nextInt(list.size()));
            schema.getJson().remove("oneOf");
            schema.merge(choice);
        }
    }
873478
function updateHandlerTags(handler) {
  let { event, tags, goesBefore, goesAfter } = handler
  let eventTags = events[event] && events[event].tags

  if (!tags || !tags.length || !eventTags) {
    return handler
  }

  tags = expandImplied(tags, eventTags, 'implies')

  for (let i = 0; i < tags.length; i++) {
    let tag = tags[i]
    let tagGoesBefore = eventTags[tag] && eventTags[tag].goesBefore
    let tagGoesAfter = eventTags[tag] && eventTags[tag].goesAfter

    if (tagGoesBefore) {
      goesBefore = goesBefore || []
      goesBefore.push(...tagGoesBefore)
    }

    if (tagGoesAfter) {
      goesAfter = goesAfter || []
      goesAfter.push(...tagGoesAfter)
    }
  }

  goesBefore = goesBefore && expandImplied(goesBefore, eventTags, 'impliedBy')
  goesAfter = goesAfter && expandImplied(goesAfter, eventTags, 'impliedBy')

  handler.tags = tags
  handler.goesBefore = goesBefore
  handler.goesAfter = goesAfter

  return handler
}
482749
function () {
      var tlis = obj.data("tlis");
      var tlid = obj.data("tlid");

      if (tlid.length > 0) {
        var tagId = tlid.pop();
        tlis.pop();
        // console.log("TagIdToRemove: " + tagId);
        jQuery("#" + objName + "_" + tagId).remove();
        refreshHiddenTagList();
        // console.log(tlis);
      }
    }
791546
function merge() {
  let i = 1
    , key
    , val
    , obj
    , target
    ;

  // make sure we don't modify source element and it's properties
  // objects are passed by reference
  target = clone( arguments[0] );
  while (obj = arguments[i++]) {
    for (key in obj) {
      if ( !hasOwn(obj, key) ) {
          continue;
      }

      val = obj[key];
      if ( isObject(val) && isObject(target[key]) ){
        // inception, deep merge objects
        target[key] = merge(target[key], val);
      } else {
        let is_url = val && val.type == url;
        let is_path = val && val.type == path;

        // make sure arrays, regexp, date, objects are cloned
        target[key] = clone(val);
        if( is_url ){
          target[key].type = url;
        }

        if( is_path ){
          target[key].type = path;
        }
      }
    }
  }
  return target;
}
1255067
function tag(name, attrs, close, content) {
  var end = close ? '/>' : '>';
  var pairs = [];
  var tag;

  for (var key in attrs) {
    if (Object.prototype.hasOwnProperty.call(attrs, key)) {
      pairs.push(key + '="' + escape(attrs[key]) + '"');
    }
  }

  tag = '<' + name + (pairs.length ? ' ' + pairs.join(' ') : '') + end;
  if (content) {
    tag += content + '</' + name + end;
  }
  return tag;
}
29840
private static String mergeTags(RoxableTest mAnnotation, RoxableTestClass cAnnotation) {
		List<String> tags = new ArrayList<>();
		
		if (mAnnotation != null) {
			tags.addAll(Arrays.asList(mAnnotation.tags()));
		}
		
		if (cAnnotation != null) {
			tags.addAll(Arrays.asList(cAnnotation.tags()));
		}

		return Arrays.toString(tags.toArray(new String[tags.size()]));
	}
1253036
function replaceElementTagMentions (element, selector) {
  const processor = selectorParser((selectors) => {
    let nodesToReplace = []

    /**
     * looping breaks if we replace dynamically
     * so instead collect an array of nodes to swap and do it at the end
     */
    selectors.walk((node) => {
      if (node.value === element.tag && node.type === 'tag') { nodesToReplace.push(node) }
    })

    nodesToReplace.forEach((node) => node.replaceWith(element.pseudos.root))
  })

  return processor.process(selector).result
}
151428
def _removeTags(tags, objects):
    
    for t in tags:
        for o in objects:
            o.tags.remove(t)

    return True
1188164
function() {
			var parent = this.parent;
			var ix = parent.children.indexOf(this);
			var items = utils.flatten(arguments);
			spliceFn.apply(parent.children, [ix, 1].concat(items));
			
			// update parent
			items.forEach(function(item) {
				item.parent = parent;
			});
		}
844871
function (target, objects, options) {

            for (var object in objects) {
                if (objects.hasOwnProperty(object)) {
                    recursiveMerge(target, objects[object]);
                }
            }

            function recursiveMerge(target, object) {
                for (var property in object) {
                    if (object.hasOwnProperty(property)) {
                        var current = object[property];
                        if (utils.getConstructor(current) === 'Object') {
                            if (!target[property]) {
                                target[property] = {};
                            }
                            recursiveMerge(target[property], current);
                        }
                        else {
                            // clearEmpty
                            if (options.clearEmpty) {
                                if (current == null) {
                                    continue;
                                }
                            }
                            target[property] = current;
                        }
                    }
                }
            }

            return target;
        }
1310707
function overrideTags (parent, child, telegraf) {
  const childCopy = {};
  const toAppend = [];
  formatTags(child, telegraf).forEach(tag => {
    const idx = typeof tag === 'string' ? tag.indexOf(':') : -1;
    if (idx < 1) { // Not found or first character
      toAppend.push(tag);
    } else {
      childCopy[tag.substring(0, idx)] = tag.substring(idx + 1);
    }
  });
  const result = parent.map(tag => {
    const idx = typeof tag === 'string' ? tag.indexOf(':') : -1;
    if (idx < 1) { // Not found or first character
      return tag;
    }
    const key = tag.substring(0, idx);
    if (childCopy.hasOwnProperty(key)) {
      const value = childCopy[key];
      delete childCopy[key];
      return `${key}:${value}`;
    }
    return tag;
  });
  Object.keys(childCopy).forEach(key => {
    result.push(`${key}:${childCopy[key]}`);
  });
  return result.concat(toAppend);
}
298336
def set_tags(
            self,
            tags=""):
        
        self.refresh
        tagList = []
        regex = re.compile(r'@[^@]*', re.S)
        matchList = regex.findall(tags)
        for m in matchList:
            tagList.append(m.strip().replace("@", ""))

        self.refresh
        oldContent = self.to_string(indentLevel=1)
        self.tags = tagList
        newContent = self.to_string(indentLevel=1)

        # ADD DIRECTLY TO CONTENT IF THE PROJECT IS BEING ADDED SPECIFICALLY TO
        # THIS OBJECT
        self.parent._update_document_tree(
            oldContent=oldContent,
            newContent=newContent
        )
        self.refresh
        return None
1247962
def merge_ligolws(elem):
	
	ligolws = [child for child in elem.childNodes if child.tagName == ligolw.LIGO_LW.tagName]
	if ligolws:
		dest = ligolws.pop(0)
		for src in ligolws:
			# copy children;  LIGO_LW elements have no attributes
			map(dest.appendChild, src.childNodes)
			# unlink from parent
			if src.parentNode is not None:
				src.parentNode.removeChild(src)
	return elem
330121
def reindex
      @tags = {}
      self.each_with_index do |field, i|
        @tags[field.tag] ||= []
        @tags[field.tag] << i
      end
      @clean = true
    end
390008
def _handle_tag_removeobject(self):
        """"""
        obj = _make_object("RemoveObject")
        obj.CharacterId = unpack_ui16(self._src)
        obj.Depth = unpack_ui16(self._src)
        return obj