function measureItem(list, opt_item) {
    var dataModel = list.dataModel;
    if (!dataModel || !dataModel.length)
      return 0;
    var item = opt_item || list.createItem(dataModel.item(0));
    if (!opt_item)
      list.appendChild(item);

    var rect = item.getBoundingClientRect();
    var cs = getComputedStyle(item);
    var mt = parseFloat(cs.marginTop);
    var mb = parseFloat(cs.marginBottom);
    var ml = parseFloat(cs.marginLeft);
    var mr = parseFloat(cs.marginRight);
    var h = rect.height;
    var w = rect.width;
    var mh = 0;
    var mv = 0;

    // Handle margin collapsing.
    if (mt < 0 && mb < 0) {
      mv = Math.min(mt, mb);
    } else if (mt >= 0 && mb >= 0) {
      mv = Math.max(mt, mb);
    } else {
      mv = mt + mb;
    }
    h += mv;

    if (ml < 0 && mr < 0) {
      mh = Math.min(ml, mr);
    } else if (ml >= 0 && mr >= 0) {
      mh = Math.max(ml, mr);
    } else {
      mh = ml + mr;
    }
    w += mh;

    if (!opt_item)
      list.removeChild(item);
    return {
        height: Math.max(0, h), marginVertical: mv,
        width: Math.max(0, w), marginHorizontal: mh};
  }
Creates an item (dataModel.item(0)) and measures its height.
@param {!List} list The list to create the item for.
@param {ListItem=} opt_item The list item to use to do the measuring. If
    this is not provided an item will be created based on the first value
    in the model.
@return {{height: number, marginVertical: number, width: number,
    marginHorizontal: number}} The height and width of the item, taking
    margins into account, and the height and width of the margins
    themselves.