UNPKG

instant

Version:

drop-in replacement for connect.static with live-reload support

20 lines (16 loc) 520 B
var parseUrl = require('./url') /** * Find the first element with the given tag-name whoes property `prop` * matches the specified url. */ exports.byURL = function(name, prop, url) { var el = document.getElementsByTagName(name) for (var i=0; i < el.length; i++) if (parseUrl(el[i][prop]).pathname == url.pathname) return el[i] } exports.bySelector = function(sel) { return document.querySelector && document.querySelector(sel) } exports.byClass = function(cls) { return exports.bySelector('.' + cls) }