/**
 * Created by baoyinghai on 4/18/17.
 */
import React from 'react';

export default class AnchorHref extends React.Component {
  static defaultProps = {
    name: 'AnchorHref'
  };

  /* eslint-disable */
  static propTypes = {
    href: React.PropTypes.string,
    title: React.PropTypes.string,
  };

  render() {
    return (<span className="anchorTag">{this.props.title}<a href={this.props.href} /></span>);
  }
}

export const queryAnchor = () => {
  // TODO: 暂时使用document
  const ret = [];
  const anchorLink = document.querySelectorAll("span[class='anchorTag']");
  console.log('#######len', anchorLink.length);
  anchorLink.forEach((a, index) => {
    ret.push({ index: index, href: a.children[0].attributes[0].nodeValue, title: a.innerText, offsetTop: a.offsetTop });
  });
  console.log('#######len', ret);
  return ret;
};
