Giter Site home page Giter Site logo

hackur / microdata-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from termi/microdata-js

0.0 2.0 0.0 408 KB

Implementation of the HTML5 Microdata specification for all browsers (including IE8, IE7, IE6 with es5 and DOM shims)

JavaScript 27.88% HTML 71.76% CSS 0.36%

microdata-js's Introduction

Implementation of the HTML5 Microdata specification

Example

var img = document.createElement("img");
img.itemProp = "test";
img.src = "http://example.org/example.jpg";
img.itemValue == img.src;//True

var div = document.createElement("div");
div.appendChild(p);
div.itemScope = true;
div.innerHTML = "<div><span><p itemprop=test>some test</p></span></div>";
div.properties["test"][0].itemValue;//"some test"

More examples in example folder

Microdata JS API

  • Element.itemValue
  • Element.itemProp
  • Element.itemScope
  • Element.itemId
  • Element.itemType
  • Element.itemRef
  • Element.properties
  • window.microdata_liveProperties = true - for auto update Element.properties value false (default) - for cached Element.properties value

Install

  • For modern browsers and IE8+:
  1. First add ES5 and DOM shim (for now only this shim supported: https://github.com/termi/ES5-DOM-SHIM/)
<script src="a.js"></script>
  1. When add microdata script
<script src="microdata-js.js"></script>
  • For IE8+ support:
  1. Add ES5 and DOM shim and microdata script as:
<!--[if IE 8]>
<script src="a.ie8.js"></script>
<![endif]-->
<script src="a.js"></script>
<script src="microdata-js.js"></script>

EXTRAs

TODO::

Features

  • Live "properties" property (turn it on manualy window.microdata_liveProperties = true)
  • Implementation of PropertyNodeList and HTMLPropertiesCollection prototypes
  • Extending DocumentFragment.prototype with getItems function
  • Extending PropertyNodeList and HTMLPropertiesCollection prototypes with toJSON functions
  • Inherit native PropertyNodeList and HTMLPropertiesCollection prototypes from Array

Browsers support

  • Opera < 12, Google Chrome, Safary, FireFox, IE8 and maybe others

Tests

tests/Microdata_tests_files/Microdata_tests.html based on Opera microdata tests

LIMITATION

  1. Require window.DOMStringCollection (DOMSettableTokenList like object) (created by https://github.com/termi/ES5-DOM-SHIM/)
  2. Opera >= 11.60:
  • PropertyNodeList.values, PropertyNodeList.toJSON and HTMLPropertiesCollection.toJSON propertys will be available only after window.onload event

TODO

  1. Live HTMLElement.prototype without window.microdata_liveProperties option
  2. Delete code adding "values" property if it not compliance with FINALE Microdata specification
  3. FireFox bug $0.itemId = "" -> $0.itemId != ""

License

MIT

microdata-js's People

Contributors

termi avatar

Watchers

Jeremy Sarda avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.