Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

d3.ie8.js #49

Merged
merged 21 commits into from
Jan 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,28 @@ JS_FILES = \

JS_COMPILER ?= uglifyjs

all: aight.js aight.min.js
# TODO aight.d3.min.js
all: \
aight.js \
aight.min.js \
d3.ie8.js \
d3.ie8.min.js

aight.js: $(JS_FILES)
cat $(JS_FILES) > $@

d3.ie8.js: d3/d3.js
cat $^ | ./bin/aight >> $@
cat src/d3.ie8.js >> $@

%.min.js: %.js
$(JS_COMPILER) $< > $@

d3/d3.js:
curl http://d3js.org/d3.v3.js > $@

clean:
rm -f aight.js aight.min.js
rm -f d3.ie8.js d3.ie8.min.js

distclean: clean
rm -f d3/d3.js
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ and other libraries that rely on them. It includes:
need to bring your own
[html5shiv-printshiv.js](https://github.com/aFarkas/html5shiv/#html5shiv-printshivjs).

* An [IE8-friendly build](#d3-ie8) of [D3](http://d3js.org).

## Installation
You have some options:

Expand Down Expand Up @@ -87,7 +89,7 @@ comment](http://www.quirksmode.org/css/condcom.html) inside the `<head>`:

```html
<!--[if lte IE 9]>
<script type="text/javascript" src="aight.min.js"></script>
<script src="aight.min.js"></script>
<![endif]-->
```

Expand All @@ -110,6 +112,26 @@ Bringing it all together, you end up with:

For your convenience, this snippet is included with aight in `template.html`.

## D3 for IE8 <a name="d3-ie8"></a>
IE8 barfs on [some parts](https://github.com/mbostock/d3/pull/2209) of
[D3](http://d3js.org)'s JavaScript. The included `d3.ie8.js` and minified
`d3.ie8.min.js` are IE8-friendly builds of [d3.v3.js](http://d3js.org/d3.v3.js)
with shams for some CSS properties, namely `opacity`. You'll need to tweak your
HTML to use these, e.g.:

```html
<!--[if lte IE 9]><script src="aight.js"></script><![endif]-->
<script src="http://d3js.org/d3.v3.min.js"></script>
<!--[if IE 8]><script src="d3.ie8.js"></script><![endif]-->
```

Since conditional comments are inaccessible to other browsers, we
have to download the "modern" d3.js (which will throw errors in IE8)
*and* the shimmed one (which won't). It's an imperfect solution,
obviously. You *may* serve `d3.ie8.js` to modern browsers, but there
will probably be performance implications depending on how you use
D3.

## What about SVG? <a name="svg"></a>
Shimming SVG support is tricky business. If you need to support IE8, my
suggestion is either to [degrade gracefully](https://www.google.com/search?q=graceful%20degradation)
Expand Down
68 changes: 0 additions & 68 deletions aight.d3.js

This file was deleted.

16 changes: 12 additions & 4 deletions aight.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
;(function(aight) {

aight.version = "2.0.5";
aight.version = "2.1.0";

var nav = null,
version = 0,
Expand Down Expand Up @@ -1000,16 +1000,24 @@ if (aight.browser.ie < 9) {
/* CSS Object Model patches */
(function(CSSSDProto) {

function getAttribute(property) {
return property.replace(/-[a-z]/g, function(bit) {
return bit[1].toUpperCase();
});
}

// patch CSSStyleDeclaration.prototype using IE8's methods
if (typeof CSSSDProto.setAttribute !== "undefined") {
CSSSDProto.setProperty = function(property, value) {
return this.setAttribute(String(property), value /*, important */ );
return this.setAttribute(getAttribute(property), String(value) /*, important */ );
};
CSSSDProto.getPropertyValue = function(property) {
return this.getAttribute(property);
return this.getAttribute(getAttribute(property)) || null;
};
CSSSDProto.removeProperty = function(property) {
return this.removeAttribute(property);
var value = this.getPropertyValue(property);
this.removeAttribute(getAttribute(property));
return value;
};
}

Expand Down
4 changes: 2 additions & 2 deletions aight.min.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion bin/aight
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ var transforms = {
right = node.right.source(),
wrapped = !!node.body.source().match(/^\s*\{/);
node.body.update([
"if (", right, ".hasOwnProperty(", left, ")) ",
"if (__hasOwnProperty(", left, ")) ",
wrapped ? "" : "{ ",
node.body.source(),
wrapped ? "" : " }",
].join(""));
node.update([
"\nvar __hasOwnProperty = Object.prototype.hasOwnProperty.bind(", right, ");\n",
node.source()
].join(""));
}
},
transform = function(node) {
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "aight",
"main": "./aight.js",
"version": "2.0.5",
"version": "2.1.0",
"homepage": "https://github.com/shawnbot/aight",
"authors": [
"Shawn Allen <shawn.allen@hush.com>"
Expand Down
Loading